A function is like a machine that follows a specific rule. For every number you put in, you get exactly one number out.
Let's imagine a machine whose rule is "multiply by 2".

If we put in a 3, we get out a 6. If we put in a 5, we get out a 10. A table of values helps us organize these pairs:
| Input | 3 | 5 | 8 | 10 |
| Output | 6 | 10 | 16 | 20 |
To work with these rules more efficiently, mathematicians developed a special notation.
To represent this machine, we write \(\textcolor{olive}{f}(\textcolor{colordef}{\text{input}}) = \textcolor{colorprop}{\text{output}}\). The parentheses \((\) \()\) indicate the action of the function \(\textcolor{olive}{f}\) on the input.
We use function notation to name functions and their variables, replacing "\(\textcolor{colordef}{\text{input}}\)" by "\(\textcolor{colordef}{x}\)" and "\(\textcolor{colorprop}{\text{output}}\)" by "\(\textcolor{colorprop}{f(x)}\)".
A function maps every element from a set of inputs, the
domain \(X\), to an element in a set of possible outputs, the
codomain \(Y\). This is written as \(f: X \to Y\). The specific rule that maps an individual element \(x\) from the domain to an element \(f(x)\) in the codomain is written as \(x \mapsto f(x)\).
In general we write $$\Function{\textcolor{olive}{f}}{\textcolor{colordef}{X}}{\textcolor{colorprop}{Y}}{\textcolor{colordef}{x}}{\textcolor{colorprop}{f(x)}}$$For example, if the rule is "twice the input" and we are mapping real numbers to real numbers, \(f: \mathbb{R} \to \mathbb{R}\):

we have \(\textcolor{olive}{f}(\textcolor{colordef}{x}) = \textcolor{colorprop}{2x}\), which is written in full as:$$\Function{\textcolor{olive}{f}}{\textcolor{colordef}{\mathbb{R}}}{\textcolor{colorprop}{\mathbb{R}}}{\textcolor{colordef}{x}}{\textcolor{colorprop}{2x}}$$When the input is \(\textcolor{colordef}{x} = \textcolor{colordef}{1}\), we get:$$\begin{aligned}\textcolor{olive}{f}(\textcolor{colordef}{1}) &= 2 \times \textcolor{colordef}{(1)}\\
&= \textcolor{colorprop}{2}\end{aligned}$$