Mathematics
Function composition: which function comes first?
In (f ∘ g)(x), apply g first, then put its output into f. The order matters: reversing it usually changes the result.
Try a worked example
Mathematics · Try a worked example
Given f(x) = 2x + 1 and g(x) = x², find (f ∘ g)(3). Apply the inner function first.
Show the worked solution
First calculate g(3) = 3² = 9, then f(9) = 2 × 9 + 1 = 19. The answer is 19. Reversing the order gives g(f(3)) = 49, which is a different calculation.
Step by step
The general rule is f(g(x)) = 2x² + 1. Reversing the order gives g(f(x)) = (2x + 1)². Function composition is not generally commutative.
Check your work
Both functions here are polynomials with real-number domains. With other functions, x must be in the inner function’s domain and its output must be in the outer function’s domain. Check denominators and roots before simplifying.
Try it yourself
Try x = −2. Both compositions give 9 at this input: g(−2) = 4 and f(4) = 9; f(−2) = −3 and g(−3) = 9. Equality at one input does not make the two rules identical.