IB Maths AI HL Functions Toolkit Paper 1 & 2 f(g(x)), domain, range ~8 min read

Composite Functions

A composite function chains two functions together — the output of one becomes the input of the next. (fg)(x) = f(g(x)) means “do g first, then f“. Order matters: swapping it usually gives a different function.

📘 What you need to know

How composition works

Think of each function as a machine. In (fg)(x), the input x is fed into the inner machine g first, producing g(x); that output then enters f, giving f(g(x)). To evaluate at a number, work inside-out: compute g(x), then apply f to that result. To find an algebraic expression, substitute the inner function’s formula wherever x appears in the outer formula, then simplify.

Order matters — the same x can give two different outputs (f ∘ g)(x) = f(g(x)) — g first x g g(x) f f(g(x)) example: p(x) = 3x − 5, q(x) = x² + 1 x = 2 → q(2) = 5 → p(5) = 10 (p ∘ q)(2) = 10 (g ∘ f)(x) = g(f(x)) — f first x f f(x) g g(f(x)) same p and q, opposite order: x = 2 → p(2) = 1 → q(1) = 2 (q ∘ p)(2) = 2
The same input x = 2 gives different outputs depending on which function acts first — (pq) and (qp) are different functions.
Composite function at a glance (fg)(x) = f(g(x)) apply inner first · (fg) ≠ (gf) in general · (ff) ≠ [f(x)]2

Domain & range of a composite

For (fg)(x) to be defined at x, two things must hold: x must be in the domain of g, and g(x) must be in the domain of f. Start with g‘s domain, find the range of g on that domain, then intersect that range with f‘s domain. If the intersection is smaller, work backwards through g to restrict the original domain. The range of (fg) is then whatever values come out when you push the restricted domain through both functions in order.

Sketching helps. On the GDC, graph f(g(x)) directly — the visible portion of the curve immediately shows you the domain and range.

🧭 Recipe — composite functions

  1. Identify which function is inner: the one closest to x in the notation.
  2. Apply inner first: compute g(x) numerically, or substitute g‘s formula wherever x appears in f.
  3. Apply outer: feed the result into f, then simplify.
  4. Domain: x must be in g‘s domain AND g(x) must lie in f‘s domain — restrict if needed.
  5. Range: push the restricted domain through g then through f; the resulting interval is the range of the composite.

Worked examples

WE 1

Order matters at a number

Let p(x) = 3x − 5 and q(x) = x2 + 1. Find (a) (pq)(2) and (b) (qp)(2). What do you notice?

(a) inner q first q(2) = 2² + 1 = 5 p(5) = 3(5) − 5 = 10 (p ∘ q)(2) = 10 (b) inner p first p(2) = 3(2) − 5 = 1 q(1) = 1² + 1 = 2 (q ∘ p)(2) = 2 order matters: 10 ≠ 2.
WE 2

Composite expressions both ways

Let h(x) = 2x − 3 and k(x) = x2 + 4. Find an expression for (a) (hk)(x) and (b) (kh)(x).

(a) substitute k inside h (h ∘ k)(x) = h(x² + 4) = 2(x² + 4) − 3 = 2x² + 8 − 3 (h ∘ k)(x) = 2x² + 5 (b) substitute h inside k (k ∘ h)(x) = k(2x − 3) = (2x − 3)² + 4 = 4x² − 12x + 9 + 4 (k ∘ h)(x) = 4x² − 12x + 13
WE 3

(f ∘ f)(x) is not [f(x)]2

Let f(x) = 2x + 1. (a) Find (ff)(x). (b) Find [f(x)]2. (c) Compare.

(a) compose f with itself (f ∘ f)(x) = f(2x + 1) = 2(2x + 1) + 1 = 4x + 2 + 1 (f ∘ f)(x) = 4x + 3 (b) square the output [f(x)]² = (2x + 1)² [f(x)]² = 4x² + 4x + 1 (c) compare linear (4x + 3) vs quadratic (4x² + 4x + 1) — very different functions.
WE 4

Domain and range with restrictions

Let f(x) = 3x + 4 with −8 ≤ x ≤ 8, and g(x) = √x with 0 ≤ x ≤ 81. Find the domain and range of (fg)(x).

expression first (f ∘ g)(x) = 3√x + 4 g’s domain: 0 ≤ x ≤ 81 g outputs: 0 ≤ √x ≤ 9 f needs input in [−8, 8] intersect [0, 9] ∩ [−8, 8] = [0, 8] need 0 ≤ √x ≤ 8 square: 0 ≤ x ≤ 64 domain: 0 ≤ x ≤ 64 range: push through both at x = 0: 3(0) + 4 = 4 at x = 64: 3(8) + 4 = 28 range: 4 ≤ (f ∘ g)(x) ≤ 28
WE 5

Composite of rational functions

Let f(x) = 1x − 3 and g(x) = 2x + 5. (a) Find (fg)(x) and state the value of x for which it is undefined. (b) Find (gf)(x).

(a) sub g into f (f ∘ g)(x) = 1/((2x + 5) − 3) = 1/(2x + 2) = 1/[2(x + 1)] (f ∘ g)(x) = 12x + 2 denominator zero when 2x + 2 = 0 ⇒ x = −1 undefined at x = −1 (b) sub f into g (g ∘ f)(x) = 2·(1/(x − 3)) + 5 = (2 + 5(x − 3))/(x − 3) (g ∘ f)(x) = 5x − 13x − 3 (g ∘ f) is undefined at x = 3.
WE 6

Applied: rocket pressure

A rocket’s altitude above the launch site after t minutes is h(t) = 2t2 + 5 km. The atmospheric pressure at altitude h km is P(h) = 100e−0.12h kPa. (a) Find (Ph)(t). (b) Find the pressure 3 minutes after launch (2 d.p.).

(a) sub h into P (P ∘ h)(t) = 100 e⁻⁰·¹²(2t² + 5) (P ∘ h)(t) = 100 e⁻⁰·²⁴t² ⁻ ⁰·⁶ (b) sub t = 3 exponent: −0.24(9) − 0.6 = −2.76 P = 100 e⁻²·⁷⁶ ≈ 100(0.06329) P ≈ 6.33 kPa at altitude h(3) = 23 km the air is very thin.

💡 Top tips

âš  Common mistakes

Next up: Inverse Functions — functions that undo each other, including how to find them, when they exist, and how restricting the domain rescues many-to-one functions.

Need help with AI HL Composite Functions?

Get 1-on-1 help from an IB examiner who knows exactly what Paper 1 & 2 are looking for.

Book Free Session →