1.02PureCore

Composite Functions

A thermostat reads a temperature, converts it to a voltage, and the voltage sets a fan speed. Each step is a function; the whole chain is a composite function\textbf{composite function}. In notation, fg(x)\mathrm{fg}(x) means "apply g\mathrm{g} first, then f\mathrm{f}" — and the order is the thing students most often get backwards.

35 min Functions

The big picture

Composition is how complicated functions are built from simple ones, and recognising the pieces is a skill you will use constantly. The chain rule in differentiation is nothing more than a rule for differentiating composites; integration by substitution undoes one; and graph transformations like f(2x)\mathrm{f}(2x) or f(x)+3\mathrm{f}(x) + 3 are compositions with very simple functions. Two technical points make or break exam answers: fg\mathrm{fg} is evaluated from right to left, and the composite only exists where the range of the inner function lies inside the domain of the outer one.

What you'll be able to do

  • Evaluate composite functions fg(x)\mathrm{fg}(x) numerically and algebraically
  • Recognise that fg\mathrm{fg} and gf\mathrm{gf} are usually different
  • Determine the domain and range of a composite function
  • Solve equations involving composite functions and decompose functions into composites
1

Reading and evaluating fg

fg(x)\mathrm{fg}(x) means f(g(x))\mathrm{f}\big(\mathrm{g}(x)\big): work out g(x)\mathrm{g}(x) first, then use that result as the input to f\mathrm{f}. The function written nearest xx acts first.

Some texts write f∘g\mathrm{f} \circ \mathrm{g}; OCR generally writes fg\mathrm{fg}. Repeated application, ff(x)\mathrm{ff}(x), is often written f2(x)\mathrm{f}^{2}(x) — which does not\textit{not} mean (f(x))2\big(\mathrm{f}(x)\big)^{2}.

Numerically, evaluate inside out. With f(x)=2x+1\mathrm{f}(x) = 2x + 1 and g(x)=x2\mathrm{g}(x) = x^{2}: fg(3)=f(9)=19\mathrm{fg}(3) = \mathrm{f}(9) = 19, while gf(3)=g(7)=49\mathrm{gf}(3) = \mathrm{g}(7) = 49.

fg(x)=f(g(x))\mathrm{fg}(x) = \mathrm{f}\big(\mathrm{g}(x)\big)
Apply g first, then f.
Why this works

Composition is not commutative. Putting socks on then shoes differs from shoes then socks, and fg\mathrm{fg} differs from gf\mathrm{gf} for almost every pair of functions you will meet.

2

Algebraic composites

To find fg(x)\mathrm{fg}(x) as an expression, substitute the whole of g(x)\mathrm{g}(x), in brackets, wherever xx appears in f\mathrm{f}.

With f(x)=3x−1\mathrm{f}(x) = \dfrac{3}{x - 1} and g(x)=x2+2\mathrm{g}(x) = x^{2} + 2: fg(x)=3(x2+2)−1=3x2+1\mathrm{fg}(x) = \dfrac{3}{(x^{2} + 2) - 1} = \dfrac{3}{x^{2} + 1}, and gf(x)=(3x−1)2+2\mathrm{gf}(x) = \left(\dfrac{3}{x-1}\right)^{2} + 2.

Example 1Given f(x)=x2−3\mathrm{f}(x) = x^{2} - 3 and g(x)=2x+5\mathrm{g}(x) = 2x + 5, solve fg(x)=46\mathrm{fg}(x) = 46.
1fg(x)=(2x+5)2−3\mathrm{fg}(x) = (2x + 5)^{2} - 3.
2Set equal to 4646: (2x+5)2=49(2x + 5)^{2} = 49.
3So 2x+5=72x + 5 = 7 or 2x+5=−72x + 5 = -7.
Answerx=1x = 1 or x=−6x = -6

Tip — When the composite contains a perfect square, take square roots rather than expanding — and remember the negative root.

3

Domain and range of a composite

For fg\mathrm{fg} to exist, every output of g\mathrm{g} must be an acceptable input to f\mathrm{f}. In other words, the range of g\textbf{range of g} must lie within the domain of f\textbf{domain of f}.

The domain of fg\mathrm{fg} is the domain of g\mathrm{g} (restricted further if necessary). To find the range of fg\mathrm{fg}, take the range of g\mathrm{g} and ask what f\mathrm{f} does to that set.

Example 1g(x)=x2+1\mathrm{g}(x) = x^{2} + 1 for x∈Rx \in \mathbb{R} and f(x)=ln⁡x\mathrm{f}(x) = \ln x for x>0x > 0. Explain why fg\mathrm{fg} exists and find its range.
1The range of g\mathrm{g} is g(x)≥1\mathrm{g}(x) \ge 1.
2Every value ≥1\ge 1 is positive, so it lies in the domain of f\mathrm{f}; hence fg\mathrm{fg} exists.
3ln⁡\ln is increasing, so on inputs ≥1\ge 1 it takes values ≥ln⁡1=0\ge \ln 1 = 0.
Answerfg(x)=ln⁡(x2+1)\mathrm{fg}(x) = \ln(x^{2} + 1) with range fg(x)≥0\mathrm{fg}(x) \ge 0.
Example 2With the same functions, explain why gf\mathrm{gf} cannot have domain R\mathbb{R}.
1gf(x)=(ln⁡x)2+1\mathrm{gf}(x) = (\ln x)^{2} + 1 requires ln⁡x\ln x to be defined.
2That needs x>0x > 0.
AnswerThe domain of gf\mathrm{gf} is the domain of f\mathrm{f}, x>0x > 0.
Why this works

Think of the range of the inner function as the only doorway into the outer function. The composite range is whatever the outer function produces from that doorway — often much smaller than the outer function’s full range.

4

Decomposing a function

Going the other way — spotting how a function is built — is just as important. h(x)=3x−2\mathrm{h}(x) = \sqrt{3x - 2} is fg(x)\mathrm{fg}(x) with g(x)=3x−2\mathrm{g}(x) = 3x - 2 (inside) and f(x)=x\mathrm{f}(x) = \sqrt{x} (outside).

There is usually more than one valid decomposition. The natural one takes the innermost operation as g\mathrm{g} and the last operation you would press on a calculator as f\mathrm{f}.

This is precisely the recognition step for the chain rule: ddx3x−2\dfrac{\mathrm{d}}{\mathrm{d}x}\sqrt{3x-2} differentiates the outer square root and multiplies by the derivative of the inner 3x−23x - 2.

Example 1Express h(x)=1(x+4)3\mathrm{h}(x) = \dfrac{1}{(x+4)^{3}} as a composite of two functions.
1Inner operation: add 4, so g(x)=x+4\mathrm{g}(x) = x + 4.
2Then cube and take the reciprocal: f(x)=1x3\mathrm{f}(x) = \dfrac{1}{x^{3}}.
Answerh=fg\mathrm{h} = \mathrm{fg} with g(x)=x+4\mathrm{g}(x) = x + 4, f(x)=x−3\mathrm{f}(x) = x^{-3}.

Think like an examiner

  • Show the intermediate step, such as fg(3)=f(9)\mathrm{fg}(3) = \mathrm{f}(9), before the final value.
  • Substitute the inner function in brackets when forming fg(x)\mathrm{fg}(x).
  • Justify existence of a composite by comparing the range of the inner with the domain of the outer.
  • For f2(x)\mathrm{f}^{2}(x), apply f\mathrm{f} twice — do not square.

Common misconceptions

Applying f\mathrm{f} first in fg(x)\mathrm{fg}(x).
The function next to xx — here g\mathrm{g} — acts first.
Assuming fg=gf\mathrm{fg} = \mathrm{gf}.
Check both; they are usually different.
Interpreting f2(x)\mathrm{f}^{2}(x) as [f(x)]2[\mathrm{f}(x)]^{2}.
f2(x)=ff(x)\mathrm{f}^{2}(x) = \mathrm{ff}(x).
Giving the range of fg\mathrm{fg} as the full range of f\mathrm{f}.
Apply f\mathrm{f} only to the range of g\mathrm{g}.

Composition

fg(x)=f(g(x))\mathrm{fg}(x) = \mathrm{f}(\mathrm{g}(x))
Right to left.
f2(x)=ff(x)\mathrm{f}^{2}(x) = \mathrm{ff}(x)
Repeated application.
range of g⊆domain of f\text{range of g} \subseteq \text{domain of f}
Condition for fg to exist.

Stretch yourself

The functions f\mathrm{f} and g\mathrm{g} are defined for all real xx by f(x)=x2−2x\mathrm{f}(x) = x^{2} - 2x and g(x)=x+k\mathrm{g}(x) = x + k, where kk is a non-zero constant. Show that the equation fg(x)=gf(x)\mathrm{fg}(x) = \mathrm{gf}(x) has exactly one solution, and find the value of kk for which that solution is x=−1x = -1.

Hint — Form both composites and subtract. The x2x^{2} terms cancel, leaving a linear equation in xx.

Reveal solution
Solutionfg(x)=(x+k)2−2(x+k)=x2+2kx+k2−2x−2k\mathrm{fg}(x) = (x + k)^{2} - 2(x + k) = x^{2} + 2kx + k^{2} - 2x - 2k, and gf(x)=x2−2x+k\mathrm{gf}(x) = x^{2} - 2x + k. Setting them equal, the x2x^{2} and −2x-2x terms cancel, leaving 2kx+k2−2k=k2kx + k^{2} - 2k = k, so 2kx=3k−k22kx = 3k - k^{2}. Because k≠0k \neq 0, the coefficient of xx is non-zero and there is exactly one solution, x=3−k2x = \dfrac{3 - k}{2}. For this to equal −1-1: 3−k=−23 - k = -2, so k=5k = 5. Check with k=5k = 5: fg(−1)=f(4)=16−8=8\mathrm{fg}(-1) = \mathrm{f}(4) = 16 - 8 = 8 and gf(−1)=g(3)=3+5=8\mathrm{gf}(-1) = \mathrm{g}(3) = 3 + 5 = 8 ✓. ■\blacksquare

Questions students ask

Which function goes first in fg?
g\mathrm{g}. Read fg(x)\mathrm{fg}(x) as f(g(x))\mathrm{f}(\mathrm{g}(x)) — the function closest to xx is applied first.
Can fg exist when gf does not?
Yes. Existence depends on whether the inner function’s range fits the outer function’s domain, and that can hold one way but not the other.
How does this connect to the chain rule?
The chain rule differentiates a composite: ddxf(g(x))=f′(g(x)) g′(x)\dfrac{\mathrm{d}}{\mathrm{d}x}\mathrm{f}(\mathrm{g}(x)) = \mathrm{f}^{\prime}(\mathrm{g}(x))\,\mathrm{g}^{\prime}(x). Decomposing correctly is the first step.
What does f3(x)\mathrm{f}^{3}(x) mean?
fff(x)\mathrm{fff}(x) — apply f\mathrm{f} three times in succession.

Key takeaways

  • fg(x)=f(g(x))\mathrm{fg}(x) = \mathrm{f}(\mathrm{g}(x)): apply g\mathrm{g} first.
  • In general fg≠gf\mathrm{fg} \neq \mathrm{gf}.
  • fg exists when the range of g\mathrm{g} lies within the domain of f\mathrm{f}.
  • The range of fg is found by applying f\mathrm{f} to the range of g\mathrm{g}.
  • Decomposing functions into composites prepares you for the chain rule.

How this fits the course

Test yourself

Answer a few questions, then review anything you missed.

Next step

Keep practising

Start with the quiz above to check the key ideas. You can also choose another topic from the practice library.

Browse practice topics

Related lessons

All 6 lessons

Put the methods into practice: see how A-Level maths duels work. An account is required to play; the overview and sample are public.