This question already has an answer here:

Can someone explain the difference between symbols:

$\rightarrow$ and $\mapsto$

Thanks.

marked as duplicate by Patrick Stevens, Daniel W. Farlow, user223391, Ramiro, user228113 Apr 20 '16 at 20:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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

  • 2
    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 3: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. – Alex S Apr 13 '16 at 3: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. – Red Apr 13 '16 at 3: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 3: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 5:09

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.