Compose two functions
The composition (f∘g)(x) means f(g(x)): do g first, then f. In general (f∘g)(x) and (g∘f)(x) are different.
This is original written practice with invented functions. Each result is checked by putting in a number and working in two steps.
Substitute inside out, then test with a number
- For f(g(x)), put g(x) into f in place of x. For g(f(x)), put f(x) into g.
- Simplify to get a formula.
- Check: choose x, work out the inner function first, then the outer. The result must match the formula.
f(x) = x + 2 and g(x) = 3x
(f∘g)(x) = 3x + 2 and (g∘f)(x) = 3(x + 2) = 3x + 6.
Check: At x = 1: g(1) = 3, then f(3) = 5, and 3 + 2 = 5. Also f(1) = 3, then g(3) = 9, and 3 + 6 = 9.
f(x) = x² and g(x) = x − 1
(f∘g)(x) = (x − 1)² and (g∘f)(x) = x² − 1.
Check: At x = 3: g(3) = 2, then f(2) = 4, and (3 − 1)² = 4. Also f(3) = 9, then g(9) = 8, and 3² − 1 = 8.
f(x) = 2x + 1 and g(x) = x²
(f∘g)(x) = 2x² + 1 and (g∘f)(x) = (2x + 1)².
Check: At x = 2: g(2) = 4, then f(4) = 9, and 2 × 4 + 1 = 9. Also f(2) = 5, then g(5) = 25, and 5² = 25.
Counterexample: doing the functions in the wrong order
A student finds f(g(x)) for f(x) = x + 2 and g(x) = 3x as 3(x + 2) = 3x + 6.
The check fails. At x = 1, g(1) = 3 and f(3) = 5, but 3x + 6 gives 9. That is g(f(x)). For f(g(x)), g goes first, giving 3x + 2.
Try one yourself
For f(x) = 3x and g(x) = x + 4, find f(g(x)) and g(f(x)) and check at x = 2.
Show the worked self-check
f(g(x)) = 3(x + 4) = 3x + 12, and g(f(x)) = 3x + 4. At x = 2: g(2) = 6, f(6) = 18, and 3 × 2 + 12 = 18. Also f(2) = 6, g(6) = 10, and 3 × 2 + 4 = 10.
Scope and limits
- The page covers the composition of two simple functions defined for all real x.
- It does not cover domains and ranges of compositions or inverse functions.
- The functions are invented, and the questions are practice, not an exam key.
- Every composition is checked with a number in two steps.
Common questions
In the composition f∘g, which function is applied first?
The function g acts first, then f. Read it from the right, so (f∘g)(x) means f(g(x)).
Can f∘g and g∘f ever be equal for a pair of functions?
Sometimes, for special pairs, but not in general. The three examples on this page each give two different formulas.
What does f∘f mean in a composition of functions?
It means f applied twice, that is f(f(x)). For f(x) = x + 2 it gives x + 4.
Must the output of g lie in the domain of f for f∘g to exist?
Yes. The numbers that g produces must be allowed as inputs to f, otherwise f(g(x)) is not defined for those values of x.
Sources and scope
Sources checked . They support the composition of functions. The numbers, worked examples and self-check above are original EZT practice.
- NCERT Class 12 Mathematics: Relations and Functions, for the composition of functions.
Read the Class 12 relations and functions chapterBrowse tuition and practice pages