HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
Domain, Range, Inverse and Composite Functions
  1. 1Functions, domain, range and the modulus
  2. 2Inverse functions and their graphs
  3. 3Composite functions
  1. Mathematics
  2. /Domain, Range, Inverse and Composite Functions
  3. /Composite functions

Course 21.1·Lesson 3 of 3

Composite functions

A composite function chains two functions, so the output of the first becomes the input of the second. The order matters. You form composites, find when a composite exists and what its domain is, and solve equations that involve them.

about 25 min1 simulation1 practice question
Lesson 3 of 3Show all lessonsHide
Domain, Range, Inverse and Composite Functions
  1. 1Functions, domain, range and the modulus
  2. 2Inverse functions and their graphs
  3. 3Composite functions

Try the code and the simulations beside the lesson.

Chaining two rules

Think of two machines in a row. The first machine is fff and the second is ggg. A number goes into fff, and the result goes into ggg.

A chain of two machines. The input x enters a box labelled f, which does times 2 plus 1. The output of f enters a box labelled g, which does square it and subtract 3. The result is gf of x. Below the chain, the example x equals 2 gives f(2) equals 5 and then g(5) equals 22.

We write this as gf(x)=g(f(x))gf(x) = g(f(x))gf(x)=g(f(x)). The function written nearest to xxx acts first. The composite fg(x)=f(g(x))fg(x) = f(g(x))fg(x)=f(g(x)) does ggg first.

Let f(x)=2x+1f(x) = 2x + 1f(x)=2x+1 and g(x)=x2−3g(x) = x^2 - 3g(x)=x2−3.

  • gf(x)=g(2x+1)=(2x+1)2−3=4x2+4x−2gf(x) = g(2x + 1) = (2x + 1)^2 - 3 = 4x^2 + 4x - 2gf(x)=g(2x+1)=(2x+1)2−3=4x2+4x−2.
  • fg(x)=f(x2−3)=2(x2−3)+1=2x2−5fg(x) = f(x^2 - 3) = 2(x^2 - 3) + 1 = 2x^2 - 5fg(x)=f(x2−3)=2(x2−3)+1=2x2−5.

These are different, so fgfgfg may not be the same as gfgfgf. The order of the functions is important. A function applied to itself is written f2(x)=f(f(x))f^2(x) = f(f(x))f2(x)=f(f(x)).

When does a composite exist?

The composite gf(x)gf(x)gf(x) needs the output of fff to be a valid input for ggg. In terms of sets:

  • the domain of gfgfgf is inside the domain of fff;
  • the range of gfgfgf is inside the range of ggg.

Suppose f(x)=x−5f(x) = x - 5f(x)=x−5 for all real xxx, and g(x)=xg(x) = \sqrt{x}g(x)=x​ for x≥0x \ge 0x≥0. Then gf(x)=x−5gf(x) = \sqrt{x - 5}gf(x)=x−5​ needs x−5≥0x - 5 \ge 0x−5≥0. So the domain of fff must be restricted to x≥5x \ge 5x≥5 for gfgfgf to exist. Without the restriction, gf(1)gf(1)gf(1) would need −4\sqrt{-4}−4​, which is not a real number.

Solving with composites

To solve gf(x)=kgf(x) = kgf(x)=k, first write gf(x)gf(x)gf(x) as one expression in xxx, then solve. Alternatively, undo the functions in the opposite order.

For f(x)=2x+1f(x) = 2x + 1f(x)=2x+1 and g(x)=x2−3g(x) = x^2 - 3g(x)=x2−3, solve gf(x)=13gf(x) = 13gf(x)=13. Then (2x+1)2−3=13(2x + 1)^2 - 3 = 13(2x+1)2−3=13, so (2x+1)2=16(2x + 1)^2 = 16(2x+1)2=16 and 2x+1=42x + 1 = 42x+1=4 or 2x+1=−42x + 1 = -42x+1=−4. That gives x=1.5x = 1.5x=1.5 or x=−2.5x = -2.5x=−2.5. Check each in the original: f(1.5)=4f(1.5) = 4f(1.5)=4 and g(4)=13g(4) = 13g(4)=13.

To solve fg(x)=gf(x)fg(x) = gf(x)fg(x)=gf(x), form both expressions and set them equal.

To undo a composite, undo the last function first: (gf)−1(x)=f−1(g−1(x))(gf)^{-1}(x) = f^{-1}(g^{-1}(x))(gf)−1(x)=f−1(g−1(x)). We write it as f−1g−1(x)f^{-1}g^{-1}(x)f−1g−1(x).

Practise with new numbers

Try it in Python

The program defines f(x)=2x−8f(x) = 2x - 8f(x)=2x−8 and g(x)=xg(x) = \sqrt{x}g(x)=x​ and forms gfgfgf. Python gives an error where gfgfgf does not exist.

Read it first. Then run it. For which inputs does gfgfgf work?

1. Find the smallest whole number input for which gf works.

2. Change f to 3 * x - 12. How does the smallest input change?

Common mistakes

  • Doing the functions in the wrong order. In gf(x)gf(x)gf(x), fff acts first.
  • Assuming fg=gffg = gffg=gf. They are usually different.
  • Reading f2(x)f^2(x)f2(x) as (f(x))2(f(x))^2(f(x))2.
  • Ignoring the domain. If the output of the first function is not allowed in the second, the composite does not exist there.
  • Losing a solution. Squaring leaves two cases, one positive and one negative.

Remember these

  • gf(x)=g(f(x))gf(x) = g(f(x))gf(x)=g(f(x)). The function next to xxx acts first.
  • gfgfgf and fgfgfg are usually different.
  • Domain of gfgfgf is inside the domain of fff. Range of gfgfgf is inside the range of ggg.
  • To undo gfgfgf: (gf)−1=f−1g−1(gf)^{-1} = f^{-1}g^{-1}(gf)−1=f−1g−1.

Check yourself

Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.

  1. f(x)=x+4f(x) = x + 4f(x)=x+4 and g(x)=3xg(x) = 3xg(x)=3x. Find gf(x)gf(x)gf(x) and fg(x)fg(x)fg(x).
  1. f(x)=5−xf(x) = 5 - xf(x)=5−x and g(x)=x2g(x) = x^2g(x)=x2. Find gf(2)gf(2)gf(2).
  1. f(x)=2x−6f(x) = 2x - 6f(x)=2x−6 for all real xxx and g(x)=xg(x) = \sqrt{x}g(x)=x​ for x≥0x \ge 0x≥0. State the largest domain of gfgfgf.
  1. f(x)=x+2f(x) = x + 2f(x)=x+2 and g(x)=x2g(x) = x^2g(x)=x2. Solve gf(x)=25gf(x) = 25gf(x)=25.
  1. f(x)=3xf(x) = 3xf(x)=3x and g(x)=x−4g(x) = x - 4g(x)=x−4. Find (gf)−1(x)(gf)^{-1}(x)(gf)−1(x).

References

  • Cambridge International, IGCSE Additional Mathematics 0606 syllabus (2025, 2026 and 2027), unit 1 Functions.

Enroll free in Domain, Range, Inverse and Composite Functions

Every lesson is open to read. Enrolling also lets you:

  • Mark lessons done and carry on where you stopped.
  • Take the tests of this lesson and its course.
  • Count the course towards the certificate for its chapter.
No payment. You can leave at any time.

Problems (3)

Two machines are placed in a row, and then the order of the machines is swapped to see whether the…Easy · High School (9–10) · by StemPy Lab
Two chains of the same two machines are built in opposite orders, and Lena looks for the one input…Medium · High School (9–10) · by StemPy Lab
Two functions are chained, but each has its own list of allowed inputs, so the chain may not exist…Hard · High School (9–10) · by StemPy Lab
That was the last lessonBack to the course: take the test
← Domain, Range, Inverse and Composite Functions
← Inverse functions and their graphsNext →

Discussion (0)

Log in to join the discussion.

Loading…

1 Python program
5 questions to check yourself

This lesson is free to read. Enroll free to keep your place and take the tests.

Python Labs (1)

Inverse and composite checksPython Lab · by StemPy Lab

Question Sets (1)

Domain, Range and Inverses: Check Your Understanding10 questions · by StemPy Lab

Notes (1)

Domain, Range, Inverse and Composite Functions: Quick RevisionNote · by StemPy Lab