SubsectionComposition of Functions
We encounter composite functions in the real world every day. As an example, suppose you and some friends are driving from Lincoln, NE to Omaha, NE. Once you arrive in Omaha you drive around the city to see all the beautiful sites. We know that Omaha is 60 miles away from Lincoln, and for each hour spent in Omaha, you drive an additional 5 miles. Then the function
\begin{equation*}
m(x)=60+5x
\end{equation*}
represents the miles traveled if you and your friends spend \(x\) hours in Omaha.
Now, suppose gas for your vehicle costs $0.15 per mile. We can represent this knowledge with the function
\begin{equation*}
c(m)=.15m
\end{equation*}
where \(m\) is in miles. If we want to know how much you and your friends will spend on gas during your trip if you spend \(x\) hours in Omaha, we can now use these two functions we created. If you spend \(x\) hours in Omaha, you will have traveled \(60+5x\) miles. The cost of gas is \(.15m\) where \(m\) is miles. Then we need only replace \(m\) by \(60+5x\) to get
\begin{equation*}
.15(60+5x)
\end{equation*}
as the cost of gas if you spend \(x\) hours in Omaha.
In function notation, we write this as follows:
\begin{equation*}
c(f(x))=.15f(x)=.15(60+5x).
\end{equation*}
Here we are evaluating the function \(c(m)\) at the value \(f(x)\) since \(f(x)\) is the number of miles traveled. The function \(c(f(x))\) is called a composite function, or a composition of functions.
Example2.61
Given the functions \(f(x)=x^22x \) and \(g(x)=.5 x\text{,}\) identify the function \(f(g(x))\) and find the value of \(f(g(1))\text{.}\)
SolutionFirst, let's find the function \(f(g(x))\text{.}\) To identify this function, we are plugging in \(.5x\) for \(x\) in the function \(f(x)=x^22x\text{.}\) We get the function
\begin{equation*}
f(g(x))=f(.5x)=(.5x)^22(.5x)=.25x^2x.
\end{equation*}
Now, to find the value \(f(g(1))\) we simply evaluate the function \(f(g(x))\) at \(1\text{.}\) We have
\begin{equation*}
f(g(1))=.25(1)^21=.251=.75.
\end{equation*}
Looking back at our first example, from the functions \(m(x)=60+5x\) and \(c(m)=.15m\) we created the new function
\begin{equation*}
c(m(x))=.15(60+5x).
\end{equation*}
Notice that this composition of functions, \(c(m(x))\text{,}\) has time in hours as its input and cost as its output.
In general, 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{.}\)
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{.}\)
Subsection
First let us consider why we need another derivative rule.
Example2.62
Consider the function
\begin{equation*}
f(x) = (x^2+3x)^2\text{,}
\end{equation*}
in order to take the derivative we would have to rewrite this as a product of two functions:
\begin{equation*}
f(x) = (x^2+3x)^2=(x^2+3x)(x^2+3x)\text{,}
\end{equation*}
and then use the product rule to find the derivative
\begin{equation*}
f'(x) = (2x+3)(x^2+3x)+(x^2+3x)(2x+3)=2(x^2+3x)(2x+3)\text{.}
\end{equation*}
When we have a composite function we could try to rewrite as we did in Example2.62; however, often this is very hard. For example:
\begin{equation*}
r(x) = (x^2+3x)^{70}\text{,}
\end{equation*}
we would not want to distribute 70 times, or apply the product rule to the product of 70 functions. We need a rule for finding the derivative of composite functions without using algebra to rewrite.
SubsectionThe Chain Rule
Chain Rule
If \(g\) is differentiable at \(x\) and \(f\) is differentiable at \(g(x)\text{,}\) then the composite function \(C\) defined by \(C(x) = f(g(x))\) is differentiable at \(x\) and
\begin{equation*}
C'(x) = f'(g(x)) g'(x)\text{.}
\end{equation*}
As with the product and quotient rules, it is often helpful to think verbally about what the chain rule says: If \(C\) is a composite function defined by an outer function \(f\) and an inner function \(g\text{,}\) then \(C'\) is given by the derivative of the outer function evaluated at the inner function, times the derivative of the inner function.
It is helpful to clearly identify the inner function \(g\) and outer function \(f\text{,}\) compute their derivatives individually, and then put all of the pieces together by the chain rule.
Example2.63
Use the chain rule to determine the derivative of the function
\begin{equation*}
r(x) = (x^2+3x)^{70}\text{.}
\end{equation*}
First we want to identify an inside function. Here the inside function is:
\begin{equation*}
\text{inside function=} g(x) = x^2+3x\text{.}
\end{equation*}
Once you have found an inside function, what is left is the outside function, here:
\begin{equation*}
\text{outside function= }f(x) = x^{70} \text{.}
\end{equation*}
Then we apply the chain rule by taking the derivative of the outside function, with the inside unchanged, then multiply by the derivative of the inside:
\begin{equation*}
r'(x)=70(x^2+3x)^{69}(2x+3)\text{.}
\end{equation*}
Example2.64
For each function given below, identify an inner function \(g\) and outer function \(f\) to write the function in the form \(f(g(x))\text{.}\) Determine \(f'(x)\text{,}\) \(g'(x)\text{,}\) and \(f'(g(x))\text{,}\) and then apply the chain rule to determine the derivative of the given function.
\(\displaystyle h(x) = (2x^2+5x)^4\)
\(\displaystyle g(x) = 3(x^3+4x)^9\)
\(\displaystyle p(x) = \sqrt{ 5x^2+7x+2}\)
\(\displaystyle s(x) = \frac{2}{(x^3+5)^2}\)
\(\displaystyle z(x) = \frac{1}{\sqrt{x^2+4}}\)
Answer
\(\displaystyle h'(x) = 4(2x^2+5x)^3(4x+5)\text{.}\)
\(\displaystyle g'(x) = 27(x^3+4x)^8(3x^2+4x)\text{.}\)
\(\displaystyle p'(x) = \frac12(5x^2+7x+2)^{1/2}(10x+7)=\frac{10x+7}{2\sqrt{5x^2+7x+2}}\text{.}\)
\(\displaystyle s'(x) = 4(x^3+5)^{3}(3x^2)=\frac{12x^2}{(x^3+5)^3}\text{.}\)
\(\displaystyle z'(x) = \frac{1}{2}(x^2+4)^{3/2}(2x)=\frac{x}{(x^2+4)^{3/2}}\text{.}\)
Solution

The outer function is \(f(x) = x^4\) while the inner function is \(g(x) = 2x^2+5x\text{.}\) We know that
\begin{equation*}
f'(x) = 4x^3,
g'(x) =4x+5\text{.}
\end{equation*}
Hence by the chain rule,
\begin{equation*}
h'(x) = f'(g(x))g'(x) = 4(2x^2+5x)^3(4x+5)\text{.}
\end{equation*}

The outer function is \(f(x) = 3x^9\) and the inner function is \(g(x) = x^3+4x\text{.}\) We know that
\begin{equation*}
f'(x) = 27x^8, g'(x) = 3x^2+4\text{.}
\end{equation*}
Thus by the chain rule,
\begin{equation*}
h'(x) = f'(g(x))g'(x) = 27(x^3+4x)^8(3x^2+4)\text{.}
\end{equation*}

The outer function is \(f(x) = \sqrt{x}=x^{1/2}\) while the inner function is \(g(x) = 5x^2+7x+2\text{.}\) We know that
\begin{equation*}
f'(x) = \frac{1}{2}x^{1/2},
g'(x) = 10x+7\text{.}
\end{equation*}
Thus by the chain rule,
\begin{equation*}
p'(x) = f'(g(x))g'(x) = \frac12(5x^2+7x+2)^{1/2}(10x+7)=\frac{10x+7}{2\sqrt{5x^2+7x+2}}\text{.}
\end{equation*}

The outer function is \(\displaystyle f(x) =\frac{2}{x^2}=2x^{2}\) and the inner function is \(g(x) = x^3+5\text{.}\) We know that
\begin{equation*}
s'(x) = 4x^{3}=\frac{4}{x^3}, g'(x) = 3x^2\text{.}
\end{equation*}
Hence by the chain rule,
\begin{equation*}
h'(x) = f'(g(x))g'(x) = 4(x^3+5)^{3}(3x^2)=\frac{12x^2}{(x^3+5)^3}\text{.}
\end{equation*}

The outer function is \(\displaystyle f(x) = \frac{1}{\sqrt{x}}=x^{1/2}\) and the inner function is \(g(x) = x^2+4\text{.}\) We know that
\begin{equation*}
f'(x) = \frac{1}{2}x^{3/2}=\frac{1}{2x^{3/2}}, g'(x) =2x\text{.}
\end{equation*}
Hence by the chain rule,
\begin{equation*}
z'(x) = f'(g(x))g'(x) = \frac{1}{2}(x^2+4)^{3/2}(2x)=\frac{x}{(x^2+4)^{3/2}}\text{.}
\end{equation*}
SubsectionUsing Multiple Rules Simultaneously
The chain rule now joins the sum, constant multiple, product, and quotient rules in our collection of techniques for finding the derivative of a function through understanding its algebraic structure and the basic functions that constitute it. It takes practice to get comfortable applying multiple rules to differentiate a single function, but using proper notation and taking a few extra steps will help.
Example2.65
Find a formula for the derivative of \(h(t) = \sqrt{t^2 + 2t}(3t^4+6t)^5\text{.}\)
We first observe that \(h\) is the product of two functions: \(h(t) = a(t) \cdot b(t)\text{,}\) where \(a(t) = \sqrt{t^2 + 2t}\) and \(b(t) = (3t^4+6t)^5\text{.}\) We will need to use the product rule to differentiate \(h\text{.}\) And because \(a\) and \(b\) are composite functions, we will also need the chain rule. We therefore begin by computing \(a'(t)\) and \(b'(t)\text{.}\)
Writing \(a(t) = f(g(t)) = \sqrt{t^2+2t}\) and finding the derivatives of \(f\) and \(g\) with respect to \(t\text{,}\) we have
\(f(t) = \sqrt{t}\text{,}\) 

\(g(t) = t^2 + 2t\text{,}\) 
\(f'(t) = \frac{1}{2}t^{1/2}\text{,}\) 

\(g'(t) = 2t+2\text{,}\) 
\(f'(g(t)) = \frac{1}{2(t^2+2t)^{1/2}}\text{.}\) 


Thus by the chain rule, it follows that
\begin{equation*}
a'(t) = f'(g(t))g'(t) = \frac{1}{2(t^2+2t)^{1/2}} (2t+2)=\frac{t+1}{\sqrt{t^2+2t}}\text{.}
\end{equation*}
Turning next to the function \(b\text{,}\) we write \(b(t) = r(s(t)) = (3t^2+6t)^5 \) and find the derivatives of \(r\) and \(s\) with respect to \(t\text{.}\)
\(r(t) = t^5\text{,}\) 

\(s(t) = 3t^2+6t \text{,}\) 
\(r'(t) = 5t^4\text{,}\) 

\(s'(t) = 6t+6\text{,}\) 
\(r'(s(t)) = 5(3t^2+6t)^4\text{.}\) 


By the chain rule,
\begin{equation*}
\end{equation*}
Now we are finally ready to compute the derivative of the function \(h\text{.}\) Recalling that \(h(t) = \sqrt{t^2 + 2t}(3t^4+6t)^5\text{,}\) by the product rule we have
\begin{equation*}
h'(t) = \frac{d}{dt}\left[\sqrt{t^2 + 2t}\right](3t^4+6t)^5+\sqrt{t^2 + 2t} \frac{d}{dt}\left[(3t^4+6t)^5\right] \text{.}
\end{equation*}
From our work above with \(a\) and \(b\text{,}\) we know the derivatives of \(\sqrt{t^2 + 2t}\) and \((3t^4+6t)^5\text{.}\) Therefore
\begin{equation*}
h'(t) =\frac{t+1}{\sqrt{t^2+2t}}(3t^4+6t)^5 + \sqrt{t^2 + 2t} 5(3t^2+6t)^4(6t+6) \text{.}
\end{equation*}
The above calculation may seem tedious. However, by breaking the function down into small parts and calculating derivatives of those parts separately, we are able to accurately calculate the derivative of the entire function.
Example2.66
Differentiate each of the following functions. State the rule(s) you use, label relevant derivatives appropriately, and be sure to clearly identify your overall answer.
\(p(x) = 4x^2\sqrt{x^6 + 2x}\)
\(\displaystyle m(x) = \frac{x}{(x^2+2)^2}\)
\(\displaystyle h(x) = \frac{\sqrt{3x^2+5x}}{4x+3}\)
\(c(x) = 4(x^4+5x)^7(7x^3+5x)^5\)
Answer
\(p'(x) = 8x\sqrt{x^6+2x}+4x^2\frac{3x^5+1}{\sqrt{x^6+2x}}\text{.}\)
\(m'(x) = \frac{(x^2+2)^2x2(x^2+2)(2x)}{(x^2+2)^4}\text{.}\)
\(m'(x) = \frac{0.5(3x^2+5x)^{1/2}(6x+5)(4x+3)\sqrt{3x^2+5x}(4)}{(4x+3)^2}\text{.}\)
\(h'(x) = [28(x^4+5x)^6(4x^3+5)](7x^3+5x)^5+4(x^4+5x)^7[5(7x^3+5x)^4(21x^2+5)]\text{.}\)
Solution

By the product rule,
\begin{equation*}
\displaystyle p'(x) = \frac{d}{dx}\left[4x^2\right]\sqrt{x^6 + 2x}+4x^2\frac{d}{dx}\left[\sqrt{x^6 + 2x}\right]\text{.}
\end{equation*}
Using the chain rule to complete the second derivative as
\begin{equation*}
\frac{d}{dx}\left[\sqrt{x^6 + 2x}\right]=\frac{1}{2}(x^6+2x)^{1/2}(6x^5+2)=\frac{3x^5+1}{\sqrt{x^6+2x}}\text{.}
\end{equation*}
Then put together, we see that
\begin{equation*}
p'(x) = 8x\sqrt{x^6+2x}+4x^2\frac{3x^5+1}{\sqrt{x^6+2x}}\text{.}
\end{equation*}

Observe that by the quotient rule,
\begin{equation*}
\displaystyle m'(x) = \frac{\frac{d}{dx}\left[x\right](x^2+2)^2x\frac{d}{dx}\left[(x^2+2)^2\right]}{((x^2+2)^2)^2}\text{.}
\end{equation*}
Applying the chain rule to differentiate
\begin{equation*}
\frac{d}{dx}\left[(x^2+2)^2\right]=2(x^2+2)(2x)
\end{equation*}
Then put together, we see that
\begin{equation*}
m'(x) = \frac{(x^2+2)^2x2(x^2+2)(2x)}{(x^2+2)^4}\text{.}
\end{equation*}

By the quotient rule,
\begin{equation*}
h'(y) = \frac{\frac{d}{dx}[\sqrt{3x^2+5x}](4x+3)  \sqrt{3x^2+5x} \frac{d}{dx}[(4x+3)]}{(4x+3)^2}\text{.}
\end{equation*}
Applying the chain rule to differentiate
\begin{equation*}
\frac{d}{dx}[\sqrt{3x^2+5x}]=\frac12(3x^2+5x)^{1/2}(6x+5)=\frac{6x+5}{2\sqrt{3x^2+5x}}\text{,}
\end{equation*}
it follows that
\begin{equation*}
h'(x) =\frac{0.5(3x^2+5x)^{1/2}(6x+5)(4x+3)\sqrt{3x^2+5x}(4)}{(4x+3)^2}\text{.}
\end{equation*}

By the product rule
\begin{equation*}
h'(x)=\frac{d}{dx}\left[4(x^4+5x)^7\right](7x^3+5x)^5+4(x^4+5x)^7\frac{d}{dx}\left[(7x^3+5x)^5\right]\text{.}
\end{equation*}
Use the chain rule to find each derivative:
\begin{equation*}
\frac{d}{dx}\left[4(x^4+5x)^7\right]=28(x^4+5x)^6(4x^3+5)
\end{equation*}
and
\begin{equation*}
\frac{d}{dx}\left[(7x^3+5x)^5\right]=5(7x^3+5x)^4(21x^2+5)\text{.}
\end{equation*}
Then with the product rule, we find that
\begin{equation*}
h'(x) = [28(x^4+5x)^6(4x^3+5)](7x^3+5x)^5+4(x^4+5x)^7[5(7x^3+5x)^4(21x^2+5)]\text{.}
\end{equation*}
The chain rule now adds substantially to our ability to compute derivatives. Whether we are finding the equation of the tangent line to a curve, the instantaneous velocity of a moving particle, or the instantaneous rate of change of a certain quantity, the chain rule is indispensable if the function under consideration is a composition.
Example2.67
Use known derivative rules (including the chain rule) as needed to answer each of the following questions.
Find an equation for the tangent line to the curve \(y= \sqrt{x^3 +x+ 4}\) at the point where \(x=0\text{.}\)
If \(\displaystyle s(t) = \frac{1}{(t^2+1)^3}\) represents the position function of a particle moving horizontally along an axis at time \(t\) (where \(s\) is measured in inches and \(t\) in seconds), find the particle's instantaneous velocity at \(t=1\text{.}\) Is the particle moving to the left or right at that instant?
Answer
\(y  2 = \frac{1}{4}(x0)\text{.}\)
\(s'(1) = \frac{3}{8}\) inches per second, so the particle is moving left at the instant \(t = 1\text{.}\)
Solution

Let \(f(x) = \sqrt{x^3 + 4}\text{.}\) By the chain rule, \(\displaystyle f'(x) = \frac{1}{2} (x^3+x+4)^{1/2}(3x^2+1)\text{,}\) and thus \(f'(0) = \frac{1}{4}\text{.}\) Note further that \(f(0) = \sqrt{4} = 2\text{.}\) The tangent line is therefore the line through \((0,2)\) with slope \(\frac{1}{4}\text{,}\) which is
\begin{equation*}
y  2 = \frac{1}{4}(x0)\text{.}
\end{equation*}
Observe that \(s(t) = (t^2 + 1)^{3}\text{,}\) and thus by the chain rule, \(s'(t) = 3(t^2 + 1)^{4}(2t)\text{.}\) We therefore see that \(s'(1) = \frac{6}{16} = \frac{3}{8}\) inches per second, so the particle is moving left at the instant \(t = 1\text{.}\)