9.4 Composite Functions

SL 2.5

In this section you will learn
  • what a composite function \((g \circ f)(x) = g\big(f(x)\big)\) is
  • when a composite function exists: the range of the first function must lie in the domain of the second
  • how to find the rule, the domain and the range of a composite function
  • the identity function \(x \mapsto x\), and why \((f \circ f^{-1})(x) = (f^{-1} \circ f)(x) = x\)

Composite functions

Sometimes we apply one function and then another function to the result. Let

\[ f(x) = x + 2 \text{ with domain } A = \{0, 1, 2\}, \qquad g(x) = x^2 . \]

First \(f\) sends \(A\) to \(B = \{2, 3, 4\}\). Then \(g\) sends \(B\) to \(C = \{4, 9, 16\}\) (Figure 1).

Figure 1: First \(f\), then \(g\): together they make the composite \(g \circ f\).

\[ 0 \overset{f}{\longmapsto} 2 \overset{g}{\longmapsto} 4, \qquad 1 \overset{f}{\longmapsto} 3 \overset{g}{\longmapsto} 9, \qquad x \overset{f}{\longmapsto} x + 2 \overset{g}{\longmapsto} (x + 2)^2 . \]

The single function \(x \mapsto (x + 2)^2\) is the composite of \(f\) and \(g\). We write it \(g \circ f\) (“\(g\) of \(f\)”) or sometimes just \(gf\).

Composite function Not in the formula booklet

\[ (g \circ f)(x) = g\big(f(x)\big) \]

\(g \circ f\) means: apply \(f\) first, then apply \(g\) to the result. (Read from the right.)

In the example above, the domain of \(g \circ f\) is the domain of \(f\), \(\{0, 1, 2\}\), and the range of \(g \circ f\) is \(\{4, 9, 16\}\).

When does a composite function exist?

Now let \(f(x) = 2x - 1\) with domain \(\{0, 1, 2\}\), and \(g(x) = \sqrt{x}\) with domain \(x \geq 0\).

\[ f(0) = -1, \qquad f(1) = 1, \qquad f(2) = 3 . \]

The output \(-1\) is not in the domain of \(g\): \(\sqrt{-1}\) is not a real number. So \(g\big(f(0)\big)\) does not exist, and \(g \circ f\) is not defined on the whole domain of \(f\).

Condition for \(g \circ f\) to exist Not in the formula booklet

\[ \text{range of } f \;\subseteq\; \text{domain of } g \]

Then \(g \circ f\) is defined by \((g \circ f)(x) = g\big(f(x)\big)\) with domain = domain of \(f\).

To find the rule of \(g \circ f\), substitute the expression \(f(x)\) for every \(x\) in \(g\).

Example 1 The functions \(f\) and \(g\) are defined by \(f(x) = 3x^2\) and \(g(x) = 2x - 5\), both for \(x \in \mathbb{R}\). Find

(a) \((f \circ g)(x)\)

(b) \((g \circ f)(x)\)

(c) \((f \circ g)(1)\)

(d) \((g \circ g^{-1})(x)\)

(a) \(g\) first, then \(f\): \(\;(f \circ g)(x) = f(2x - 5) = 3(2x - 5)^2\).

(b) \(f\) first, then \(g\): \(\;(g \circ f)(x) = g(3x^2) = 2(3x^2) - 5 = 6x^2 - 5\).

Notice that \(f \circ g \neq g \circ f\). The order matters.

(c) \(g(1) = -3\), then \(f(-3) = 27\). (Or use (a): \(3(2 - 5)^2 = 27\).)

(d) \(g^{-1}(x) = \dfrac{x + 5}{2}\), so \((g \circ g^{-1})(x) = 2 \cdot \dfrac{x + 5}{2} - 5 = x\).

The identity function

The function \(I(x) = x\) is called the identity function: it leaves every input unchanged. Part (d) of Example 1 shows the important fact that a function followed by its inverse (or the other way round) gives the identity.

Identity and inverse Not in the formula booklet

\[ (f \circ f^{-1})(x) = (f^{-1} \circ f)(x) = x \]

for every \(x\) in the relevant domain. Also \(f \circ I = I \circ f = f\).

  • \(f^{-1}\): the inverse function of \(f\)
  • \(I\): the identity function, \(I(x) = x\)

This gives a quick way to check an inverse: work out \(f\big(f^{-1}(x)\big)\) and see whether you get \(x\).

Example 2 Let \(f(x) = 2x - 1\). Find the function \(g\) such that \((f \circ g)(x) = 6x + 7\).

\((f \circ g)(x) = f\big(g(x)\big) = 2g(x) - 1\). So \(2g(x) - 1 = 6x + 7\), giving \(g(x) = 3x + 4\).

(Another way: apply \(f^{-1}\) to both sides. \(f^{-1}(x) = \dfrac{x + 1}{2}\), so \(g(x) = f^{-1}(6x + 7) = \dfrac{6x + 8}{2} = 3x + 4\).)

Domain and range of a composite function

To find the range of \(g \circ f\): first find the range of \(f\). Then find what \(g\) does to those values only. Do not just put the end points of the domain into the composite.

Example 3 Functions \(f\) and \(g\) are defined by

\[ f : x \mapsto 4 - x^2, \quad 0 \leq x \leq 3, \qquad\qquad g : x \mapsto x^2, \quad x \in \mathbb{R} . \]

(a) State the range of \(f\).

(b) Show that \(g \circ f\) exists, and define it in the same form.

(c) State the range of \(g \circ f\).

(a) \(f\) is decreasing on \(0 \leq x \leq 3\): \(f(0) = 4\), \(f(3) = -5\). Range: \(-5 \leq f(x) \leq 4\).

(b) The range of \(f\), \([-5, 4]\), is contained in the domain of \(g\), \(\mathbb{R}\). So \(g \circ f\) exists:

\[ g \circ f : x \mapsto (4 - x^2)^2, \qquad 0 \leq x \leq 3 . \]

(c) \(g\) squares the numbers in \([-5, 4]\). Squares of numbers from \(-5\) to \(4\) go from \(0\) (at \(0\)) up to \(25\) (at \(-5\)). Range: \(0 \leq (g \circ f)(x) \leq 25\).

(The end points give \((g \circ f)(0) = 16\) and \((g \circ f)(3) = 25\), but the least value \(0\) occurs at \(x = 2\).)

Example 4 The functions \(f\) and \(g\) are defined by

\[ f : x \mapsto \frac{2x + 1}{x + 2}, \quad x \geq 0, \qquad\qquad g : x \mapsto x^2 - 4x + 5, \quad 1 \leq x \leq 3 . \]

(a) Show that \(f \circ g\) exists.

(b) Find the rule for \(f \circ g\) and its domain.

(c) Find the range of \(f \circ g\).

(a) \(g(x) = (x - 2)^2 + 1\). On \(1 \leq x \leq 3\): least value \(g(2) = 1\), greatest \(g(1) = g(3) = 2\). The range of \(g\) is \([1, 2]\), which is inside the domain of \(f\) (\(x \geq 0\)). So \(f \circ g\) exists.

(b) Put \(g(x)\) into \(f\):

\[ (f \circ g)(x) = \frac{2(x^2 - 4x + 5) + 1}{(x^2 - 4x + 5) + 2} = \frac{2x^2 - 8x + 11}{x^2 - 4x + 7}, \qquad 1 \leq x \leq 3 . \]

(c) \(f\) acts on the values \(1 \leq u \leq 2\). Since \(f(u) = \dfrac{2u + 1}{u + 2} = 2 - \dfrac{3}{u + 2}\), \(f\) is increasing.

\(f(1) = 1\) and \(f(2) = \dfrac{5}{4}\), so the range of \(f \circ g\) is \(1 \leq (f \circ g)(x) \leq \dfrac{5}{4}\).

Example 5 The functions \(f\) and \(g\) are defined by

\[ f : x \mapsto \mathrm{e}^{3 - x}, \quad x \geq 1, \qquad\qquad g : x \mapsto \ln(x + 2), \quad x > -2 . \]

(a) Only one of \(g \circ f\) and \(f \circ g\) exists.

(i) Define the one that exists (with its domain) and state its range.

(ii) Explain why the other one does not exist.

(b) The domain of \(g\) is now restricted to \(x > a\).

(i) Find the least value of \(a\) for which the other composite exists, and define it.

(ii) State its range.

Range of \(f\): \(f\) is decreasing, \(f(1) = \mathrm{e}^2\), and \(f(x) \to 0\) as \(x \to \infty\). So \(0 < f(x) \leq \mathrm{e}^2\). Range of \(g\): all of \(\mathbb{R}\).

(a)(i) The range of \(f\), \((0, \mathrm{e}^2]\), is inside the domain of \(g\), \((-2, \infty)\). So \(g \circ f\) exists:

\[ g \circ f : x \mapsto \ln\!\big(\mathrm{e}^{3 - x} + 2\big), \qquad x \geq 1 . \]

As \(0 < \mathrm{e}^{3 - x} \leq \mathrm{e}^2\), we have \(2 < \mathrm{e}^{3 - x} + 2 \leq \mathrm{e}^2 + 2\). Range: \(\ln 2 < (g \circ f)(x) \leq \ln(\mathrm{e}^2 + 2)\).

(a)(ii) The range of \(g\) is \(\mathbb{R}\), which is not inside the domain of \(f\) (\(x \geq 1\)). For example \(g(0) = \ln 2 < 1\), and \(f(\ln 2)\) is not defined.

(b)(i) We need \(g(x) \geq 1\) for all \(x > a\): \(\;\ln(x + 2) \geq 1 \iff x + 2 \geq \mathrm{e} \iff x \geq \mathrm{e} - 2\). So the least value is \(a = \mathrm{e} - 2\). Then

\[ (f \circ g)(x) = \mathrm{e}^{3 - \ln(x + 2)} = \frac{\mathrm{e}^3}{\mathrm{e}^{\ln(x + 2)}} = \frac{\mathrm{e}^3}{x + 2}, \qquad x > \mathrm{e} - 2 . \]

(b)(ii) For \(x > \mathrm{e} - 2\), \(\;x + 2 > \mathrm{e}\), so \(0 < \dfrac{\mathrm{e}^3}{x + 2} < \mathrm{e}^2\). Range: \(0 < (f \circ g)(x) < \mathrm{e}^2\).

Common errors

✗ Wrong ✓ Right Why
\((f \circ g)(x) = f(x) \times g(x)\) \((f \circ g)(x) = f\big(g(x)\big)\) \(\circ\) means “put inside”, not multiply.
\((f \circ g)(x)\): apply \(f\) first Apply \(g\) first Read from the right: the inner function acts first.
Assuming \(f \circ g = g \circ f\) Usually different See Example 1 (a) and (b).
Range of \(g \circ f\) from the end points only Use the range of \(f\), then apply \(g\) In Example 3 the least value \(0\) is not at an end point.
Forgetting to check the range of the first function lies in the domain of the second Check it before writing the composite Otherwise the composite may not exist.

Exercises

1 Let \(f(x) = x + 5\) and \(g(x) = 3x^2\). Find

(a) \((f \circ g)(x)\)

(b) \((g \circ f)(x)\)

(c) \((g \circ f)(-2)\).

(a) \(3x^2 + 5\).

(b) \(3(x + 5)^2\).

(c) \(f(-2) = 3\), \(g(3) = 27\).

2 Let \(f(x) = 1 - 4x\). Find \((f \circ f)(x)\) and solve \((f \circ f)(x) = 9\).

\((f \circ f)(x) = 1 - 4(1 - 4x) = 16x - 3\). \(\;16x - 3 = 9 \Rightarrow x = \dfrac{3}{4}\).

3 Let \(f(x) = \dfrac{1}{x - 2}\), \(x \neq 2\), and \(g(x) = 2x + 1\). Find \((f \circ g)(x)\) and state the value of \(x\) that must be excluded from its domain.

\((f \circ g)(x) = \dfrac{1}{2x + 1 - 2} = \dfrac{1}{2x - 1}\). We need \(g(x) \neq 2\), so \(x \neq \dfrac{1}{2}\).

4 Let \(f(x) = \sqrt{x}\), \(x \geq 0\), and \(g(x) = x - 7\), \(x \in \mathbb{R}\). Find \((f \circ g)(x)\) and its largest possible domain.

\((f \circ g)(x) = \sqrt{x - 7}\). We need \(x - 7 \geq 0\), so the domain is \(x \geq 7\).

5 Let \(f(x) = 5x + 2\). Find \(f^{-1}(x)\), and verify that \((f \circ f^{-1})(x) = (f^{-1} \circ f)(x) = x\).

\(f^{-1}(x) = \dfrac{x - 2}{5}\).

\(f\big(f^{-1}(x)\big) = 5 \cdot \dfrac{x - 2}{5} + 2 = x\) ✓ \(\qquad f^{-1}\big(f(x)\big) = \dfrac{5x + 2 - 2}{5} = x\) ✓

6 Let \(g(x) = x^2 + 1\). Find a function \(f\) such that \((g \circ f)(x) = x^2 + 6x + 10\).

\(x^2 + 6x + 10 = (x + 3)^2 + 1 = g(x + 3)\). So \(f(x) = x + 3\).

7 Write \(h(x) = (3x - 1)^5\) as a composite \(f \circ g\) of two simpler functions.

Let \(g(x) = 3x - 1\) (the inside) and \(f(x) = x^5\) (the outside). Then \((f \circ g)(x) = (3x - 1)^5 = h(x)\).

8 Let \(f(x) = 2x - 3\) and \(g(x) = \dfrac{x + 1}{2}\). Find \((f \circ g)(x)\) and \((g \circ f)(x)\). What do you notice?

\((f \circ g)(x) = (x + 1) - 3 = x - 2\). \(\qquad (g \circ f)(x) = \dfrac{2x - 3 + 1}{2} = x - 1\).

They are different, so \(f \circ g \neq g \circ f\). (Also \(g\) is not the inverse of \(f\), because neither composite is \(x\).)

9 The functions \(f(x) = x^2 - 2x\), \(\;-1 \leq x \leq 2\), and \(g(x) = 3x + 1\), \(x \in \mathbb{R}\), are given. Find \((g \circ f)(x)\) and its range.

\((g \circ f)(x) = 3(x^2 - 2x) + 1 = 3x^2 - 6x + 1\), \(\;-1 \leq x \leq 2\).

Range of \(f\): \(f(x) = (x - 1)^2 - 1\), least \(-1\) (at \(x = 1\)), greatest \(3\) (at \(x = -1\)). So \(-1 \leq f(x) \leq 3\).

\(g\) is increasing, so the range of \(g \circ f\) is \(g(-1) = -2\) to \(g(3) = 10\): \(\;-2 \leq (g \circ f)(x) \leq 10\).

10 Let \(f(x) = \mathrm{e}^{x}\), \(x \in \mathbb{R}\), and \(g(x) = \ln(x - 1)\), \(x > 1\).

(a) Explain why \(g \circ f\) does not exist on the whole of \(\mathbb{R}\).

(b) Find the largest domain on which \(g \circ f\) exists, and its rule.

(c) Find \((f \circ g)(x)\) in its simplest form.

(a) The range of \(f\) is \((0, \infty)\), but \(g\) needs inputs \(> 1\). For example \(f(-1) = \mathrm{e}^{-1} < 1\).

(b) We need \(\mathrm{e}^{x} > 1\), so \(x > 0\). \(\;(g \circ f)(x) = \ln(\mathrm{e}^{x} - 1)\), \(\;x > 0\).

(c) \((f \circ g)(x) = \mathrm{e}^{\ln(x - 1)} = x - 1\), \(\;x > 1\).