Skip to content
IGCSE·Tuition
Additional Mathematics · Lessons

Form a composite function in the correct order

Two functions can look like one small job, yet swapping their order quietly gives a different answer.

On this page
  1. How do you build a composite function?
  2. Worked example
  3. The mistake to watch for
  4. Check yourself
  5. Where this leads next

A composite function is one function applied to the result of another. In the notation fg(x), the function g acts first and f acts on its output. Additional Mathematics questions ask you to write fg(x) or gf(x) as a single expression, to evaluate one at a value, or to solve an equation such as fg(x) = 49.

This lesson follows finding a range from a restricted domain, because the output of the inner function must be a value the outer function can accept.

How do you build a composite function?

The safest method is to treat the inner function as a bracket and put it in place of x.

  1. Identify the inner function. In fg(x) it is g, the one written next to x.
  2. Write the outer function with a gap where x goes, for example f( ) = 3( ) − 2.
  3. Put the whole of g(x) in the gap, inside brackets.
  4. Expand and simplify.
  5. Check with a number. Pick an easy x, work it step by step, and compare.

Worked example

Given f(x) = 3x − 2 and g(x) = x² + 1, find fg(x) and gf(x), then solve fg(x) = 49.

fg(x), g goes first: fg(x) = f(x² + 1) = 3(x² + 1) − 2 = 3x² + 3 − 2 = 3x² + 1.

gf(x), f goes first: gf(x) = g(3x − 2) = (3x − 2)² + 1 = 9x² − 12x + 4 + 1 = 9x² − 12x + 5.

Check with x = 2. For fg: g(2) = 5, then f(5) = 13, and 3(4) + 1 = 13. For gf: f(2) = 4, then g(4) = 17, and 9(4) − 24 + 5 = 17. Both agree.

Solve fg(x) = 49: 3x² + 1 = 49, so 3x² = 48, so x² = 16, so x = 4 or x = −4.

Check x = −4: g(−4) = 17, then f(17) = 51 − 2 = 49. It works.

The mistake to watch for

A common slip is to apply the functions in the order the letters are written, so fg(x) becomes g first and then f reversed.

Mistaken working: fg(x) = g(f(x)) = (3x − 2)² + 1 = 9x² − 12x + 5.

This is actually gf(x). The student applied f first, which is the wrong way round for fg.

The correction is to read fg(x) as f(g(x)): the function next to x acts first. If the letters are written f then g, the substitution goes g into f. The numerical check at x = 2 would expose the slip straight away, because fg(2) is 13, not 17.

Check yourself

Try these, then open each answer.

1. f(x) = x + 4 and g(x) = 2x. Find fg(x) and gf(x).

Show answer

fg(x) = f(2x) = 2x + 4. gf(x) = g(x + 4) = 2(x + 4) = 2x + 8. So fg(x) = 2x + 4 and gf(x) = 2x + 8. They are different.

2. f(x) = 1/x for x ≠ 0, and g(x) = x − 3. Find fg(x) and gf(x), and state any excluded value for fg.

Show answer

fg(x) = f(x − 3) = 1/(x − 3), with x ≠ 3. gf(x) = g(1/x) = 1/x − 3, with x ≠ 0.

3. f(x) = 2x − 1 and g(x) = x². Solve fg(x) = 17.

Show answer

fg(x) = f(x²) = 2x² − 1. Then 2x² − 1 = 17, so x² = 9, so x = 3 or x = −3. Check x = 3: g(3) = 9, f(9) = 17.

Where this leads next

Composite functions underpin inverses, since f⁻¹ undoes f. Continue with finding an inverse and checking its domain. The function composition and inverse explorer shows fg and gf side by side for any input you choose, and the non-calculator working trainer helps with checking expanded brackets.

If the notation slows you down, a teacher can go through your own working in online one-to-one Additional Mathematics tuition.

Questions people ask

How do I read fg(x)?

Read fg(x) as f of g of x. You apply g to x first, then apply f to the result. The function nearest to x acts first. So fg(x) means substitute g(x) into f, which is the reverse of the order the letters are written in.

Are fg(x) and gf(x) ever equal?

Sometimes, but not in general. For f(x) = x + 2 and g(x) = x + 5 they are equal, because both give x + 7. For most pairs they differ, so you must never assume the order does not matter.

Does a composite function have a domain restriction?

Yes. The inner function must accept the input, and its output must be accepted by the outer function. If f(x) = 1/(x − 2) and g(x) = x + 5, then fg(x) = 1/(x + 3), which excludes x = −3.

Updated:

Your next step

If you know the rule but still swap fg and gf under pressure, a one-to-one teacher can have you talk through each substitution and fix the habit at the moment it happens.

Paid one-hour trial at your assigned teacher’s confirmed rate, starting from RM80. Other fees, schedules and ongoing arrangements are confirmed directly with your teacher after the trial class.

Tuition is arranged with a parent or guardian. Send them this page on WhatsApp and they can enquire for you.

Parent or guardian? Enquire here

9,000+ students helped through our service