A function in math is a rule (made up of a set of operations on a number) that describes how a given number may be transformed.

### Function Diagram

The expression $3n + 1$ can be described in the format:

$n \rarr \boxed{\times 3} \rarr \boxed{+1} \rarr 3n+1$

Which can be written more explicitly:

$n \rarr \boxed{\times 3} \rarr 3n \rarr \boxed{+1} \rarr 3n+1$

### Mapping/Arrow Diagram

A rule may be described by a mapping of inputs to its outputs:

$\begin{rcases} 1 \rarr 5 \ 2 \rarr 7 \ 3 \rarr 9 \ 4 \rarr 11 \ 5 \rarr 13 \ 6 \rarr 15 \end{rcases}$ $x \rarr 2x+3$

### Domains

The set of valid input numbers of a function is called its domain while the set of possible output numbers is called its codomain.

Domain and codomain of a function are not always explicit.

## Notation

Functions may be written in a number of ways:

### Functional Notation

Ambiguous notation that implicitly uses the set of real number $\reals$ for its domain and codomain.

Given the function definition $f(x) = x + 1$

$f(x)$ becomes shorthand for $x + 1$

$f(x)$ is the image of x of $f$

$f(5) = 6$

This notation is ambiguous because $f(x)$ could refer to $f(x) = x + 1$ or an image of $f$ for a certain number if one has previously been declard for $x$.

### Arrow Notation

Also implies a domain and codomain of $\reals$. This notation is used to define rules inline without naming them.

$x \rarr x^2 + 4$

### Index Notation

Is often used instead of functional notation. It uses a subscript instead of parantheses to name its input.

$f_x$

This notation is typically used for sequences of natural numbers.

## Composite Functions

The output of one function $f(x)$ can be directly channeled into the input of another function $g(x)$ by combining their letters.

$f(x) = x + 2$, $g(x) = x^2$

$gf(x) = (x+2)^2$ (the innermost function is applied first)

## Inverse Function

An inverse function runs a function's opposite operations in reverse order.

$n \rarr \boxed{\times 3} \rarr \boxed{+1} \rarr 3n+1$

$n \larr \boxed{\div 3} \larr \boxed{-1} \larr \frac {n-1}{3}$

The inverse to $f(5) = 11$ is $f^{-1}(11) = 5$

$f(x) = x + 6$

$f^{-1} = x - 6$

### Finding the input of a given output

If a function's rule and an output are known, that output can be traced through the function's inverse rule to find its original input (domain).