Pure · Functions and Graphs · Year 2

Composite Functions

Chain two functions together — feed the output of one straight into the other — and a brand new rule falls out, one that depends entirely on which function you apply first.

8 min read 3 worked examples

Composite functions

With the language of domain, range and mapping types now in place, it's time to combine two functions into one. The composite function $fg(x)$ (also written $f(g(x))$ or $(f\circ g)(x)$) means: apply $g$ first, then apply $f$ to the result. Order matters enormously — $fg(x)$ and $gf(x)$ are generally different functions.

$fg(x) = f(g(x))$
Reading order — right to left

In $fg(x)$, the function written closest to $x$ acts first. So to evaluate $fg(3)$: first compute $g(3)$, then feed that result into $f$. This "inside-out" reading order is the single most common source of composite-function errors — always identify which function is innermost before substituting.

For $fg(x)$ to be defined at a given $x$, that $x$ must lie in the domain of $g$, and the output $g(x)$ must lie in the domain of $f$. The domain of the composite is therefore the set of $x$ in the domain of $g$ for which $g(x)$ also lies in the domain of $f$.

Looking ahead

Chaining functions together is only half the picture. The next lesson looks at running a single function backwards — its inverse — which raises a natural question: does composing $f$ with its own inverse just hand you $x$ back again? (It does — that's exactly what makes it an inverse.)

Worked example 1

Evaluating and finding a composite function
Given $f(x)=2x+1$ and $g(x)=x^2-3$, find $fg(x)$ and $gf(2)$.
MethodSubstitute the inner function into the outer, working from the inside out
1
$fg(x)$ means apply $g$ first, then $f$: $fg(x) = f(g(x)) = f(x^2-3)$.
fg(x) is read "f of g of x" — g acts first.
2
Substitute $x^2-3$ into $f$: $f(x^2-3) = 2(x^2-3)+1 = 2x^2-5$.
Replace every x in f(x) = 2x + 1 with the expression x² − 3.
3
So $fg(x) = 2x^2-5$.
Simplified composite.
4
For $gf(2)$: first find $f(2) = 2(2)+1 = 5$.
Now f acts first, since g is the outer function.
5
Then $gf(2) = g(5) = 5^2-3 = 22$.
Feed f(2) = 5 into g.
▪ solved
Notice

$fg(x)=2x^2-5$ while $gf(x) = g(2x+1) = (2x+1)^2-3 = 4x^2+4x-2$ — clearly a different function. This confirms composition is not commutative: $fg \neq gf$ in general.

Worked example 2

Domain and range of a composite function
$f(x)=\sqrt{x}$ for $x\ge0$, and $g(x)=x-4$ for $x\in\mathbb{R}$. Find $fg(x)$, stating its domain and range.
MethodForm the composite, then restrict the domain so every output of g lands in the domain of f
1
$fg(x) = f(x-4) = \sqrt{x-4}$.
Substitute g(x) = x − 4 into f.
2
For $fg(x)$ to be defined, the output of $g$ must lie in the domain of $f$, i.e. $g(x)\ge0$.
f only accepts non-negative inputs.
3
$x-4\ge0 \Rightarrow x\ge4$.
Solve the resulting inequality for x.
4
So the domain of $fg$ is $x\ge4$.
This restricts g's natural domain (all reals) down to where the composite makes sense.
5
As $x$ ranges over $x\ge4$, $x-4$ ranges over all values $\ge0$, so $\sqrt{x-4}$ ranges over all values $\ge0$: range is $fg(x)\ge0$.
Track how the restricted domain feeds through to the output values.
▪ solved
The key insight

The domain of a composite is never assumed — it must be derived by checking which inputs to the first function produce outputs that the second function can accept. Here, even though $g(x)=x-4$ is defined for all real $x$, only $x\ge4$ produces an output that $f$ (which needs a non-negative input) can handle.

Worked example 3

Solving an equation involving a composite function
$f(x)=2x-1$ and $g(x)=x^2+3$. Find $fg(x)$, and hence solve $fg(x)=23$.
MethodForm the composite, set it equal to the target value, then solve as an ordinary equation
1
$fg(x) = f(x^2+3) = 2(x^2+3)-1 = 2x^2+5$.
Substitute g(x) into f, since g acts first.
2
Set $2x^2+5=23$.
The composite is now an ordinary function of x — solve as usual.
3
$2x^2=18 \Rightarrow x^2=9 \Rightarrow x=\pm3$.
Rearrange and take square roots.
▪ solved
The key insight

Once $fg(x)$ has been simplified into a single expression in $x$, an equation like $fg(x)=23$ is solved exactly like any other equation — the "composite" structure only matters while you're building the expression, not while you're solving it.

Common mistake

Writing $fg(x)$ but actually substituting $f$ into $g$ (i.e. computing $gf(x)$ by accident). Always identify the innermost function first — in $fg(x)$, that's $g$ — and work outward. A quick check: $fg$ is read "f of g", so g is applied first, closest to x.

Check yourself

$f(x)=2x-3$ and $g(x)=x^2+1$. Find $gf(x)$, and hence solve $gf(x)=10$.
(Hint: substitute f into g first, since f is the inner function in gf(x).)

Method
1
$gf(x) = g(2x-3) = (2x-3)^2+1 = 4x^2-12x+9+1 = 4x^2-12x+10$.
Substitute f(x) into g, since f acts first in gf(x).
2
Set $4x^2-12x+10=10 \Rightarrow 4x^2-12x=0 \Rightarrow 4x(x-3)=0$.
Rearrange to standard form and factorise.
3
$x=0$ or $x=3$.
Solve the factorised equation.
▪ solved