Skip to main content

Section 5.1 Function Composition

In Chapter 2 we gave a quick explanation of a composition of functions, in which we discovered the following:

Composing Functions.

Given two functions \(f(x)\) and \(g(x)\text{,}\) the composition \(f(g(x))\) has the same input as \(g \text{,}\) but has the same output as \(f \text{.}\)
However, something we did not discuss in section 6.2 is when we can compose two given functions.

Subsection 5.1.1 When We Can Compose

Suppose that \(f(x) \) and \(g(x) \) are functions, and we wish to compose them as \(f(g(x))\text{.}\) In order for this composition to be possible, it must "make sense." In particular, we need the output of \(g(x)\) be contained in the input of \(f(x) \text{.}\) Let’s see this through an example.

Example 5.1.

Suppose that \(f(x)\) is the function which has as its input the students in a given class, and the function outputs the student’s favorite color. Suppose too that \(g(x)\) is the function which has as its input the buildings in Nebraska, and outputs the building’s height in feet.
Does the composition \(f(g(x))\) make sense?
Solution.
No. Recall that the notation \(f(g(x))\) indicates that we are evaluating the function \(f\) at an output value of \(g \text{.}\) Since the output of \(g \) is the height of a building and the possible input values for \(f \) are students in a given classroom, there is no way to evaluate \(f \) at an output value of \(g \text{.}\)
For example, if the composition were to make sense, then \(f(g(x))\) would be telling us the favorite color of a building of a given height. This is clearly nonsense.

Subsection 5.1.2 Examples of Compositions

As with most topics in mathematics, the best way to understand compositions of functions is by working with several examples. In your course packet you will get practice with several different ways to look at composition of functions, but let’s work through a few together now.

Example 5.2.

Let \(f(x)=2x^2+e^x \) and \(g(x)=3x+1\text{.}\) Find the equation for the compositions \(f(g(x))\) and \(g(f(x))\text{.}\)
Solution.
Let’s start by finding the equation for \(g(f(x))\text{.}\) Start by rewriting the outer function, \(g(x) \text{,}\) with parenthesis around the input \(x \text{.}\) This will help us see where the input of the function \(g \) is located in the equation.
\begin{equation*} g(x)=3(x)+1 \end{equation*}
Now, the composition \(g(f(x))\) is telling us that we are putting the output of \(f(x)\text{,}\) which is \(2x^2+e^x\text{,}\) in place of the input of \(g(x)\text{,}\) which is just \(x \text{.}\) We can accomplish this by putting \(2x^2+e^x\) in place of the \(x \) in the equation for \(g(x)\text{.}\) So, the equation for the composition is given by
\begin{equation*} g(f(x))=3(2x^2+e^x)+1 \end{equation*}
Similarly, to find the equation of \(f(g(x))\text{,}\) we start by rewriting the function \(f(x) \) with parenthesis around the input \(x \text{.}\)
\begin{equation*} f(x)=2(x)^2+e^{(x)} \end{equation*}
Then, by the same reasoning as above, we simply need to put the out of \(g(x)\text{,}\) which is \(3x+1\text{,}\) in place of the input of \(f(x)\text{,}\) which is again just \(x \text{.}\) So, the other composition is given by
\begin{equation*} f(g(x))=2(3x+1)^2+e^{(3x+1)} \end{equation*}
In this next example we will focus less on being able to write an equation for the composition, but instead work on simply evaluating the composition at a few points.

Example 5.3.

Below is the graph of the function \(f(x)\) and a table of values for the function \(g(x)\text{.}\) Using this information, identify the following values:
  1. \(\displaystyle f(g(1)) \)
  2. \(\displaystyle f(f(2))\)
  3. \(\displaystyle g(g(3))\)
described in detail following the image
line for composition
Figure 5.4.
\(x\) \(g(x)\)
\(1\) \(-2\)
\(2\) \(0\)
\(3\) \(2\)
\(4\) \(10\)
Solution.
We will work through the solutions in the same order they were presented:
  1. To find the value of \(f(g(1)) \text{,}\) we must first identify the interior value of \(g(1) \text{.}\) Looking at the table, we see
    \begin{equation*} g(1)=-2 \end{equation*}
    So, replacing \(g(1)\) with \(-2 \) in the formula \(f(g(1))\) we have
    \begin{equation*} f(g(1))=f(-2) \end{equation*}
    From the graph, we see that \(f(-2)=9\text{.}\) This tells us that
    \begin{equation*} f(g(1))=f(-2)=9. \end{equation*}
  2. Using the same steps as outlined in the first problem, we first find the value \(f(2)\text{.}\) From the graph, we see
    \begin{equation*} f(2)=3 \end{equation*}
    Since the graph also shows us that \(f(3)=3\text{,}\) we conclude that
    \begin{equation*} f(f(2))=f(3)=3. \end{equation*}
  3. From the table, we have \(g(3)=2\text{,}\) and \(g(2)=0\text{.}\) So, it must be that
    \begin{equation*} g(g(3))=g(2)=0. \end{equation*}

Exercises 5.1.3 Exercises

1. Composition Functions vs. Non-Functions.

Which of the following functions will result in the composition \(f(g(x))\) not being a function of real values?
Hint.
It may be useful to think about the domain and range of each function. In order for the composition of functions to result in a function, the range of the inside function needs to be within the domain of the outside function.
For example, you can’t take the square root of a negative number, so if the range of a function \(f(x)\) contains all negative values, the composition \(g(f(x))\) is not a function for \(g(x)=\sqrt{x}\text{.}\)

2. Evaluating Function Composition.

Where possible, fill in the values for the function composition \(p(q(x))\text{.}\) If it is not possible to fill in a value, please write "NONE" in the space.
\(x\) 0 1 2 3 4 5
\(p(x)\) 5 1 13 7 1 2
\(q(x)\) 5 0 1 9 4 2
\(p(q(x))\)
Hint.
It may be useful to write down each step as you go. To evaluate \(p(q(0))\text{,}\) you should first use the table to evaluate \(q(0)\text{.}\) Once you get that value, you should evaluate \(p(x)\) at that value using the table.

3. Composing Functions.

Find the following compositions of functions. Note: You do not need to simplify your answer.
a) Let \(f(x)=5x-3\) and \(g(x)=\sqrt{x+5}\text{.}\) Find \(g(f(x))\text{.}\)
\(g(f(x))=\)
b) Let \(f(x)=5x+4\) and \(g(x)=\frac{3x^2-2}{x(x-1)}\text{.}\) Find \(g(f(x))\text{.}\)
\(g(f(x))=\)
c) Let \(f(x)=\frac{1}{\sqrt{1x}}\) and \(g(x)=\frac{1}{(3x-3)^2}\text{.}\) Find \(f(g(x))\text{.}\)
\(f(g(x))=\)
d) Let \(f(x)=\frac{\ln(x)}{7}\) and \(g(x)=e^{2x^2-1}\text{.}\) Find \(f(g(x))\text{.}\)
\(f(g(x))=\)
Hint.
For any function composition, we want to make sure we use the functions in the right order. We want to plug the inside function into the outside function everywhere there’s an "x".
So, to find \(f(g(x))\text{,}\) we would replace each \(x\) in \(f(x)\) with \(g(x)\text{.}\)

4. Composition of Piecewise Functions.

Find \(f(f(f(7)))\) given
\begin{equation*} f(x)=\begin{cases}\displaystyle{2^{x}+2}\amp \text{if}\ x \le 2\cr \displaystyle{4x^{5}-3}\amp \text{if}\ 2 \lt x \le 6\cr \displaystyle{2}\amp \text{if}\ x > 6\end{cases}. \end{equation*}
\(f(f(f(7)))=\)
Hint.
We will break this down into 3 evaluations of the function
\begin{equation*} f(x)=\begin{cases}\displaystyle{2^{x}+2}\amp \text{if}\ x \le 2\cr \displaystyle{4x^{5}-3}\amp \text{if}\ 2 \lt x \le 6\cr \displaystyle{2}\amp \text{if}\ x > 6\end{cases} \end{equation*}
to answer this problem. First evaluate \(f(10)\text{,}\) then plug that value into \(f(x)\) again, then take that new value and evaluate \(f(x)\) at this new value.
Make sure to pay close attention to which piece of the function \(f(x)\) to use based on what value you are evaluating. This may change at each step!

5. Composition from Graphs.

Estimate the following using the graphs of \(f(x)\) (in blue) and \(g(x)\) (in red) shown.
a) \(f(g(5))=\)
b) \(g(f(5))=\)
c) \(f(f(1))=\)
d) \(g(g(5))=\)
Hint.
Any time we need to evaluate \(f(x)\text{,}\) we want to use the blue function graphed above and any time we need to evaluate \(g(x)\text{,}\) we want to use the red function graphed above.
For example, to evaluate \(f(g(0))\text{,}\) you should first use the red function to evaluate \(g(0)=0\text{.}\) Then, we have \(f(g(0))=f(0)=5\text{,}\) using the blue function to evaluate \(f(0)\text{.}\)

6. Decomposing Composition.

In each of the following, \(y = u(v(x))\text{,}\) and \(u(x)\) is given. Find a possible formula for \(v(x)\text{.}\) That is, decompose the given function.
a) \(y=e^{x^3+4}\) given that \(u(x)=e^x\)
\(v(x)=\)
b) \(y=\ln\left(3^{x+5}+x\right)+6\) given that \(u(x)=\ln(x)+6\)
\(v(x)=\)
Hint.
In both cases, we are given the outer-most function. We need to figure out what was plugged into \(u(x)\) to get the composition \(u(v(x))\text{.}\)
a) Since we are given that \(u(x)=e^x\text{,}\) we have
\begin{equation*} u(v(x))=e^{v(x)}. \end{equation*}
What does that mean the formula for \(v(x)\) is?
b) Since we are given that \(u(x)=\ln(x)+6\text{,}\) we have that
\begin{equation*} u(v(x))=\ln(v(x))+6. \end{equation*}
What does that mean the formula for \(v(x)\) is?

7. Decomposing Composition.

For the following composite functions, find possible formulas for \(g(x)\text{,}\) \(h(x)\text{,}\) and \(f(x)\text{,}\) as indicated below. Assume \(g(x) \neq x\text{,}\) \(h(x) \neq x\text{,}\) and \(f(x) \neq x\text{.}\)
a) Find a formula for \(g(x)\) given that \(g(h(x))=(x+4)^2\) and \(h(x)=x+4\text{.}\)
\(g(x)=\)
b) Suppose \(g(h(x))=\sqrt{2x^2+5}\text{.}\)
i) Find a formula for \(g(x)\) if \(h(x)=2x^2\)
\(g(x)=\)
ii) Find a formula for \(g(x)\) if \(h(x)=x^2\text{.}\)
\(g(x)=\)
iii) Find a formula for \(h(x)\) if \(g(x)=\sqrt{x}\text{.}\)
\(h(x)=\)
c) Find a formula for \(h(x)\) given that \(g(h(x))=\dfrac{1}{x-1}+x^2-2x+1\) and \(g(x)=\frac{1}{x}+x^2\text{.}\)
\(h(x)=\)
d) Suppose \(f(g(h(x)))=\dfrac{1}{\log{(x^2+4)}}\text{.}\)
i) Find a formula for \(f(x)\) if \(g(x)=\log(x+4)\) and \(h(x)=x^2\text{.}\)
\(f(x)=\)
ii) Find a formula for \(g(x)\) if \(f(x)=\frac{1}{\log(x)}\) and \(h(x)=x^2\text{.}\)
\(g(x)=\)
iii) Find a formula for \(h(x)\) if \(f(x)=\frac{1}{x}\) and \(g(x)=\log(x)\text{.}\)
\(h(x)=\)
e) Suppose \(g(h(x))=\left(\ln(x)\right)^{2/3}\text{.}\)
i) Find a formula for \(g(x)\) if \(h(x)=\ln(x)\text{.}\)
\(g(x)=\)
ii) Find a formula for \(h(x)\) if \(g(x)=x^2\text{.}\)
\(h(x)=\)
f) Find a formula for \(g(x)\) given that \(g(h(x))=\dfrac{1}{(x-6)^2}\) and \(h(x)=(x-6)^2\text{.}\)
\(g(x)=\)
Hint.
To solve these problems, try to fill in the information you know and fill in the rest. The rest of this hint gives a bit more detail to how you would do that. Once you think you have an answer, you should try to compose the functions to see if you get the right result!
a) Since we know that \(g(h(x))=(x+4)^2\) and \(h(x)=x+4\text{,}\) we have
\begin{equation*} g(h(x))=g(x+4). \end{equation*}
What does that mean the formula is for \(h(x)\text{?}\)
b) We are considering \(g(h(x))=\sqrt{2x^2+5}\text{.}\)
i) To find a formula for \(g(x)\) if \(h(x)=2x^2\text{,}\) we have that
\begin{equation*} g(h(x))=g(2x^{2}). \end{equation*}
What does that mean the formula is for \(g(x)\text{?}\)
ii) To find a formula for \(g(x)\) if \(h(x)=x^2\text{,}\) we have that
\begin{equation*} g(h(x))=g(x^{2}). \end{equation*}
What does that mean the formula is for \(g(x)\text{?}\)
iii) To find a formula for \(h(x)\) if \(g(x)=\sqrt{x}\text{,}\) we have that
\begin{equation*} g(h(x))=\sqrt{h(x)}. \end{equation*}
What does that mean the formula is for \(h(x)\text{?}\)
c) Since we know that \(g(h(x))=\dfrac{1}{x-1}+x^2-2x+1\) and \(g(x)=\frac{1}{x}+x^2\text{,}\) we have
\begin{equation*} g(h(x))=\frac{1}{h(x)}+(h(x))^2. \end{equation*}
What does that mean the formula is for \(h(x)\text{?}\)
d) We are considering \(f(g(h(x)))=\dfrac{1}{\log{(x^2+4)}}\text{.}\)
i) To find a formula for \(f(x)\) if \(g(x)=\log(x+4)\) and \(h(x)=x^2\text{,}\) we have
\begin{equation*} f(g(h(x)))=f(g(x^{2}))=f\left(\log(x^2+4)\right). \end{equation*}
What does that mean the formula is for \(f(x)\text{?}\)
ii) To find a formula for \(g(x)\) if \(f(x)=\frac{1}{\log(x)}\) and \(h(x)=x^2\text{,}\) we have
\begin{equation*} f(g(h(x)))=f(g(x^{2}))=\frac{1}{\log(g(x^{2}))}. \end{equation*}
What does that mean the formula is for \(g(x)\text{?}\)
iii) To find a formula for \(h(x)\) if \(f(x)=\frac{1}{x}\) and \(g(x)=\log(x)\text{,}\) we have
\begin{equation*} f(g(h(x)))=f(\log(h(x)))=\frac{1}{\log(h(x))}. \end{equation*}
What does that mean the formula is for \(h(x)\text{?}\)
e) We are considering \(g(h(x))=\left(\ln(x)\right)^{2/3}\text{.}\)
i) To find a formula for \(g(x)\) if \(h(x)=\ln(x)\text{,}\) we have
\begin{equation*} g(h(x))=g(\ln(x)). \end{equation*}
What does that mean the formula is for \(g(x)\text{?}\)
ii) To find a formula for \(h(x)\) if \(g(x)=x^2\text{,}\) we have
\begin{equation*} g(h(x))=(h(x))^2. \end{equation*}
For this problem, it is useful to remember some properties about exponents. We have
\begin{equation*} (\log(x))^{2/3}=(\log(x)^{1/3})^2. \end{equation*}
What does that mean the formula is for \(h(x)\text{?}\)
f) Since we know that \(g(h(x))=\dfrac{1}{(x-6)^2}\) and \(h(x)=(x-6)^2\text{,}\) we have
\begin{equation*} g(h(x))=g\left((x-6)^2\right). \end{equation*}
What does that mean the formula is for \(g(x)\text{?}\)