The Chain Rule

Read this section to learn about the Chain Rule. Work through practice problems 1-8.

Chain Rule ( composition form)

If \mathrm{g} is differentiable at x and \mathrm{f} is differentiable at \mathrm{g}(\mathrm{x}),

then the composite f \circ g is differentiable at x, and (f \circ g)^{\prime}(x)=D(f(g(x)))=f^{\prime}(g(x)) \cdot g^{\prime}(x).

You may find it easier to think of the composition form of the Chain Rule in words:

\left(\mathrm{f}(\mathrm{g}(\mathrm{x}))^{\prime}=\right. "the derivative of the outside function (with respect to the original inside function) times the derivative of the inside function" where \mathrm{f} is the outside function and \mathrm{g} is the inside function.


Example 4: Differentiate \sin \left(x^{2}\right).

Solution: The function \sin \left(x^{2}\right) is the composition f \circ gof two simple functions: f(x)=\sin (x) and g(x)=x^{2}: f \circ g(x)=f(g(x))=f\left(x^{2}\right)=\sin \left(x^{2}\right) which is the function we want. Both f and g are differentiable functions with derivatives f^{\prime}(x)=\cos (x) and g^{\prime}(x)=2 x, so, by the Chain Rule,

\begin{align*}
\mathrm{D}\left(\sin \left(x^{2}\right)\right)=(f \circ g)^{\prime}(x)=f^{\prime}(g(x)) \cdot g^{\prime}(x)=\cos (g(x)) \cdot 2 x=\cos \left(x^{2}\right) \cdot 2 x=2 x \cos \left(x^{2}\right)
\end{align*}

If you tried using the definition of derivative to calculate the derivative of this function at the beginning of the section, you can really appreciate the power of the Chain Rule for differentiating compositions.

Example 5: 

The table gives values for f, f^{\prime}, g and g' at a number of points. Use these values to determine ( f \circ g )(x) and (f \circ g) '(x) at x=-1 and 0.

  x f(x) g(x) f '(x) g '(x) ( f \circ g )(x) ( f \circ g )'(x)
  –1 2 3 1 0    
0 –1 1 3 2    
1 1 0 –1 3    
2 3 –1 0 1    
3 0 2 2 –1    

Solution: ( f \circ g)(-1)=\mathrm{f}(\mathrm{g}(-1))=\mathrm{f}(3)=0 and ( f \circ g)(0)=\mathrm{f}(\mathrm{g}(0))=\mathrm{f}(1)=1

(f \circ g)^{\prime}(-1)=\mathbf{f}^{\prime}(g(-1)) \cdot g^{\prime}(-1)=f^{\prime}(3) \cdot(0)=(2)(0)=0 and

(f \circ g) '(0)=f^{\prime}(g(0)) \cdot g^{\prime}(0)=f^{\prime}(1) \cdot(2)=(-1)(2)=-2


Practice 3: Fill in the table in Example 5 for ( f \circ g )(x) and ( f \circ g ) '(x) at x = 1, 2 and 3.

Neither form of the Chain Rule is inherently superior to the other - use the one you prefer. The Chain Rule will be used hundreds of times in the rest of this book, and it is important that you master its usage. The time you spend now mastering and understanding how to use the Chain Rule will be paid back tenfold in the next several chapters.

Example 6: Determine \mathbf{D}\left(\mathrm{e}^{\cos (\mathrm{x})}\right) using each form of the Chain Rule.

Solution: Using the Leibniz notation: \mathrm{y}=\mathrm{e}^{\mathrm{u}} and \mathrm{u}=\cos (\mathrm{x}) . \mathrm{dy} / \mathrm{du}=\mathrm{e}^{\mathrm{u}} and \mathrm{du} / \mathrm{dx}=-\sin (\mathrm{x}) so \mathrm{dy} / \mathrm{dx}=(\mathrm{dy}
    / \mathrm{du}) \cdot(\mathrm{du} / \mathrm{dx})=\left(\mathrm{e}^{\mathrm{u}}\right) \cdot(-\sin (\mathrm{x}))=-\sin (\mathrm{x}) \cdot \mathrm{e}^{\cos (\mathrm{x})}

The function e^{\cos (x)} is also the composition of \mathrm{f}(\mathrm{x})=\mathrm{e}^{\mathrm{x}} with \mathrm{g}(\mathrm{x})=\cos (\mathrm{x}), so

\mathbf{D}\left(\mathrm{e}^{\cos (\mathrm{x})}\right)=\mathrm{f}^{\prime}(\mathrm{g}(\mathrm{x})) \cdot \mathrm{g}^{\prime}(\mathrm{x}) by the Chain Rule

=e^{g(x)} \cdot(-\sin (x)) since D\left(e^{x}\right)=e^{x} and \mathbf{D}(\cos (x))=-\sin (x)

=-\sin (x) \cdot e^{\cos (x)}

Practice 4: \quad Calculate \mathbf{D}(\sin (7 \mathrm{x}-1)), \frac{\mathbf{d}}{\mathbf{d x}}(\sin (a x+b)), and \frac{\mathbf{d}}{d t}\left(\mathrm{e}^{3 t}\right) .

Practice 5: Use the graph of \mathrm{g} in Fig. 1 and the Chain Rule to estimate \mathbf{D}(\sin (\mathrm{g}(\mathrm{x}))) and \mathbf{D}(\mathrm{g}(\sin (\mathrm{x}))) at \mathrm{x}=\pi


The Chain Rule is a general differentiation pattern, and it can be used with the other general patterns such as the Product and Quotient Rules.

Example 7: \quad Determine \mathbf{D}\left(\mathrm{e}^{3 \mathrm{x}} \cdot \sin (5 \mathrm{x}+7)\right) and \frac{\mathbf{d}}{\mathbf{d x}}\left(\cos \left(\mathrm{x} \cdot \mathrm{e}^{\mathrm{x}}\right)\right)

Solution: (a) \mathrm{e}^{3 \mathrm{x}} \sin (5 \mathrm{x}+7) is a product of two functions so we need the product rule first:

\begin{align*}
\begin{aligned}
&D\left(e^{3 x} \cdot \sin (5 x+7)\right)=e^{3 x} \cdot D(\sin (5 x+7))+\sin (5 x+7) \cdot D\left(e^{3 x}\right) \\
&=e^{3 x} \cos (5 x+7) \cdot 5+\sin (5 x+7) e^{3 x} \cdot 3=5 e^{3 x} \cos (5 x+7)+3 e^{3 x} \sin (5 x+7)
\end{aligned}
\end{align*}

(b) \cos \left(x \cdot e^{x}\right) is a composition of cosine with a product so we need the Chain Rule first:

\begin{align*}
\begin{aligned}
\frac{d}{d x}\left(\cos \left(x \cdot e^{x}\right)\right) &=-\sin \left(x \cdot e^{x}\right) \cdot \frac{d}{d x}\left(x \cdot e^{x}\right) \\
&=-\sin \left(x e^{x}\right) \cdot\left\{x \cdot \frac{d}{d x}\left(e^{x}\right)+e^{x} \cdot \frac{d}{d x}(x)\right\}=-\sin \left(x e^{x}\right) \cdot\left\{x e^{x}+e^{x}\right\}
\end{aligned}
\end{align*}

Sometimes we want to differentiate a composition of more than two functions. We can do so if we proceed in a careful, step-by-step way.

Example 8: Find \mathbf{D}\left(\sin \left(\sqrt{\mathrm{x}^{3}+1}\right)\right)

Solution: The function \sin \left(\sqrt{x^{3}+1}\right) can be considered as a composition fog of \mathrm{f}(\mathrm{x})=\sin (\mathrm{x}) and \mathrm{g}(\mathrm{x})=\sqrt{\mathrm{x}^{3}+1}. Then

\left(\sin \left(\sqrt{x^{3}+1}\right)\right)^{\prime}=f^{\prime}(g(x)) \cdot g^{\prime}(x)=\cos (g(x)) \cdot g^{\prime}(x)=\cos \left(\sqrt{x^{3}+1}\right) D\left(\sqrt{x^{3}+1}\right)

For the derivative of \sqrt{x^{3}+1}, we can use the Chain Rule again or its special case, the Power Rule: D \left(\sqrt{x^{3}+1}\right)=\mathbf{D}\left(\left(x^{3}+1\right)^{1 / 2}\right)=\frac{1}{2}\left(x^{3}+1\right)^{-1 / 2} \mathrm{D}\left(x^{3}+1\right)=\frac{1}{2}\left(x^{3}+1\right)^{-1 / 2} 3 x^{2}

Finally, \left(\sin \left(\sqrt{x^{3}+1}\right)\right)^{\prime}=\cos \left(\sqrt{x^{3}+1}\right) D\left(\sqrt{x^{3}+1}\right)

\begin{align*}
=\cos \left(\sqrt{x^{3}+1}\right) \frac{1}{2}\left(x^{3}+1\right)^{-1 / 2}\left(3 x^{2}\right)=\frac{3 x^{2} \cos \left(\sqrt{x^{3}+1}\right)}{2 \sqrt{x^{3}+1}}
\end{align*}

This example was more complicated than the earlier ones, but it is just a matter of applying the Chain Rule twice, to a composition of a composition.  If you proceed step–by–step and don't get lost in the problem, these multiple applications of the Chain Rule are relatively straightforward.  

We can also use the Leibniz form of the Chain Rule for a composition of more than two functions.  If 

\mathrm{y}=\sin \left(\sqrt{\mathrm{x}^{3}+1}\right), then \mathrm{y}=\sin (\mathrm{u}) with \mathrm{u}=\sqrt{\mathrm{w}} \quad and \mathrm{w}=\mathrm{x}^{3}+1. The Leibniz form of the Chain Rule is \frac{\mathrm{dy}}{\mathrm{dx}}=\frac{\mathrm{dy}}{\mathrm{du}} \cdot \frac{\mathrm{du}}{\mathrm{dw}} \cdot \frac{\mathrm{d} \mathrm{w}}{\mathrm{dx}}, so \frac{\mathrm{dy}}{\mathrm{dx}}=\cos (\mathrm{u}) \frac{1}{2 \sqrt{\mathrm{w}}} 3 \mathrm{x}^{2}=\cos \left(\sqrt{\mathrm{x}^{3}+1}\right) \cdot \frac{1}{2 \sqrt{\mathrm{x}^{3}+1}} \cdot 3 \mathrm{x}^{2}.

Practice 6:

(a) Find \mathrm{D}(\sin (\cos (5 \mathrm{x}))).

(b) For y=e^{\cos (3 x)}, find d y / d x.