Uni-Sine
MathematicsAlgebra

Composite functions

A composite function is two functions applied one after the other: the output of the first becomes the input of the second. fg(x) means apply g first, then f, so fg(x) = f(g(x)). For example, if f(x) = 2x + 7 and g(x) = x², then fg(3) = f(9) = 25. Composite functions come up in GCSE Maths Higher and A-level Maths.

What is a composite function?

Think of each function as a machine. Put a number into g, take what comes out, and put that into f. The two machines together make a new function, the composite function fg.

3gf925
fg(3): g squares 3 to give 9, then f doubles 9 and adds 7 to give 25

The notation is read from the inside out. In fg(x) the function nearest the x, which is g, acts first. You may also see it written f(g(x)), or (f ∘ g)(x) in American and university books, which all mean the same thing.

How to find a composite function

Use f(x) = 2x + 7 and g(x) = x² for the examples in this section.

Example 1: a number in a composite function

Find fg(3) and gf(3).

  • fg(3): do g first. g(3) = 3² = 9. Then f(9) = 2 × 9 + 7 = 25.
  • gf(3): do f first. f(3) = 2 × 3 + 7 = 13. Then g(13) = 13² = 169.

Same functions, same input, different answers. The order matters: fg and gf are usually different functions.

Example 2: finding fg(x) and gf(x)

To find fg(x), write out f, and wherever it has an x, put the whole of g(x) in its place, in brackets:

fg(x) = f(x^2) = 2x^2 + 7

For gf(x), put f(x) into g:

gf(x) = g(2x + 7) = (2x + 7)^2 = 4x^2 + 28x + 49

Check with Example 1: 4 × 9 + 28 × 3 + 49 = 169. It matches.

Example 3: a function with itself

ff(x) means apply f twice, and it is sometimes written f²(x):

ff(x) = f(2x + 7) = 2(2x + 7) + 7 = 4x + 21

Check your understanding.

practice
Pick an answer, then check it.
f(x) = x + 4 and g(x) = 3x. What is gf(2)?

Solving equations with composite functions

Example 4: fg(x) = 39

With f(x) = 2x + 7 and g(x) = x², solve fg(x) = 39. Find the composite first, then solve:

2x^2 + 7 = 39 \Rightarrow x^2 = 16 \Rightarrow x = 4 \text{ or } x = -4

Example 5: when fg(x) = gf(x)

Solve fg(x) = gf(x) for the same functions. Set the two expressions equal:

2x^2 + 7 = 4x^2 + 28x + 49 \Rightarrow x^2 + 14x + 21 = 0

This doesn't factorise, so use the quadratic formula: x = −7 ± √28 = −7 ± 2√7, which is x ≈ −1.71 or x ≈ −12.29.

Domain and range of composite functions (A-level)

At A-level, functions come with a domain (the inputs allowed) and a range (the outputs it can give). For fg to make sense, every output of g must be an allowed input of f. In other words, the range of g must fit inside the domain of f.

Example 6: a square root

Let p(x) = √x with domain x ≥ 0, and q(x) = x − 6 for all real x.

  • pq(x) = √(x − 6). You can only take the square root of a number that is not negative, so x − 6 ≥ 0. The domain of pq is x ≥ 6, and its range is pq(x) ≥ 0.
  • qp(x) = √x − 6. Here x only has to suit p, so the domain is x ≥ 0, and the range is qp(x) ≥ −6.

To find the range of a composite, work out the range of the inner function first, then see what the outer function does to those values.

Breaking a function into a composite

Sometimes you need to go the other way and spot the two functions inside one. For example, h(x) = (4x + 1)³ is fg(x) with g(x) = 4x + 1 on the inside and f(x) = x³ on the outside. Seeing functions this way is the key to the chain rule in calculus, which differentiates a composite function.

Composite functions and inverse functions

The inverse function f⁻¹ undoes f. Composing a function with its inverse gives back the input: ff⁻¹(x) = f⁻¹f(x) = x. For f(x) = 2x + 7, the inverse is f⁻¹(x) = (x − 7) ÷ 2, and:

ff^{-1}(x) = 2 \times \frac{x - 7}{2} + 7 = x

To undo a composite fg, undo the outer function first: (fg)⁻¹ = g⁻¹f⁻¹.

Common mistakes

  • Doing the functions in the wrong order. In fg(x), g goes first.
  • Multiplying the functions. fg(x) is not f(x) × g(x).
  • Forgetting brackets. gf(x) = (2x + 7)², not 2x + 7² or 2x² + 7.
  • Expanding badly. (2x + 7)² = 4x² + 28x + 49, not 4x² + 49.
  • Mixing up ff(x) and [f(x)]². ff(x) applies f twice; [f(x)]² squares the output.
  • Ignoring the domain at A-level, for example taking the square root of a negative number.

Practice questions

Use f(x) = 3x − 2 and g(x) = x² + 1.

  1. Find fg(2).
  2. Find gf(2).
  3. Find fg(x).
  4. Find gf(x), and simplify.
  5. Solve fg(x) = 25.

Answers: 1) g(2) = 5, f(5) = 13. 2) f(2) = 4, g(4) = 17. 3) fg(x) = 3(x² + 1) − 2 = 3x² + 1. 4) gf(x) = (3x − 2)² + 1 = 9x² − 12x + 5. 5) 3x² + 1 = 25 gives x² = 8, so x = ±2√2.

Practise with a short timed paper

Functions come up in GCSE Maths Higher and in A-level Maths. The daily A-level Maths: Algebra & Functions and GCSE Maths Higher papers are short timed papers of 8 questions, with a new one every day.

Common questions

What is a composite function?
A function made by applying one function and then another to the result. fg(x) = f(g(x)) means apply g first, then f.
How do you find fg(x)?
Write out f(x) and replace every x with the whole of g(x), in brackets. Then simplify.
Is fg(x) the same as gf(x)?
Usually not. The order matters: fg applies g first, gf applies f first.
What does ff(x) mean?
Applying f twice: f(f(x)). It is not the same as f(x) squared.
Are composite functions on GCSE Foundation?
No. For AQA and Edexcel, composite functions are Higher tier only.
What is the domain of a composite function?
The inputs of the inner function whose outputs are allowed inputs of the outer function.

Revision cards

Say the answer first, then flip the card to check it.

Where to go next

  • Test it

    A-level Maths: Algebra & Functions

    A new exam-style paper every day, with instant marking and a mark scheme

    Start today's paper
  • Test it

    GCSE Maths Higher

    A new exam-style paper every day, with instant marking and a mark scheme

    Start today's paper
Read next
Maths · CoursesGraphing functions course: lines, curves and transformationsAn interactive graphing functions course in 31 short sections: linear, quadratic, cubic, rational, exponential and root graphs, and transformations.