27

Can someone explain the difference between symbols:

$\rightarrow$ and $\mapsto$

Thanks.

iLemming
  • 379
  • 5
    See also: http://math.stackexchange.com/questions/1751187/what-does-the-function-f-x-%E2%86%A6-y-mean and http://math.stackexchange.com/questions/473247/different-of-mapsto-and-right-arrow – Martin Sleziak Apr 20 '16 at 13:48

3 Answers3

39

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$.

Plutoro
  • 22,730
  • 3
  • 41
  • 71
  • 3
    so why then different arrows needed? Sets are denoted using capital letters and elements using lowercase letters, isn't that enough? – iLemming Apr 13 '16 at 03:41
  • 3
    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. – Plutoro Apr 13 '16 at 03:43
  • 1
    @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. – Bunny Apr 13 '16 at 03:43
  • 7
    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...) – Eric Stucky Apr 13 '16 at 03:43
  • 1
    Since a set may be an element of another set, it is not possible to reserve lower-case for members only, and upper-case for sets only. – DanielWainfleet Apr 13 '16 at 05:09
  • 3
    $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. – Yakk Apr 13 '16 at 14:40
12

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*}$$

Vectornaut
  • 4,860
9

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.

M. Vinay
  • 9,004