Skip to content
IGCSE·Tuition
Mathematics · Lessons

Trace an input through a composite function

Two functions side by side can feel like a puzzle about which one goes first.

On this page
  1. How do you read fg(x)?
  2. Two ways to work it
  3. Worked example
  4. The mistake to watch for
  5. Check yourself
  6. Where this leads next

A composite function applies one function and then feeds its output into another. fg(x) means “do g first, then f”, because g is the one sitting next to x.

This is the second lesson in functions and mappings. It builds directly on evaluating a function with negative inputs, because the output of the first function may well be negative.

How do you read fg(x)?

Think of two machines joined in a line. The input x enters g.

Whatever comes out of g goes into f. What comes out of f is the answer.

Write it as f(g(x)). The innermost bracket is done first. That habit, working from the inside out, is all you need.

Two ways to work it

  1. With a number: find the inner result, then use it as the next input.
  2. With an expression: replace every x in the outer function by the whole inner function, then simplify.

Use the number method when the question supplies a number. Use the expression method when it asks for fg(x) itself.

Worked example

Let f(x) = 3x − 2 and g(x) = x² + 1. Find fg(2), gf(2), fg(x) and gf(x).

fg(2): g(2) = 4 + 1 = 5. Then f(5) = 15 − 2 = 13.

gf(2): f(2) = 6 − 2 = 4. Then g(4) = 16 + 1 = 17.

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

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

Check: substitute x = 2 into both expressions. 3(4) + 1 = 13 matches fg(2). 9(4) − 24 + 5 = 36 − 24 + 5 = 17 matches gf(2). Both routes agree, so the expressions are very likely right.

The mistake to watch for

The usual slip is to apply the functions in the order they are written, reading left to right.

Mistaken working: fg(2) = f(2) then g: f(2) = 4, g(4) = 17

The student started with f because it is written first. That is gf(2), not fg(2).

The correct order is g first. Always ask “which function is next to x?” and start there. A second slip is squaring a bracket as if it were two separate terms, writing (3x − 2)² = 9x² + 4 and forgetting the middle term −12x.

Check yourself

Try these on paper, then open each answer.

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

Show answer

g(3) = 6, then f(6) = 6 + 4 = 10.

2. Let f(x) = x² and g(x) = x − 1. Find fg(−2) and gf(−2).

Show answer

fg(−2): g(−2) = −3, then f(−3) = 9. gf(−2): f(−2) = 4, then g(4) = 3.

3. Let f(x) = 2x − 3 and g(x) = x + 5. Find fg(x) and gf(x) as simplified expressions.

Show answer

fg(x) = 2(x + 5) − 3 = 2x + 10 − 3 = 2x + 7. gf(x) = (2x − 3) + 5 = 2x + 2. Check with x = 1: fg(1) = f(6) = 9 and 2 + 7 = 9. gf(1) = g(−1) = 4 and 2 + 2 = 4.

Where this leads next

Composition sets up reversing a one-to-one mapping, because an inverse function undoes the machine in the opposite order. The function composition and inverse explorer shows fg and gf side by side, which is useful for seeing that the order changes the answer. You can also practise each step in the non-calculator working trainer.

If you can do each substitution but still pick the wrong order under pressure, our teachers can help you fix that in online one-to-one Mathematics tuition.

Questions people ask

In fg(x), which function is applied first?

The function written next to x is applied first. So fg(x) means f(g(x)): do g to x, then do f to that result. It reads from right to left, which feels backwards at first, but it matches the brackets in f(g(x)), where g sits inside.

Is fg(x) always the same as gf(x)?

No, usually they differ. With f(x) = 2x + 1 and g(x) = x², fg(3) = f(9) = 19 but gf(3) = g(7) = 49. Only for special pairs of functions do the two orders give the same result, so never assume they match.

Should I work out a composite as an expression or a number?

Follow the question. If it gives a number such as fg(2), substitute step by step and get a number. If it asks for fg(x), substitute the whole of g(x) into f and simplify. Checking one number in both methods is a good way to catch slips.

Does fg(x) mean f multiplied by g?

No. In function notation, fg(x) does not mean f × g × x. It means 'apply g, then apply f'. Multiplying two functions is written differently, for example f(x) × g(x), and the syllabus questions in this topic are about composition.

Updated:

Your next step

If fg and gf still swap places in your working, a one-to-one teacher can give you a short routine for the order and then test it on questions you have not seen.

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