Function composition is one of 2 functions formulas in the precalculus section of this library, and it is used at high school level.
Why function composition works
Composition wires two machines in a row: whatever g produces becomes the raw material for f. The parentheses show the wiring, since g sits inside and therefore runs first. The result is a brand new function whose rule is f's rule with g's whole expression written wherever x used to be.
What each symbol means
$g$ is applied first and $f$ second.
Function composition: when it holds
$x$ must lie in the domain of $g$ and $g(x)$ in the domain of $f$.
When it stops applying
The chain breaks if g produces something f cannot accept. With f(x) = √x and g(x) = x − 5, the composition f(g(3)) asks for the square root of −2, so 3 is excluded from the domain even though both functions handle it fine on their own.
Function composition: a worked example
If $f(x)=x^2$ and $g(x)=x+1$, then $(f\circ g)(x)=(x+1)^2$.
The mistake to avoid
What people do: Students run the functions in the order they are written and compute g(f(x)) by accident.
Why it goes wrong: Composition is read from the inside out, and the two orders usually disagree. With f(x) = x² and g(x) = x + 1 at x = 2, f(g(2)) is 9 while g(f(2)) is 5.
Do this instead: Evaluate the inner function first, then feed its output to the outer one. Writing the inner value down as its own number before the second step makes the order impossible to confuse.
Function composition: step by step
- Name the unknown, and the unit the answer has to come out in.
- Match the symbols to your values. $g$ is applied first and $f$ second.
- Check the conditions before substituting. $x$ must lie in the domain of $g$ and $g(x)$ in the domain of $f$.
- Substitute, keep exact values to the last line, then test the sign, size, and unit against a rough estimate — the check that catches most precalculus slips.
Where this formula fits
- Subject
- Precalculus formulas — 10 entries in this library
- Topic
- Functions
- Level
- High school
Formulas are easiest to keep when they sit inside a method rather than on a list. Use the links below to see where function composition comes from, to check a calculation against a tool, and to practise it until you can recall it without looking.
- Inverse Functions — the lesson behind this formula: reverse a one-to-one function and verify by composition.
- Precalculus Calculator — check your substitution and the value it produces.
- Study precalculus — the subject guide that explains the ideas these formulas compress.
- Precalculus Practice — questions that make you retrieve the formula instead of recognising it.
- All 10 precalculus formulas — the full grouped reference, or the complete formula library.
Questions about function composition
Is f∘g the same as f times g?
No, and the small circle is what keeps them apart. The product multiplies two outputs, while the composition feeds one output into the other function, and they rarely agree on anything.
Is composition ever commutative?
Occasionally, but do not count on it. It holds when one function is the other's inverse, or in a case like f(x) = x + 1 and g(x) = x + 2, where both orders give x + 3.
How do I find the domain of a composition?
Keep only the inputs g accepts, then throw out any whose output f cannot take. Both restrictions apply, so the domain of the composition is usually smaller than the domain of g.
Where does this show up in calculus?
In the chain rule, which is the derivative of a composition. Spotting the inner and outer functions is exactly the skill that makes differentiating something like sin(3x² + 1) routine.