Skip to content
SPM Tuition
Additional Mathematics · Functions

Composite functions in the right order

You can find f(x) and g(x) on their own, but fg(x) keeps coming out as gf(x).

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).

  1. Write f(g(x)) = 2g(x) − 1.
  2. Set it equal to the composite: 2g(x) − 1 = 6x + 5.
  3. Solve for g(x): 2g(x) = 6x + 6, so g(x) = 3x + 3.
  4. 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).

  1. Write f(x + 2) = 3x + 1.
  2. Let u = x + 2, so x = u − 2.
  3. Substitute: f(u) = 3(u − 2) + 1 = 3u − 5.
  4. 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.

Common questions

Is fg(x) the same as f(x) times g(x)?

No. fg(x) means apply g first, then apply f to the result. Multiplying the two functions is a different operation and is written f(x) × g(x). SPM Add Maths questions on composite functions always mean the first.

Why do I apply g first when f is written first?

Read fg(x) as f(g(x)). The function nearest to x acts first, just like brackets are worked from the inside. The notation is written in the order you would read it aloud, not the order of calculation.

How do I find g(x) if I am given f(x) and fg(x)?

Write f(g(x)) using the rule for f with g(x) in place of x, set it equal to the given fg(x), then solve for g(x) as if it were an unknown. Always substitute back to check that f of your answer gives the original fg(x).

Can fg(x) ever equal gf(x)?

It can for particular pairs, for example when one function is the identity, or at specific values of x. In general the two are different, so never assume they are equal without working both out.

If composite questions still flip in your head under time pressure, one-to-one Add Maths lessons let a teacher watch where the order goes wrong and fix it on your own questions.

  • Online one-to-one lessons for your child with an experienced teacher.
  • Your first class is a one-hour trial, from RM50. The fee is agreed before you book.
  • Happy with the teacher? Continue with lessons of about 1.5 hours. If not, ask for another teacher.