Can someone explain the difference between symbols:

$\rightarrow$ and $\mapsto$



When referring to functions, $\rightarrow$ points from the domain of the function to its codomain. When we write $f:A\to B$, we mean that $f$ takes things in $A$ and maps them to thing in $B$. The symbol $\mapsto$ points from an element of the domain to its image in the codomain. $f:x\mapsto y$ means that $f(x)=y$.

  • 3
    $\begingroup$ so why then different arrows needed? Sets are denoted using capital letters and elements using lowercase letters, isn't that enough? $\endgroup$
    – iLemming
    Apr 13 '16 at 3:41
  • 3
    $\begingroup$ It's always good to add extra clarity. Besides, elements are not always lowercase. I write matrices as capital letters, and I often deal with functions mapping between sets of matrices. $\endgroup$
    – Alex S
    Apr 13 '16 at 3:43
  • 1
    $\begingroup$ @Agzam You're probably seeing a function that is being represented just with sets like $A \rightarrow B$. This just means what is explained in the answer. If it isn't the case, give an example, because context is everyting with notations. $\endgroup$
    – Red
    Apr 13 '16 at 3:43
  • 7
    $\begingroup$ If, for instance, $f:\mathcal P(A)\to\mathcal P(B)$, then the elements of the domain would be sets :) But a better answer is because the two arrows do psychologically different things: $\to$ just tells you something about the function, whereas $\mapsto$ is closer to actually "defining" a function. (Technically, the information for both arrow types are needed to define the function, but it sure seems like $\mapsto$ is doing most of the work...) $\endgroup$ Apr 13 '16 at 3:43
  • 2
    $\begingroup$ $f:A\to B$ defines the type of the variable $f$, the kind of thing it is. $f:x\mapsto y$ defines the value of the variable $f$. You can often reason about things purely from their types, without having to think about the details of where specific values go. $\endgroup$
    – Yakk
    Apr 13 '16 at 14:40

In programming parlance, $\to$ is part of a type signature, while $\mapsto$ is part of a function definition.

The expression $$x \mapsto \operatorname{floor}(1/x)$$ denotes the function that takes in a number and spits out the floor of its reciprocal.

There are many different type signatures that can be consistently assigned to this function. If you drop in numbers between $0$ and $1$, the function will spit out positive integers, so $$(0, 1) \to \mathbb{N}$$ is one valid type signature.

As M. Vinay noted, it's not unusual to combine these notations in a function definition. For example, I could declare a function $g$ with the definition and type signature above by writing $$\begin{align*} g \colon (0,1) & \to \mathbb{N} \\ x & \mapsto \operatorname{floor}(1/x). \end{align*}$$


For sets $X$ and $Y$, $f\colon X \to Y$ is a function "from $X$ to $Y$", meaning that $f$ has domain $X$ and codomain $Y$. If $y = f(x)$, then we may write $x \mapsto y$, read as "$x$ maps to $y$". This is used only when the function that maps $x$ to $y$ is clear from the context. Sometimes, you may see a function defined as \begin{align*} f\colon\ & \mathbb R \to \mathbb R\\ & x \mapsto 4x^3 \end{align*} instead of $f(x) = 4x^3$.

See here.


Not the answer you're looking for? Browse other questions tagged or ask your own question.