Canonical: https://knowlpedia.com/shared-foundations/function/

# Function

A relation that assigns each input exactly one output

A **function** is a [relation](https://knowlpedia.com/shared-foundations/relation/) \(f\subseteq A\times B\) between [sets](https://knowlpedia.com/shared-foundations/set/) \(A\) and \(B\) such that for every \(a\in A\) there exists a unique \(b\in B\) with \((a,b)\in f\); we write this \(b\) as \(f(a)\) and denote the function by \(f:A\to B\).

## Remarks

The set \(A\) is called the [domain](https://knowlpedia.com/shared-foundations/domain/) and the set \(B\) the [codomain](https://knowlpedia.com/shared-foundations/codomain/). Functions allow you to form [images](https://knowlpedia.com/shared-foundations/image/) and [preimages](https://knowlpedia.com/shared-foundations/preimage/) of subsets and to build new functions via [composition](https://knowlpedia.com/shared-foundations/composition/).

## Examples

- The squaring map \(f:\mathbb{N}\to\mathbb{N}\) given by \(f(n)=n^2\) is a function on the [natural numbers](https://knowlpedia.com/shared-foundations/natural-numbers/).
- If \(S\) is a [subset](https://knowlpedia.com/shared-foundations/subset/) of a set \(A\), the inclusion map \(i:S\to A\) defined by \(i(s)=s\) is a function.
