# Introduction to Functions

Want some more advanced function concepts?

A function is a rule that takes an input, does something to it, and gives an output. Each input has exactly one output.

It is often helpful to think of a function as a box. You drop an input in the top, something happens to the input inside the box, and the output drops out the bottom. The box (the function) can be labeled with what it does. For example, if the box is labeled ‘add 2’, then when the number $\,3\,$ is dropped in the top, the number $\,3+2 = 5\,$ comes out the bottom:

$$\cssId{s15}{\overset{\text{input}}{\overbrace{\ \ 3\ \ }}} \cssId{s16}{\overset{\text{the function adds 2}} { \overset{\text{to the input}}{\overbrace{\strut\ +\ \ 2\ }} }} \cssId{s17}{\overset{\text{and produces }}{\overbrace{\strut\ \ =\ \ }}} \cssId{s18}{\overset{\text{the output}}{\overbrace{\strut\ \ 5\ \ }}}$$

## Examples

Question: Consider the ‘add $\,2\,$’ function. If $\,3\,$ is the input, then what is the output?
Answer: $3 + 2 = 5$
Question: Consider the ‘add $\,2\,$’ function. If $\,x\,$ is the input, then what is the output?
Answer: $x + 2$
Question: Consider the ‘add $\,2\,$’ function. If $\,x + 3\,$ is the input, then what is the output?
Answer: $(x + 3) + 2 = x + 5$
Question: Consider the ‘multiply by $\,2\,$’ function. If $\,x + 5\,$ is the input, then what is the output?
Answer: $2(x + 5) = 2x + 10$