In Adding, Subtracting, Multiplying and Dividing Functions you combined two outputs. Composition does something different: the output of one function becomes the input of the next, like two machines on an assembly line.
Key idea
$(f \circ g)(x) = f(g(x))$. Work from the inside out: apply $g$ first, then apply $f$ to the result. To get a formula, replace every $x$ in $f$ with the whole expression $g(x)$.
Why it works
Read $f(g(3))$ like a set of instructions. The parentheses say $g$ acts on 3 first; its output is the only thing $f$ ever sees. Order matters because the processes are different: putting on socks and then shoes is not the same as shoes and then socks. The little circle $\circ$ is read "after": $f \circ g$ is "$f$ after $g$."
Worked examples
Worked example: Numbers first
Let $f(x) = x^2 + 1$ and $g(x) = 2x - 3$. Find $f(g(2))$ and $g(f(2))$.
- $g(2) = 4 - 3 = 1$, then $f(1) = 1 + 1 = 2$. So $f(g(2)) = 2$.
- $f(2) = 4 + 1 = 5$, then $g(5) = 10 - 3 = 7$. So $g(f(2)) = 7$.
Answer: $f(g(2)) = 2$ and $g(f(2)) = 7$: the order changes the answer.
Worked example: A formula for the composition
With the same functions, find $f(g(x))$ and $g(f(x))$.
- Replace $x$ in $f$ with $(2x - 3)$: $f(g(x)) = (2x - 3)^2 + 1$.
- Expand: $4x^2 - 12x + 9 + 1 = 4x^2 - 12x + 10$.
- Replace $x$ in $g$ with $(x^2 + 1)$: $g(f(x)) = 2(x^2 + 1) - 3 = 2x^2 - 1$.
- Check with $x = 2$: $4(4) - 24 + 10 = 2$ and $2(4) - 1 = 7$, matching the first example.
Answer: $f(g(x)) = 4x^2 - 12x + 10$ and $g(f(x)) = 2x^2 - 1$
Worked example: Reading a table
$f(1) = 4$, $f(3) = -2$, $g(2) = 3$ and $g(4) = 1$. Find $f(g(2))$.
- Inside first: $g(2) = 3$.
- Then $f(3) = -2$.
Answer: $f(g(2)) = -2$
Common mistake
Multiplying instead of composing. $f(g(x))$ is not $f(x) \cdot g(x)$. In the first example, $f(2) \cdot g(2) = 5 \cdot 1 = 5$, but $f(g(2)) = 2$. Another slip is working in the wrong order. Check yourself by plugging in one number and evaluating step by step from the inside out.