I'm confused as to when one uses $\mapsto$ and when one uses $\to$. From what I understand, we use $\to$ when dealing with sets and $\mapsto$ when dealing with elements but I'm not entirely sure.
For example which of the two is used for the following? $$\begin{pmatrix} x \\ y \\ z \end{pmatrix} \cdots \begin{pmatrix} x+y \\ z+y \\ x+z \\ -z\end{pmatrix}$$
The $\to$ arrow points from the domain of a function to its codomain or target set. The $\mapsto$ arrow (fittingly called
\mapstoin TeX) shows what an individual element of the domain will be mapped to, i.e. it shows what the function does while $\to$ shows where it operates (so to say).So, the elaborate way to write a function definition is $$f:\begin{cases}A\to B\\x\mapsto f(x)\end{cases}$$ where "$f(x)$" will typically be something like "$x^2+42$" or whatever. So, both arrows play different roles when describing the function and they are both needed to describe the function as a whole.
But note that you might have a function like $$f:\begin{cases}{\cal P}(\{1,2,3\})\to \mathbb{N}\\A\mapsto |A|\end{cases}$$ where there's a set on the left side of the $\mapsto$, so the rule isn't as easy as "$\to$ is for sets and $\mapsto$ for the rest". (As every set theorist will be eager to explain to you, everything is a set anyway...)
Two examples:
$$f_1:\begin{cases}\mathbb{R}\to \mathbb{R}\\x\mapsto x^3\end{cases} \quad\quad f_2:\begin{cases}\mathbb{N}\to \mathbb{R}\\x\mapsto x^3\end{cases}$$
Here $f_1$ and $f_2$ are different functions. They do the same thing, but on different domains.
$$g_1:\begin{cases}\mathbb{R}\to \mathbb{R}\\x\mapsto x^3\end{cases} \quad\quad g_2:\begin{cases}\mathbb{R}\to \mathbb{R}\\x\mapsto x^5\end{cases}$$
And $g_1$ and $g_2$ are again different functions. This time, they act on the same domain, but they do different things.