## The Basics of Functions

**Definition.** A function $f$ from a set $X$ to a set $Y$ is a relation which satisfies the following two conditions:

- $\forall x\in X, \exists y\in Y: (x,y)\in f$, and
- $\forall x\in X, y_1,y_2\in Y, \left[(x,y_1)\in f \wedge (x,y_2)\right]\in f\Rightarrow y_1=y_2$

That is, a function assigns to *each* (clause 1) element of $X$ an element of $Y$, and that assignment is unambiguous (clause 2). Since we could rewrite clause 1 as $\operatorname{Domain}(f)=X$ (**why?**), we’ll refer to clause 1 as the “domain clause” and clause 2 as the “unambiguousness clause”.

**Notation. **Instead of the mouthful $f$ is a function from $X$ to $Y$, we write the shorthand $f:X\rightarrow Y$.

We also have this familiar notation:

**Notation. **If $f$ is a function from $X$ to $Y$, and $(x,y)\in f$, we write $y=f(x)$.

Observe that if $(x,y_1)\in f$ and $(x,y_2)\in f$, then this notation reads as follows: $y_1=f(x)$ and $y_2=f(x)$, so we’d *darn well better* have $y_1=y_2$, or else something is very wrong.

There is another way to represent a function, by specifying its domain and its rule:

**Notation. **If $f$ is a function from $X$ to $Y$, we write $f:X\rightarrow Y$. To specify the rule that $f$ uses, we write \begin{align*}f:X&\rightarrow Y\\x&\mapsto f(x) \end{align*}

For example, we could denote the function which takes in a real number as input, and squares it by

\begin{align*} sq:\mathbb{R}&\rightarrow\mathbb{R}\\ t&\mapsto t^2 \end{align*}

Notice that the arrow between the sets is a different shape from the one between elements of the set. As usual we want to let go of our $x$s, so we could as well have written

\begin{align*} sq:\mathbb{R}&\rightarrow\mathbb{R}\\ z&\mapsto z^2 \end{align*}

or

\begin{align*} sq:\mathbb{R}&\rightarrow\mathbb{R}\\ Q&\mapsto Q^2 \end{align*}

This frees us from the tyranny of always writing $y=f(x)$.