A composite function applies one function to the output of another. In fg(x), you apply g first and then f, so fg(x) = f(g(x)).
This lesson is part of SPM Additional Mathematics functions. If function notation itself still feels slippery, start with reading function notation, domain and range.
Which function goes first in fg(x)?
The function closest to x goes first. Rewrite fg(x) as f(g(x)) before doing anything else, then work from the inside out.
Think of it like getting dressed: in “shoes(socks(feet))” the socks go on first even though “shoes” is written first.
Worked example: the same pair, two orders
Take f(x) = 2x + 3 and g(x) = x².
Finding fg(x). Rewrite as f(g(x)). Replace every x in f with g(x):
f(g(x)) = 2(x²) + 3 = 2x² + 3
Finding gf(x). Rewrite as g(f(x)). Replace every x in g with f(x):
g(f(x)) = (2x + 3)² = 4x² + 12x + 9
The two answers are different functions. Check with a number: when x = 2, fg(2) = 2(4) + 3 = 11, but gf(2) = (7)² = 49.
The mistake that costs marks
The common slip is to square first and double second for gf(x), writing 2x² + 3 again. The working looks tidy, so the error is hard to spot when checking.
| Step | Wrong | Right |
|---|---|---|
| Rewrite gf(x) | (skipped) | g(f(x)) |
| Inner function | g acts first | f acts first: 2x + 3 |
| Outer function | f applied to x² | g squares the whole output |
| Result | 2x² + 3 | 4x² + 12x + 9 |
The fix is mechanical. Always write the nested form, then substitute the whole inner expression, with brackets, into the outer rule.
Finding an unknown function from a composite
SPM questions often give you the composite and ask for one of the pieces. There are two cases, and they need different methods.
Case 1: the unknown is on the inside. Given f(x) = 2x − 1 and fg(x) = 6x + 5, find g(x).
- Write f(g(x)) = 2g(x) − 1.
- Set it equal to the composite: 2g(x) − 1 = 6x + 5.
- Solve for g(x): 2g(x) = 6x + 6, so g(x) = 3x + 3.
- Check: f(3x + 3) = 2(3x + 3) − 1 = 6x + 5. It matches.
Case 2: the unknown is on the outside. Given g(x) = x + 2 and fg(x) = 3x + 1, find f(x).
- Write f(x + 2) = 3x + 1.
- Let u = x + 2, so x = u − 2.
- Substitute: f(u) = 3(u − 2) + 1 = 3u − 5.
- Rename the variable: f(x) = 3x − 5. Check: f(x + 2) = 3(x + 2) − 5 = 3x + 1.
Case 2 is where most students get stuck, because it needs the substitution step. If you want to test your own pairs, the composite and inverse function explorer shows both orders side by side.
Check yourself
Given f(x) = 3x − 1 and g(x) = x + 4, find fg(x), then solve fg(x) = 20.
Answer
fg(x) = f(g(x)) = 3(x + 4) − 1 = 3x + 11.
Solve 3x + 11 = 20, so 3x = 9 and x = 3.
Check by working inside out: g(3) = 7, then f(7) = 3(7) − 1 = 20.
What to study next
Inverse functions build directly on this lesson, because f⁻¹f(x) = x is a composite. Continue with finding inverse functions with domain restrictions, then test the whole chapter with the functions practice set.
If you want a teacher to work through composite and inverse questions with you, see online one-to-one Additional Mathematics tuition.