# Math Insight

### Composition definition

The composition $f \circ g$ of two functions $f$ and $g$ is the function formed by first applying the function $g$ and then the function $f$. In other words, to apply the composition $f \circ g$ to an input $x$, you perform the following two steps. You first apply the function $g$ to the input $x$ and obtain the result $g(x)$ as the output. Next, you apply the function $f$ using $g(x)$ as the input and obtain the result $f(g(x))$ as the output. We can write the composition as $(f \circ g)(x) = f(g(x))$.

In the simplest case, the input $x$ and the outputs to the functions are just numbers. However, the inputs and outputs to functions could be more complicated objects. If $f$ or $g$ are vector-valued functions, then these objects might instead be vectors.

One can illustrate function composition using the function machine metaphor by connecting function machines together.