Skip to main content

Section 5.9 Function Composition

The symbols \((f \circ g)(x)\) are read as "\(f\) composed with \(g\) at \(x\)" or "\(f\) composed with \(g\) of \(x\text{.}\)" The meaning of the symbols follows.

\begin{equation*} (f \circ g)(x)=f(g(x))\text{.} \end{equation*}

For example, suppose that

\begin{equation*} f(x)=2x+7\,\,\text{and}\,\,g(x)=3x-8\text{.} \end{equation*}

Then we would evaluate \((f \circ g)(5)\) as follows.

\begin{align*} (f \circ g)(5)\amp=f(\highlight{g(5)})\\ \amp=f(\highlight{3 \cdot 5-8})\\ \amp=f(\highlight{7})\\ \amp=2 \cdot \highlight{7}+7\\ \amp=21 \end{align*}

The function \(f\) does not need to come first in the composition. Using the same two functions as the last example, let's evaluate \((g \circ f)(-4)\text{.}\)

\begin{align*} (g \circ f)(-4)\amp=g(\highlight{f(-4)})\\ \amp=g(\highlight{2 \cdot -4+7})\\ \amp=g(\highlight{-1})\\ \amp=3 \cdot \highlight{-1} -8\\ \amp=-11 \end{align*}

We can even compose a function with itself. For example, let's evaluate \((h \circ h)(9)\) where \(h(x)=x^2-71\text{.}\)

\begin{align*} (h \circ h)(9)\amp=h(\highlight{h(9)})\\ \amp=h(\highlight{9^2-71})\\ \amp=h(\highlight{10})\\ \amp=\highlight{10}^2-71\\ \amp=29 \end{align*}

In most cases, when working with function composition we are more interested in the function formula than in any one specific function value. Finding the formula for the composition of two functions is very similar to some of the advanced function notation discussed in the last section.

Example 5.9.1.

Determine \((f \circ g)(x)\text{,}\) where

\begin{equation*} f(x)=x^2+3x\,\,\text{and}\,\,g(x)=4-x^2 \end{equation*}
Solution
\begin{align*} (f \circ g)(x)\amp=f(\highlight{g(x)})\\ \amp=f(\highlight{4-x^2})\\ \amp=(\highlight{4-x^2})^2+3(\highlight{4-x^2})\\ \amp=(4-x^2)(4-x^2)+12-3x^2\\ \amp=16-8x^2+x^4+12-3x^2\\ \amp=x^4-11x^2+28 \end{align*}
Example 5.9.2.

Determine \((g \circ f)(x)\) where

\begin{equation*} f(x)=x^2+3x\,\,\text{and}\,\,g(x)=4-x^2 \end{equation*}
Solution
\begin{align*} (g \circ f)(x)\amp=g(\highlight{f(x)})\\ \amp=g(\highlight{x^2+3x})\\ \amp=4-(\highlight{x^2+3x})^2\\ \amp=4-(x^2+3x)(x^2+3x)\\ \amp=4-(x^4+3x^3+3x^3+9x^2)\\ \amp=4-x^4-3x^3-3x^3-9x^2\\ \amp=-x^4-6x^3-9x^2+4 \end{align*}
Example 5.9.3.

\((f \circ f)(x)\)where

\begin{equation*} f(x)=x^2+3x \end{equation*}
Solution
\begin{align*} (f \circ f)(x)\amp=f(\highlight{f(x)})\\ \amp=f(\highlight{x^2+3x})\\ \amp=(\highlight{x^2+3x})^2+3(\highlight{x^2+3x})\\ \amp=(x^2+3x)(x^2+3x)+3x^2+9x\\ \amp=x^4+3x^3+3x^3+9x^2+3x^2+9x\\ \amp=x^4+6x^3+12x^2+9x \end{align*}
Example 5.9.4.

Determine \((g \circ g)(x)\) where

\begin{equation*} g(x)=4-x^2 \end{equation*}
Solution
\begin{align*} (g \circ g)(x)\amp=g(\highlight{g(x)})\\ \amp=g(\highlight{4-x^2})\\ \amp=4-(\highlight{4-x^2})^2\\ \amp=4-(4-x^2)(4-x^2)\\ \amp=4-(16-8x^2+x^4)\\ \amp=4-16+8x^2-x^4\\ \amp=-x^4+8x^2-12 \end{align*}
Example 5.9.5.

Determine \((f \circ g)(x)\text{,}\) where

\begin{equation*} f(x)=\frac{5-7x}{3}\,\,\text{and}\,\,g(x)=\frac{5-3x}{7} \end{equation*}
Solution
\begin{align*} (f \circ g)(x)\amp=f(\highlight{g(x)})\\ \amp=f\left(\highlight{\frac{5-3x}{7}}\right)\\ \amp=\frac{5-\frac{7}{1} \cdot \highlight{\frac{5-3x}{7}}}{3}\\ \amp=\frac{5-(5-3x)}{3}\\ \amp=\frac{5-5+3x}{3}\\ \amp=\frac{3x}{3}\\ \amp=x \end{align*}
Example 5.9.6.

Determine \((g \circ f)(x)\) where

\begin{equation*} f(x)=\frac{5-7x}{3}\,\,\text{and}\,\,g(x)=\frac{5-3x}{7} \end{equation*}
Solution
\begin{align*} (g \circ f)(x)\amp=g(\highlight{f(x)})\\ \amp=\frac{5-\frac{3}{1} \cdot \highlight{\frac{5-7x}{3}}}{7}\\ \amp=\frac{5-(5-7x)}{7}\\ \amp=\frac{5-5+7x}{7}\\ \amp=\frac{7x}{7}\\ \amp=x \end{align*}

In the last example, the functions \(f\) and \(g\) are called inverse functions. Two functions are inverses of one another when the result of applying them in succession, in either order, is that the value input (from the domain) is returned at the end of the composition. That is, \(f\) and \(g\) are inverse functions if and only if

\begin{equation*} (f \circ g)(x)=x\,\,\text{and}\,\,(g \circ f)(x)=x \end{equation*}

for all \(x\) in the appropriate domain.

Exercises Exercises

Determine both \((f \circ g)(x)\) and \((g \circ f)(x)\) for each of the following function pairs. Completely simplify each expression.

1.

\(f(x)=2x-7\) and \(g(x)=8-x\)

Solution
\begin{align*} (f \circ g)(x)\amp=f(\highlight{g(x)})\\ \amp=f(\highlight{8-x})\\ \amp=2(\highlight{8-x})-7\\ \amp=16-2x-7\\ \amp=9-2x \end{align*}
\begin{align*} (g \circ f)(x)\amp=g(\highlightr{f(x)})\\ \amp=g(\highlightr{2x-7})\\ \amp=8-(\highlightr{2x-7})\\ \amp=8-2x+7\\ \amp=15-2x \end{align*}
2.

\(f(x)=x^2+7x\) and \(g(x)=3x+1\)

Solution

We are given \(f(x)=x^2+7x\) and \(g(x)=3x+1\text{.}\) The composite function formulas are derived below.

\begin{align*} (f \circ g)(x)\amp=f(\highlight{g(x)})\\ \amp=f(\highlight{3x+1})\\ \amp=(\highlight{3x+1})^2+7(\highlight{3x+1})\\ \amp=(3x+1)(3x+1)+7(3x+1)\\ \amp=9x^2+3x+3x+1+21x+7\\ \amp=9x^2+27x+8 \end{align*}
\begin{align*} (g \circ f)(x)\amp=g(\highlightr{f(x)})\\ \amp=g(\highlightr{x^2+7x})\\ \amp=3(\highlightr{x^2+7x})+1\\ \amp=3x^2+21x+1 \end{align*}
3.

\(f(x)=\sqrt{x+4}\) and \(g(x)=-3x^2\)

Solution

We are given \(f(x)=\sqrt{x+4}\) and \(g(x)=-3x^2\text{.}\) The composite function formulas are derived below.

\begin{align*} (f \circ g)(x)\amp=f(\highlight{g(x)})\\ \amp=f(\highlight{-3x^2})\\ \amp=\sqrt{-3x^2+4} \end{align*}
\begin{align*} (g \circ f)(x)\amp=g(\highlightr{f(x)})\\ \amp=g(\highlightr{\sqrt{x+4}})\\ \amp=-3(\highlightr{\sqrt{x+4}})^2\\ \amp=-3(x+4)\\ \amp=-3x-12 \end{align*}
4.

\(f(x)=2x+6\) and \(g(x)=\frac{x-8}{2x+1}\)

Solution
\begin{align*} (f \circ g)(x)\amp=f(\highlight{g(x)})\\ \amp=f\left(\highlight{\frac{x-8}{2x+1}}\right)\\ \amp=2\left(\highlight{\frac{x-8}{2x+1}}\right)+6\\ \amp=\frac{2}{1} \cdot \frac{x-8}{2x+1}+\frac{6}{1} \cdot \frac{2x+1}{2x+1}\\ \amp=\frac{2x-16}{2x+1}+\frac{12x+6}{2x+1}\\ \amp=\frac{2x-16+12x+6}{2x+1}\\ \amp=\frac{14x-10}{2x+1} \end{align*}
\begin{align*} (g \circ f)(x)\amp=g(\highlightr{f(x)})\\ \amp=g(\highlightr{2x+6})\\ \amp=\frac{\highlightr{2x+6}-8}{2(\highlightr{2x+6})+1}\\ \amp=\frac{2x-2}{4x+12+1}\\ \amp=\frac{2x-2}{4x+13} \end{align*}
5.

\(f(x)=x^2+3\) and \(g(x)=2x^2+3x\)

Solution
\begin{align*} (f \circ g)(x)\amp=f(\highlight{g(x)})\\ \amp=f(\highlight{2x^2+3x})\\ \amp=(\highlight{2x^2+3x})^2+3\\ \amp=(2x^2+3x)(2x^2+3x)+3\\ \amp=4x^4+6x^3+6x^3+9x^2+3\\ \amp=4x^4+12x^3+9x^2+3 \end{align*}
\begin{align*} (g \circ f)(x)\amp=g(\highlightr{f(x)})\\ \amp=g(\highlightr{x^2+3})\\ \amp=2(\highlightr{x^2+3})^2+3(\highlightr{x^2+3})\\ \amp=2(x^2+3)(x^2+3)+3x^2+9\\ \amp=2(x^4+3x^2+3x^2+9)+3x^2+9\\ \amp=2(x^4+6x^2+9)+3x^2+9\\ \amp=2x^4+12x^2+18+3x^2+9\\ \amp=2x^4+15x^2+27 \end{align*}
6.

\(f(x)=\frac{1}{x}\) and \(g(x)=\frac{x-4}{x+5}\)

Solution

We are given \(f(x)=\frac{1}{x}\) and \(g(x)=\frac{x-4}{x+5}\text{.}\) The composite function formulas are derived below.

\begin{align*} (f \circ g)(x)\amp=f(\highlight{g(x)})\\ \amp=f\left(\highlight{\frac{x-4}{x+5}}\right)\\ \amp=\frac{1}{\highlight{\frac{x-4}{x+5}}}\\ \amp=\frac{\frac{1}{1}}{\frac{x-4}{x+5}}\\ \amp=\frac{1}{1} \cdot \frac{x+5}{x-4}\\ \amp=\frac{x+5}{x-4} \end{align*}
\begin{align*} (g \circ f)(x)\amp=g(\highlightr{f(x)})\\ \amp=g\left(\highlightr{\frac{1}{x}}\right)\\ \amp=\frac{\highlightr{\frac{1}{x}}-4}{\highlightr{\frac{1}{x}}+5}\\ \amp=\frac{\frac{1}{x}-\frac{4x}{x}}{\frac{1}{x}+\frac{5x}{x}}\\ \amp=\frac{\frac{1-4x}{x}}{\frac{1+5x}{x}}\\ \amp=\frac{1-4x}{x} \cdot \frac{x}{1+5x}\\ \amp=\frac{x \cdot (1-4x)}{x \cdot (1+5x)}\\ \amp=\frac{1-4x}{1+5x} \end{align*}
7.

\(f(x)=6-5x\) and \(g(x)=\frac{6-x}{5}\)

Solution

We are given \(f(x)=6-5x\) and \(g(x)=\frac{6-x}{5}\text{.}\) The composite function formulas are derived below.

\begin{align*} (f \circ g)(x)\amp=f(\highlight{g(x)})\\ \amp=f\mathopen{}\left(\highlight{\frac{6-x}{5}}\right)\mathclose{}\\ \amp=6-5\left(\highlight{\frac{6-x}{5}}\right)\\ \amp=6-\frac{5}{1} \cdot \frac{6-x}{5}\\ \amp=6-\frac{5(6-x)}{5}\\ \amp=6-(6-x)\\ \amp=6-6+x\\ \amp=x \end{align*}
\begin{align*} (g \circ f)(x)\amp=g(\highlightr{f(x)})\\ \amp=g(\highlightr{6-5x})\\ \amp=\frac{6-(\highlightr{6-5x})}{5}\\ \amp=\frac{6-6+5x}{5}\\ \amp=\frac{5x}{5}\\ \amp=x \end{align*}
8.

\(f(x)=x^2-16\) and \(g(x)=\sqrt{x+16}\)

Solution
\begin{align*} (f \circ g)(x)\amp=f(\highlight{g(x)})\\ \amp=f(\highlight{\sqrt{x+16}})\\ \amp=(\highlight{\sqrt{x+16}})^2-16\\ \amp=x+16-16\\ \amp=x \end{align*}
\begin{align*} (g \circ f)(x)\amp=g(\highlightr{f(x)})\\ \amp=g(\highlightr{x^2-16})\\ \amp=\sqrt{\highlightr{x^2-16}+16}\\ \amp=\sqrt{x^2}\\ \amp=\abs{x} \end{align*}