Composition of Functions
Feeding one function's output into another, and why order matters.
The explanation
Composing means chaining: run x through g, then feed the result into f.
Written (f∘g)(x) or f(g(x)). Always work from the inside out.
With f(x) = x + 3 and g(x) = 2x:
f(g(x)) = f(2x) = 2x + 3
g(f(x)) = g(x + 3) = 2x + 6
Different answers. Composition is not commutative, and swapping the order is the most common error.
For a numerical value, evaluate the inner function first. f(g(5)) means find g(5), then apply f to that number.
Composition (f∘g)(x) = f(g(x)) applies g first despite f being written first, a notational quirk worth stating explicitly because it drives most errors.
The domain of f∘g is the set of x in the domain of g whose image g(x) lies in the domain of f. Both constraints apply, and the second is often forgotten: for f(x) = √x and g(x) = x − 5, the composition √(x − 5) requires x ≥ 5 even though g alone accepts all reals.
Composition is associative but not commutative. The special case f(g(x)) = g(f(x)) = x for all x characterises inverse functions, which is the standard verification method for an inverse.
Decomposition — writing a complicated function as a composition of simpler ones — is the reverse skill, and is required for the chain rule in calculus: recognising (3x + 1)⁵ as f(g(x)) with f(u) = u⁵ and g(x) = 3x + 1.
Worked example
For f(x) = x² − 1 and g(x) = x + 4, find f(g(2)) and g(f(x)).
- Inner first: g(2) = 6.
- f(6) = 36 − 1 = 35.
- g(f(x)) = g(x² − 1) = (x² − 1) + 4.
Answer: f(g(2)) = 35 and g(f(x)) = x² + 3
Common mistakes
- Applying f first in f(g(x)).
- Multiplying the two functions instead of composing them.