Skip to main content

Section 7.3 Composing and Decomposing Functions

Suppose you wanted to convert 12000 inches to miles. The function
\begin{equation*} g(x) = \frac{1}{12}x \end{equation*}
takes an input \(x\) in inches and yields an output in feet (because there are 12 inches in one foot). Similarly, the function
\begin{equation*} f(x) = \frac{1}{5280}x \end{equation*}
takes an input \(x\) in feet and yields an output in miles (because there are 5280 feet in a mile). We could thus convert 12000 inches to miles by first converting it to feet by computing
\begin{equation*} g(12000) = \frac{1}{12}(12000) = 1000 \end{equation*}
and then taking 1000 feet and converting that to miles by calculating
\begin{equation*} f(1000) = \frac{1}{5280}(1000) \approx 0.189. \end{equation*}
Thus, we arrive at the conclusion that 12000 inches is approximately 0.189 miles.
What if we wanted a single function that could convert inches to miles, so that we only had to perform one calculation rather than two? Given two functions, it is possible to generate another function by composing one with the other. This can be done by substituting one function into the other.

Definition 7.3.1. Composition of Functions.

Given two functions \(f\) and \(g\text{,}\) we denote the composition of \(f\) with \(g\) by \(f \circ g\) and define
\begin{equation*} (f \circ g)(x) = f(g(x)). \end{equation*}
We read the above as β€œ\(f\) of \(g\) of \(x\text{.}\)” \((f \circ g)(x)\) is defined for inputs \(x\) such that \(x\) is in the domain of \(g\) and \(g(x)\) is in the domain of \(f\text{.}\)
We often call \(f\) the β€œoutside” or the β€œouter” function of the composition \(f(g(x))\text{;}\) we call \(g\) the β€œinside” or the β€œinner” function of the composition \(f(g(x))\text{.}\)

Example 7.3.2.

Let \(f(x) = \frac{1}{5280}x\) and let \(g(x) = \frac{1}{12}x\text{.}\) Find \((f \circ g)(x)\text{.}\)
Solution.
By definition, the function
\begin{equation*} (f \circ g)(x) = f(g(x)). \end{equation*}
This means that we are taking the function \(f(x)\) and substituting \(g(x) = \frac{1}{12}x\) into it. Thus, we have that
\begin{align*} f(\textcolor{red}{g(x)}) \amp = f\left(\textcolor{red}{\frac{1}{12}x}\right)\\ \amp = \frac{1}{5280}\left(\textcolor{red}{\frac{1}{12}x}\right)\\ \amp = \frac{1}{63360}x. \end{align*}
Observe that in the above example, \((f \circ g)(12000) = \frac{1}{63360}(12000) \approx 0.189\text{,}\) so this composite function in fact is the formula for converting an input \(x\) in inches to miles.

Example 7.3.3.

Let \(f(x) = x^2 - 2x + 1\text{,}\) \(g(x) = 2 - x\text{,}\) and let \(h(x) = \sqrt{x - 1}\text{.}\) Find each of the following.
  1. \(\displaystyle (f \circ g)(x)\)
  2. \(\displaystyle (g \circ f)(x)\)
  3. \(\displaystyle (h \circ f \circ g)(x)\)
  4. \(\displaystyle (h \circ h)(x)\)
Solution.
  1. We have that
    \begin{align*} f(\textcolor{red}{g(x)}) \amp = f(\textcolor{red}{2 - x})\\ \amp = (\textcolor{red}{2 - x})^2 - 2(\textcolor{red}{2 - x}) + 1\\ \amp = 4 - 4x + x^2 - 4 + 2x + 1\\ \amp = x^2 - 2x + 1. \end{align*}
  2. We have that
    \begin{align*} g(\textcolor{red}{f(x)}) \amp = g(\textcolor{red}{x^2 - 2x + 1})\\ \amp = 2 - (\textcolor{red}{x^2 - 2x + 1})\\ \amp = 2 - x^2 + 2x - 1\\ \amp = - x^2 + 2x + 1. \end{align*}
  3. Since we know \(f(g(x)) = x^2 - 2x + 1\) from part (1), then
    \begin{align*} h(\textcolor{red}{f(g(x))}) \amp = h(\textcolor{red}{x^2 - 2x + 1})\\ \amp = \sqrt{\textcolor{red}{x^2 - 2x + 1} - 1}\\ \amp = \sqrt{x^2 - 2x}. \end{align*}
  4. We have that
    \begin{align*} h(\textcolor{red}{h(x)}) \amp = h(\textcolor{red}{\sqrt{x - 1}})\\ \amp = \sqrt{\textcolor{red}{\sqrt{x - 1}} - 1}\\ \amp = \sqrt{\sqrt{x - 1} - 1}. \end{align*}
Note: Notice that the two functions \((f \circ g)(x) = f(g(x))\) and \((g \circ f)(x) = g(f(x))\) in the above example are different. The order in which you compose functions matters.
To compose functions is important, but it is often even more important to be able to decompose a complicated function into simpler functions; that is, represent a more complicated function as a composition of simpler functions.

Example 7.3.4.

Express each of the following as a composition of two functions \(f(x)\) and \(g(x)\) so that \(y = (f \circ g)(x)\text{.}\)
  1. \(\displaystyle y = (3x - 10)^9\)
  2. \(\displaystyle y = \sqrt{x + 1}\)
  3. \(\displaystyle y = \ln(x^2 + 2)\)
Solution.
  1. To represent the function \(y = (3x - 10)^9\) as a composition \(y = f(g(x))\text{,}\) think of the function as a sequence of operations. To obtain output \(y\) from an input \(x\) we perform the following operations: multiply by \(3\text{,}\) subtract \(10\text{,}\) and then raise to the power \(9\text{.}\) To decompose the function, split this sequence of operations into two simpler chunks. β€œMultiply by \(3\) and subtract \(10\)” β€” that is the first group of operations which gives us our inner function \(g(x) = 3x - 10\text{.}\) The next operation is β€œraise to the power \(9\)” which gives us the outer function \(f(x) = x^9\text{.}\)
    Does this work? We compute \((f \circ g)(x) = f(g(x))\) for this choice of \(f(x)\) and \(g(x)\text{:}\)
    \begin{align*} (f \circ g)(x) \amp = f(g(x))\\ \amp = f(3x - 10)\\ \amp = (3x - 10)^9. \end{align*}
    This is equivalent to our original function \(y\text{,}\) so we have chosen \(f(x)\) and \(g(x)\) appropriately, and we are done.
  2. The sequence of operations performed on the input to get the corresponding output is: add \(1\) and then take the square root of the result. Take the inner function \(g\) which adds \(1\) and the outer function \(f\) which takes the square root. That is, take \(g(x) = x + 1\) and \(f(x) = \sqrt{x}\text{.}\) The given function \(y = \sqrt{x + 1}\) is the composition \(f(g(x))\text{:}\)
    \begin{align*} (f \circ g)(x) \amp = f(g(x))\\ \amp = f(x + 1)\\ \amp = \sqrt{x + 1}. \end{align*}
  3. The function represents the sequence of operations: take the square of the input, add \(2\text{,}\) and then take the natural logarithm of the result. Hence, we can write the function as \(f(g(x))\) for \(g(x) = x^2 + 2\) and \(f(x) = \ln(x)\text{:}\)
    \begin{align*} f(g(x)) \amp = f(x^2 + 2)\\ \amp = \ln(x^2 + 2) \end{align*}
    which gives our original function \(y = \ln(x^2 + 2)\text{.}\)

Example 7.3.5.

Decompose the function
\begin{equation*} h(x) = \frac{1}{\sqrt{x + 1}} \end{equation*}
into two simpler functions \(f\) and \(g\text{.}\)
Solution.
The sequence of operations that \(h\) performs on an input to obtain the output is: add 1, take the square root, take the reciprocal of the result. We group them as follows: β€œadd 1 and take the square root” for the inner function and β€œtake the reciprocal” for the outer function. In other words we take the inner function \(g(x) = \sqrt{x + 1}\) and the outer function \(f(x) = \displaystyle\frac{1}{x}\text{.}\) It works as:
\begin{align*} h(x) \amp= f(g(x))\\ \amp= f(\sqrt{x + 1})\\ \amp= \frac{1}{\sqrt{x + 1}} \end{align*}
Is it the only way to decompose \(h\text{?}\) No. Usually there are many ways to decompose a given function. For the function \(h\) given above, take \(g(x) = x + 1\) and \(f(x) = \frac{1}{\sqrt{x}}\text{.}\) Those two functions work as well:
\begin{align*} h(x) \amp= f(g(x))\\ \amp= f(x + 1)\\ \amp= \frac{1}{\sqrt{x + 1}} \end{align*}

Example 7.3.6.

Decompose the function
\begin{equation*} m(x) = e^{x^3 - 2} \end{equation*}
into two simpler functions \(f\) and \(g\text{.}\)
Solution.
The sequence of operations for \(m(x)\) is: take the cube, subtract 2 and then take the natural exponential of the result. The following functions should work: \(g(x) = x^3 - 2\text{,}\) \(f(x) = e^x\text{.}\) Indeed:
\begin{align*} m(x) \amp = f(g(x))\\ \amp = f(x^3 - 2)\\ \amp = e^{x^3 - 2} \end{align*}

By the way...

Exercises Exercises

Computing a Composition.

For each of the following, find \((f\circ g)(x)\) and \((g\circ f)(x)\text{.}\)

2.

\(f(x)=3x-1\) and \(g(x)=5-\frac{1}{2}x\)
Solution.
\(f(g(x))=-\frac{3}{2}x+14\text{;}\) \(g(f(x))=-\frac{3}{2}x+\frac{11}{2}\)

6.

\(f(x)=\sqrt{x-7}\) and \(g(x)=\sqrt{x+7}\)
Solution.
\(f(g(x))=\sqrt{\sqrt{x+7}-7}\text{;}\) \(g(f(x))=\sqrt{\sqrt{x-7}+7}\)

9.

\(f(x)=\dfrac{x}{x^2-9}\) and \(g(x)=3x+1\)
Solution.
\(f(g(x))=\dfrac{3x+1}{(3x+1)^2-9}\text{;}\) \(g(f(x))=3\left(\dfrac{x}{x^2-9}\right)+1\)

10.

\(f(x)=\dfrac{2x-3}{x+1}\) and \(g(x)=\dfrac{1}{2x-1}\)
Solution.
\(f(g(x))=\frac{5}{2x}-3\text{;}\) \(g(f(x))=\frac{x+1}{3x-7}\)

Evaluating a Composition.

For each of the following, find \((f\circ g)(2)\) for the functions \(f(x)\) and \(g(x)\) given.

Decomposing a Function.

For each of the following, express it as a composition of two functions \(f(x)\) and \(g(x)\) so that \(y=(f\circ g)(x)\text{.}\)
You have attempted of activities on this page.