5F

Composite functions

Form composite functions f(g(x)) and g(f(x)), evaluate them, and find the domain and range of a composite.

Many functions are built by doing one thing and then another: add $3$, then square. Writing them as a composite of two simpler functions makes them easier to graph now and to differentiate later, since the chain rule in calculus is all about composites.

One function after another

Let $g(x) = x + 3$ and $f(x) = x^2$. Put $2$ into $g$ to get $5$, then put $5$ into $f$ to get $25$. We write this as $f(g(2)) = 25$: the inside function acts first.

Example 1●

$f(x) = x^2$ and $g(x) = x + 3$. Find $f(g(x))$ and $g(f(x))$.

$f(g(x)) = f(x + 3) = (x + 3)^2$
Replace x in f by the whole of g(x).
$g(f(x)) = g(x^2) = x^2 + 3$
Now square first, then add 3.
They are different functions.
Check with x = 2: (2 + 3)² = 25, but 2² + 3 = 7.
f(g(x)) versus g(f(x))

f squares, and g(x) = x + s adds s. It starts on Example 1, with s = 3.

Try this
  • Describe each graph as a transformation of $y = x^2$. Which composite shifts the parabola sideways, and which shifts it up?
  • Is there a value of $s$ that makes the two composites the same?

This is the link with 5A: adding inside the function, $f(x + 3)$, is a horizontal shift, while adding outside, $f(x) + 3$, is a vertical shift. Multiplying inside or outside gives the dilations of 5D.

Example 2●●

$f(x) = 2^x$ and $g(x) = 3x - 1$. Find $f(g(x))$, $g(f(x))$ and $f(g(1))$.

$f(g(x)) = 2^{3x - 1}$
Substitute 3x − 1 for x in f.
$g(f(x)) = 3 \times 2^x - 1$
Substitute 2ˣ for x in g.
$f(g(1)) = 2^{2} = 4$
g(1) = 2, then f(2) = 4.

Domain and range of a composite

An $x$ is allowed in $f(g(x))$ only if $x$ is in the domain of $g$ and $g(x)$ is in the domain of $f$.

Example 3●●●

$f(x) = \sqrt x$ and $g(x) = 4 - x^2$. Find the domain and range of $f(g(x))$ and of $g(f(x))$.

$f(g(x)) = \sqrt{4 - x^2}$ needs $4 - x^2 \ge 0$, so the domain is $-2 \le x \le 2$.
g accepts any x, but f needs a non-negative input, so g(x) ≥ 0.
Range $0 \le y \le 2$.
It is the upper semicircle of radius 2.
$g(f(x)) = 4 - (\sqrt x)^2 = 4 - x$, with domain $x \ge 0$ and range $y \le 4$.
The formula simplifies to 4 − x, but f acts first, so x must still be in the domain of f.

Your turn

$f(x) = 2x - 1$ and $g(x) = x^2$. Solve $f(g(x)) = g(f(x))$.

Show the working

$f(g(x)) = 2x^2 - 1$ and $g(f(x)) = (2x - 1)^2 = 4x^2 - 4x + 1$. Setting them equal: $0 = 2x^2 - 4x + 2 = 2(x - 1)^2$, so $x = 1$. Check: $f(g(1)) = f(1) = 1$ and $g(f(1)) = g(1) = 1$.

Flashcards
$f(g(x))$
Apply $g$ first, then $f$.
Domain of $f(g(x))$
$x$ in the domain of $g$, and $g(x)$ in the domain of $f$.
Practice
  1. $f(x) = 2x + 1$ and $g(x) = x^2$. Find $f(g(3))$.

  2. $f(x) = 2x + 1$ and $g(x) = x^2$. Find $g(f(3))$.

  3. $f(x) = x^2$ and $g(x) = x + 3$. Then $f(g(x)) =$

  4. $f(x) = x^2$ and $g(x) = x + 3$. Then $g(f(x)) =$

  5. $f(x) = 2^x$ and $g(x) = 3x - 1$. Find $f(g(1))$.

  6. $f(x) = 3x - 5$. Find $f(f(2))$.

  7. $f(x) = \sqrt x$ and $g(x) = 4 - x^2$. The domain of $f(g(x))$ is:

  8. $f(x) = x - 4$. Then $f(f(x)) = x - k$. Find $k$.

  9. Exam style: $f(x) = x^2 - 1$ and $g(x) = x + 2$. Solve $f(g(x)) = g(f(x))$.

  10. Exam style: $f(x) = \dfrac{1}{x - 1}$. Apart from $x = 1$, which value of $x$ must be excluded from the domain of $f(f(x))$?

Formula sheet