Regarding the notation $f: a \mapsto b$

While I have come to understand that $f:a\mapsto b$ means that for input from the set $a$, the function will return a value from the set $b$, I am curious as to how far one may "drag" this notation. Say $f(x) = x$, would $f: 1 \mapsto 1$ be valid, or does one have to write $f: \mathbb{R} \mapsto \mathbb{R}$? (While I understand that my initial example would seldom prove useful, I am curious as to what is valid notation or not.)


$\to$ : $$ f:X\to Y $$ where $X,Y$ are sets.
$\mapsto$: $$ f:x\mapsto f(x) $$ where $x\in X$ and $f(x)\in Y$, i.e. this notation says what element $x$ in $X$ is mapped to what element $f(x)$ in $Y$.
Writing $f:x\mapsto f(x)$is equivalent to the previous one, but it is written in terms of elements of the sets, not sets (it implies you have already chosen $X,Y$, o.w. it does not make sense).

Examples:

  1. $\mathbb{R}$ is a set so you may write $$ f:\mathbb{R}\to \mathbb{R} $$ NOT $ f:\mathbb{R}\mapsto \mathbb{R} $.

  2. Say you have $f(x)=x^2$, now this only means that you square a certain element $x$ of...what set???? If you choose $\mathbb{R}=X$ then you know $f(2)=4$ but you may have $4\in\mathbb{R},[0,\infty],[0,\infty),\mathbb{R}^4,\mathbb{C}$, say. These $Y$'s make sense for the function $f$, but a different $Y$ imples a different function! (Try to make examples in terms of injectivity and surjectivity.)

HOWEVER (generally) you should choose where the function is living on first (the sets), then you built up the details of $f$ (whether it is $f(x)=x$ or $f(x)=x^2$).


The domain and codomain are part of a function (and a very important part at that). For every set $X$, there exists a function written as $\mbox{Id}_X\colon X\to X$ which is defined by $f(x)=x$ for all $x\in X$. This is known as the identity function on $X$ and is a different function for each $X$. you can only compose functions $f\colon A\to B$ and $g\colon C\to D$ if $B=C$ so that $(g\circ f)\colon A\to B=C\to D$ or more simply $g\circ f\colon A\to D$ and this emphasises why the domain and codomain of a function are important.

To help reinforce how important it is to specify the domain and codomain of a function, here is the definition of function equality.

If $f\colon A\to B$ and $g\colon C\to D$ are functions, then $f$ is equal to $g$, and we write $f=g$, if and only if

$1)$ $A=C$

$2)$ $B=D$

$3)$ For all $x\in A$ we have $f(x)=g(x)$.

If $f\colon \mathbb{R}\to\mathbb{R}$ is given by $f(x)=x^2$ and $g\colon\mathbb{R}\to [0,\infty)$ is given by $g(x)=x^2$ then it is not true that $f$ and $g$ are equal because they do not satisfy the second condition that their codomains are equal, even though they satisfy the other two.


To add to the confusion, let me say this: Some standard functions don’t have standard names, so that if we want to talk about, say, the cubing function, we have to choose a letter to represent it, and then say what it does to a typical element of the the domain. Or, we could talk about “the function $x\mapsto x^3\>$” with the understanding that its domain and target-space (codomain) are $\mathbb R$. The more formal way would be to say, “the function $g\colon\mathbb R\to\mathbb R$ by the rule $g(x)=x^3$”.