NOTE: You may view the original PDFs of the notes written in class by clicking on the link for the 1:30 Section or 2:30 Section, respectively.

Lecture 10: The Chain Rule

GOAL: Be able to differentiate functions of the form \( f(g(x)) \), like \( \sin(x^2) \) or \( e^{3x} \).

Summary:

\[ \begin{gathered} [f(g(x))]' = f'(g(x)) \cdot g'(x) \\[0.5em] \frac{d}{dx}[f(g(x))] = \frac{df}{dg} \cdot \frac{dg}{dx} \\[0.5em] [g(x)^p]' = p[g(x)]^{p-1} \cdot g'(x) \\[0.5em] [b^x]' = b^x \cdot \ln b \\[0.5em] [\sin(\theta^\circ)]' = \tfrac{\pi}{180}\cos(\theta^\circ) \end{gathered} \]

Theorem (Chain Rule)

Let \( f \) and \( g \) be differentiable functions. Then

\[ \begin{gathered} \text{Format I:}\quad \frac{d}{dx}(f \circ g) =& \frac{df}{dg} \cdot \frac{dg}{dx} \\[0.5em] \text{Format II:}\quad [f(g(x))]' =& f'(g(x)) \cdot g'(x) \end{gathered} \]

We will show how the Chain Rule is used in both formats. That being said, use the one that is most advantageous for the problem you are working on. Or at least, the one that is easier to understand and memorize.

We give a easy and intuitative "proof" of the Chain Rule:

\begin{align*} \dfrac{d(f \circ g)}{dx} =&~ \lim_{\Delta x \to 0}\dfrac{\Delta f(g(x))}{\Delta x}\\[0.5em] =&~ \lim_{\Delta x \to 0}\frac{\Delta f(g(x))}{\Delta g(x)}\cdot \frac{\Delta g(x)}{\Delta x}\\[0.5em] =&~ \left[\lim_{\Delta x \to 0} \frac{\Delta f(g(x))}{\Delta g(x)} \right]\cdot \left[\lim_{\Delta x \to 0} \frac{\Delta g(x)}{\Delta x}\right]~(g\text{ is continuous, so }\Delta g \to 0\text{ as }\Delta x \to 0)\\[0.5em] =&~ \left[\lim_{\Delta g \to 0} \frac{\Delta f(g(x))}{\Delta g(x)} \right]\cdot \left[\lim_{\Delta x \to 0} \frac{\Delta g(x)}{\Delta x}\right]\\[0.5em] =&~ \dfrac{df}{dg}\cdot\dfrac{dg}{dx} \end{align*}

This, unfortunately, is invalid since it is possible to have \(\Delta g(x) = 0\) even if \(\Delta x \neq 0\) (hence, we are dividing by \(0\)). There is a way around this, but that is way too technical for our purposes today. We just want to apply the Chain Rule.

Example 1

We already know:

\[ \frac{d}{dx}\left(x^{\frac{3}{2}}\right) = \frac{3}{2}x^{\frac{1}{2}} \]

But, let's differentiate it by writing it as \(x^{\frac{3}{2}} = \left[x^{\frac{1}{2}}\right]^3\). To get used to using the Chain Rule, we break the function into two "layers;" the outside function \(f\) and the inside function \(g\). Looking at how we get \(f(x) = x^{3/2}\), we see the very last step is cubing everything:

\[ x \mapsto x^{\frac{1}{2}} \mapsto \left(x^{\frac{1}{2}}\right)^3 = f(g(x)) \]

So, everything except the cube will be \(g(x)\). I.e., \(g(x) = x^{\frac{1}{2}}\). We now want to find \(f(g)\), meaning we rewrite our function \(f\) as a function of \(g\). Doing so, we get \(f(g) = g^3\). With this in mind,

\begin{align*} \text{Format I:}\quad \frac{df}{dx} =&~ \frac{df}{dg} \cdot \frac{dg}{dx} \\[0.5em] =&~ \frac{d}{dg}\left(g^3\right) \cdot \frac{d}{dx}\left(x^{\frac{1}{2}}\right) \\[0.5em] =&~ 3g^2\cdot \frac{1}{2}x^{-\frac{1}{2}}\\[0.5em] =&~ 3\left(x^{\frac{1}{2}}\right)^2 \cdot\frac{1}{2}x^{-\frac{1}{2}} \\[0.5em] =&~\frac{3}{2}x^{\frac{1}{2}} \end{align*} \begin{align*} \text{Format II:}\quad\left[\left(x^{\frac{1}{2}}\right)^3\right]' =&~ f'(g) \cdot g' \\[0.5em] =&~ \underbrace{\left[g^3\right]'}_{\text{w.r.t. } g} \cdot \underbrace{\left[x^{\frac{1}{2}}\right]'}_{\text{w.r.t. } x} \\[0.5em] =&~ 3g^2 \cdot \frac{1}{2}x^{-\frac{1}{2}}\\[0.5em] =&~ 3\left(x^{\frac{1}{2}}\right)^2 \cdot\frac{1}{2}x^{-\frac{1}{2}} \\[0.5em] =&~ \frac{3}{2}x^{\frac{1}{2}} \end{align*}

NOTE:

This gives us a way to show the Power Rule holds if the exponent is rational. We check that that it holds for \(x^{\frac{1}{n}}\) where \(n\) is a non-zero integer and \(x\) is in the domain of the function. We note that this function is not differentiable at 0 (you can check using the limit definition of the derivative), so we may assume \(x\neq 0\). \begin{align*} x =&~ \left(x^{1/n}\right)^n \\[0.5em] \dfrac{d}{dx}(x) =&~ \dfrac{d}{dx}\left(x^{1/n}\right)^n \\[0.5em] 1 =&~ n\left( x^{1/n} \right)^{n-1} \cdot \dfrac{d}{dx}\left( x^{1/n}\right)\\[0.5em] 1 =&~ n x^{1 - \frac{1}{n}}\cdot \dfrac{d}{dx}\left( x^{1/n}\right)\\[0.5em] \dfrac{d}{dx}\left( x^{1/n}\right) =&~ \frac{1}{n x^{1 - \frac{1}{n}}}\\[0.5em] \dfrac{d}{dx}\left( x^{1/n}\right) =&~ \frac{1}{n }x^{\frac{1}{n}-1} \\[0.5em] \end{align*} Now, for any fractional exponent \(\frac{m}{n}\), we can write

\[ x^{\frac{m}{n}} = \left(x^{\frac{1}{n}}\right)^m \]

and we can do something very similar to Example 1.

Example 2

Find \(\left[(\sin x)^2\right]'\).

As with Example 1, we write \(g(x) = \sin x\) and \(f(g) = g^2\).

\begin{align*} \text{Format I:}\quad \frac{df}{dx} =&~ \frac{df}{dg} \cdot \frac{dg}{dx}\\[0.5em] =&~ \frac{d}{dg}\left(g^2\right) \cdot \frac{d}{dx}(\sin x) \\[0.5em] =&~ 2g \cos x\\[0.5em] =&~ 2\sin x \cos x \end{align*} \begin{align*} \text{Format II:}\quad \left[(\sin x)^2\right]' =&~ f'(g(x)) \cdot g'(x) \\[0.5em] =&~\underbrace{\left[g^2\right]'}_{\text{w.r.t. } g} \cdot \underbrace{\left[\sin x\right]'}_{\text{w.r.t. } x} \\[0.5em] =&~ 2g \cos x\\[0.5em] =&~ 2\sin x \cos x \end{align*}

Example 3

Find \(y'\) if \(y=e^{x^2+x+1}\).

As with the previous examples, \(g(x) = x^2+x+1\) and \(f(g) = e^g\). So, by the Chain Rule:

\begin{align*} \frac{dy}{dx} =&~ \frac{d}{dg}\left(e^g\right) \cdot \frac{d}{dx}\left(x^2+x+1\right)\\[0.5em] =&~ e^g \cdot (2x+1) \\[0.5em] =&~ (2x+1)e^{x^2+x+1} \end{align*}

NOTE:

It is very common to skip the step of writing \( f \) as a function of \( g \). For example, in repeating Example 3 using Format II.

\[ \begin{gathered} \left[e^{x^2+x+1}\right]' = \underbrace{\left[e^{x^2+x+1}\right]'}_{\text{w.r.t. } "x^2+x+1"} \cdot \underbrace{\left[x^2+x+1\right]'}_{\text{w.r.t. } x} \\[0.5em] = e^{x^2+x+1}(2x+1) \end{gathered} \]

Here, we treat \(x^2 + x + 1\) as a single variable or block, then part of the Chain Rule is differentiating the outside function \(f\) with respect to that block.

Example 4

Differentiate \(w(x) = \tan\left(\cos\left(x^2\right)\right)\).

This is an example of a function with three "layers:"

\[ x \mapsto x^2 \mapsto \cos\left(x^2\right) \mapsto \tan( \cos\left(x^2\right)) \]

We need two layers to do the Chain Rule. However, like what we saw with the Product Rule, we can handle a situation like this. Though, we need to perform the Chain Rule twice.

\begin{align*} w'(x) =&~\sec^2\left(\cos\left(x^2\right)\right) \cdot \left[\cos\left(x^2\right)\right]' \\[0.5em] =&~\sec^2\left(\cos\left(x^2\right)\right) \cdot -\sin\left(x^2\right) \cdot \left[x^2\right]' \\[0.5em] =&~\sec^2\left(\cos\left(x^2\right)\right) \cdot -\sin\left(x^2\right) \cdot 2x \\[0.5em] =&~-2x\sin\left(x^2\right)\sec^2\left(\cos\left(x^2\right)\right) \end{align*}

NOTE: ("Peeling the Onion" Analogy)

One way of interpreting the Chain Rule is as follows:

  1. Idenity the outermost layer ("outer function") of the function.
  2. Differentiate that outermost layer, while keeping the core (the "inside function") untouched.
  3. Shed the outermost layer.
  4. Repeat until you run out of layers. In the previous example, the last layer is \(x^2\). The last layer should not be a composition of functions.

Applications of The Chain Rule

Example 5

Differentiate \( y = \left(x^3-1\right)^{100} \)

\[ \begin{gathered} y' = 100\left(x^3-1\right)^{99} \cdot \left[x^3-1\right]' = 100\left(x^3-1\right)^{99}\left(3x^2\right) \\[0.5em] = 300x^2\left(x^3-1\right)^{99} \end{gathered} \]

Theorem (Generalized Power Rule)

Let \( g \) be a differentiable function and \( p \) any real number. Then

\[ \left[\left(g(x)\right)^p\right]' = p\left(g(x)\right)^{p-1} \cdot g'(x) \]

If \( g(x) = x \), this is the usual power rule.

Example 6

Let \( R > 0 \) be constant. The semicircle of radius \( R \) is given by

\[ y = \sqrt{R^2-x^2} \]
Sketch of a semicircle of radius R above a horizontal axis from -R to R with height R
Figure 1
A freehand sketch of a semicircle drawn above a horizontal axis with arrowheads at both ends. The semicircle meets the axis at two marked points labeled \( -R \) on the left and \( R \) on the right. A vertical segment is drawn from the axis up to the top of the arc, and its height is labeled \( R \) at the top. The curve represents the graph of \( y = \sqrt{R^2-x^2} \).

Find \( y' \)

\[ \begin{gathered} y' = \left[\sqrt{R^2-x^2}\right]' = \left[\left(R^2-x^2\right)^{\frac{1}{2}}\right]' \\[0.5em] = \frac{1}{2}\left(R^2-x^2\right)^{-\frac{1}{2}} \cdot \left[R^2-x^2\right]' \\[0.5em] = \frac{1}{2}\left(R^2-x^2\right)^{-\frac{1}{2}} \cdot (-2x) = \ldots = \frac{-x}{\sqrt{R^2-x^2}} \end{gathered} \]

Example 7

What's \( \frac{d}{dx}\left(2^x\right) \)?

\[ \left[2^x\right]' = \left[e^{\ln\left(2^x\right)}\right]' = \left[e^{x(\ln 2)}\right]' = e^{x(\ln 2)} \cdot \ln 2 = 2^x \cdot \ln 2 \]

In general, if \( b > 0 \),

\[ \frac{d}{dx}\left(b^x\right) = b^x \cdot \ln(b) \]

Example 8 (Dampened Pendulum)

A pendulum's position is measured from its angle (in radians) from its resting point. Its position function is given by:

\[ s(t) = e^{-t}\cos t \]
Sketch of a pendulum hanging at an angle s from its vertical resting position
Figure 2
A small freehand sketch of a pendulum. A straight line descends diagonally from a pivot point at the upper left to a small open circle representing the pendulum bob at the lower right. A dashed vertical line drops from the pivot indicating the resting position, and the angle between the dashed vertical and the pendulum rod is labeled s.

Find \( v(t) \)

\begin{align*} v(t) = s'(t) =&~ \left[e^{-t}\right]'\cos t + e^{-t}\left[\cos t\right]' \\[0.5em] =&~ -e^{-t}\cos t + e^{-t}\left(-\sin t\right) \\[0.5em] =&~ \left[-e^{-t}\left(\cos t + \sin t\right)\right] \frac{\text{rad}}{\text{s}} \end{align*}

Example 9

The radius of a circle is evolving over time, how fast is the area changing as a function of time?

Hand-drawn circle with a radius segment labeled r from the center
Figure 3
A roughly drawn circle with a dot marking its center. A straight line segment extends from the center dot up and to the right toward the circle boundary, labeled r to indicate the radius.

The area of a circle is a function of its radius, namely:

\[A = \pi r^2\] Since \(r = r(t)\) is a function of time, the composition \(A(r(t))\) describes the area of the circle at time \(t\). We want to find a formula for \(\displaystyle \dfrac{dA}{dt}\), so we need to use the Chain Rule to handle that composition. \begin{align*} A =&~ \pi r^2 \\[0.5em] A(t) =&~\pi\left[r(t)\right]^2 \\[0.5em] \frac{dA}{dt} =&~ \pi\,2\left[r(t)\right]\frac{dr}{dt}\\[0.5em] \frac{dA}{dt} =&~ 2\pi r \frac{dr}{dt} \end{align*} In other words, the derivative of the area is a function of both the radius and the derivative of the radius.

Example 10 (One of the reasons we don't use degrees for angles)

Recall \(\pi\text{ radians} = 180^\circ\), or in other words, \(1^\circ\) is \(\frac{\pi}{180}\) radians. All of the derivative formulas for the trig functions assumed the angle was in radians. So, if \(x^\circ\) is measured in degrees, in order to take the derivative of \(\sin(x^\circ)\) we need to convert the angle into radians: \[ \sin\left(x^\circ\right) = \sin\left(\underbrace{\frac{\pi}{180}x}_{\text{radians}}\right) \] Taking the derivative we get: \[ \left[\sin\left(x^\circ\right)\right]' = \left[\sin\left(\frac{\pi}{180}x\right)\right]' = \cos\left(\frac{\pi}{180}x\right)\cdot\frac{\pi}{180} = \frac{\pi}{180}\cos\left(x^\circ\right) \] So, not only was taking the derivative more work, we now have a bunch of constants muddying up our equations when we didn't have that when the angle was in radians. This is also why, for example, we also use base \(e\) for exponential functions and the natural log for logarithmic functions.