Difference of mapsto and right arrow

The arrow $\rightarrow$ denotes a mapping between two sets. The $\mapsto$ is telling you what it does to each element of the set. For example, I can define a function $f: \mathbb{R} \to \mathbb{R}$ by $f(x) := 2x$. Notice that the $\to$ is between the two real number sets. But, I can also express that $f(3) = 6$ by $3 \mapsto 6$. More generally, $f(x) := 2x$ can be written as $x \mapsto 2x$


We can say:$$f:\{1,2,3\}\to\{4, 5, 6\}$$ This is a function from the set $\{1,2,3\}$ to the set $\{4, 5, 6\}$. Both things on the right and left of the arrow are sets.

But, if we say: $$1\mapsto5$$ This says that when we put $1$ into the function/relation/whatnot, we get out a $5$. Both things on the left and right of the arrow are elements of the the domain/codomain.

This is not to say that we couldn't have a function like:* $$f:\{\{1, 2\},\{3, 4\},\{5, 6\}\}\to\{4, 5, 6\}\text{ such that:}\\\{1, 2\}\mapsto 4\\\vdots\\\text{etc.}$$ In this case, one of the things on the right/left of the $\mapsto$ is a set. We could even make both of the things a set; it doesn't matter for $\mapsto$, but $\to$ must have sets on both sides. The $\mapsto$ is really just specifying what we get out when we put in something.


Typically $\to$ is used when specifying the domain and codomain of an arbitrary function while $\mapsto$ is used in explicit definitions. So $f: A \to B$ means that $f$ is a function with domain $A$ and codomain $B$ (note $B$ might not be the range of $f$). Notice this doesn't define a specific $f$ from $A$ to $B$, but instead could represent any such function.

On the other hand, when I say $f: \mathbb{R} \to \mathbb{R}$ is defined by $f: x \mapsto x^2$, the second arrow simply says that this is the function $f(x) = x^2$.