# Chain Rule

Page

You probably remember the derivatives of $\sin (x)$, $x^{8}$, and $e^{x}$. But what about functions like $\sin (2x-1)$, $(3x^{2}-4x+1)^{8}$, or $e^{-x^{2}}$? How do we take the derivative of compositions of functions?

Compositions of Functions
Compositions of Functions

The composition $f(g(x))$, often denoted by $f\circ g$, of functions $f$ and $g$ is the function obtained by applying the function $f$ to $g(x)$.

The Chain Rule allows us to use our knowledge of the derivatives of functions $f(x)$ and $g(x)$ to find the derivative of the composition $f(g(x))$:

Suppose a function $g(x)$ is differentiable at $x$ and $f(x)$ is differentiable at $g(x)$. Then the composition $f(g(x))$ is differentiable at $x$.

Letting $y=f(g(x))$ and $u=g(x)$, $$\frac{dy}{dx}=\frac{dy}{du}\cdot\frac{du}{dx}.$$ Using alternative notation, \begin{eqnarray*} \frac{d}{dx}\left[ f(g(x)) \right] & = & f'(g(x))g'(x), \\ \frac{d}{dx}\left[ f(u) \right] & = & f'(u)\frac{du}{dx}. \end{eqnarray*}

Proof of the Chain Rule
Proof of the Chain Rule

Let $g(x)$ be differentiable at $x$ and $f(x)$ be differentiable at $g(x)$. Let $y = f(g(x))$ and $u=g(x)$.

We will use the fact that if $y=h(x)$ is differentiable at $x$ then $$\Delta y = h'(x) \Delta x + \varepsilon \Delta x$$ where $\varepsilon \rightarrow 0$ as $\Delta x \rightarrow 0$. We have that \begin{eqnarray*} \Delta u & = & g'(x) \Delta x + \varepsilon_1 \Delta x \mbox{ where } \varepsilon_1 \rightarrow 0 \mbox{ as } \Delta x \rightarrow 0,\\ \Delta y & = & f'(u) \Delta u + \varepsilon_2 \Delta u \mbox{ where } \varepsilon_2 \rightarrow 0 \mbox{ as } \Delta u \rightarrow 0. \end{eqnarray*} Substituting $\Delta u$ from the first equation into the second, $$\frac{\Delta y}{\Delta x} = \left[ f'(u) + \varepsilon_2 \right] \left[ g'(x) + \varepsilon_1 \right].$$ Taking the limit as $\Delta x \rightarrow 0$, \begin{eqnarray*} \frac{dy}{dx} & = & f'(u) \cdot g'(x) \\ & = & \frac{dy}{du} \cdot \frac{du}{dx} \end{eqnarray*} (taken from Calculus, by Howard Anton.)

The three formulations of the Chain Rule given here are identical in meaning. In words, the derivative of $f(g(x))$ is the derivative of $f$, evaluated at $g(x)$, multiplied by the derivative of $g(x)$.

###### Examples
• To differentiate $\sin (2x-1)$, we identify $u=2x-1$. Then

\begin{eqnarray*} \frac{d}{dx}\left[ \sin(2x-1)\right] & = & \frac{d}{du} \left[ \sin (u) \right] \cdot \frac{d}{dx} \left[ 2x-1 \right] \\ & = & \cos (u) \cdot 2 \\ & = & 2 \cos (2x-1). \end{eqnarray*}

\begin{eqnarray*} f(x) & = & \sin (x) \\ g(x) & = & 2x-1 \\ f(g(x)) & = & \sin (2x-1) \end{eqnarray*}

• To differentiate $\left( 3x^{2} – 4x + 1 \right)^{8}$, we identify $u=3x^2-4x+1$. Then

\begin{eqnarray*} \frac{d}{dx} \left[\left( 3x^{2} – 4x + 1 \right)^{8}\right] & = & \frac{d}{du}\left[ u^8 \right] \cdot \frac{d}{dx}\left[ 3x^2-4x+1 \right] \\ & = & 8u^7 \cdot (6x-4) \\ & = & 8 (6x-4)\left( 3x^{2} – 4x + 1 \right)^{7}. \end{eqnarray*}

\begin{eqnarray*} f(x) & = & x^8 \\ g(x) & = & 3x^{2} – 4x + 1 \\ f(g(x)) & = & \left( 3x^{2} – 4x + 1 \right)^{8} \end{eqnarray*}

• To differentiate $e^{-x^{2}}$, we identify $u=-x^{2}$. Then

\begin{eqnarray*} \frac{d}{dx} \left[ e^{-x^{2}} \right] & = & \frac{d}{du}\left[ e^u \right] \cdot \frac{d}{dx}\left[ -x^2 \right] \\ & = & e^u \cdot (-2x) \\ & = & -2xe^{-x^2}. \end{eqnarray*}

\begin{eqnarray*} f(x) & = & e^x \\ g(x) & = & -x^2 \\ f(g(x)) & = & e^{-x^{2}} \end{eqnarray*}

Sometimes you will need to apply the Chain Rule several times in order to differentiate a function.

###### Example

We will differentiate $\sqrt{\sin^{2} (3x) + x}$. $$\begin{array}{rclc} \frac{d}{dx}\left[ \sqrt{\sin^{2} (3x) + x}\right] & = & \frac{1}{2\sqrt{\sin^{2} (3x) + x}} \cdot \frac{d}{dx}\left[ \sin^{2} (3x) + x \right] & f(u) = \sqrt{u}\\ & = & \frac{1}{2\sqrt{\sin^{2} (3x) + x}} \cdot \left( 2 \sin (3x) \frac{d}{dx} \left[ \sin (3x) \right] + 1 \right) & \begin{array}{rcl} f(u) & = & u^2 \\ \frac{d}{dx} [x] & = & 1 \end{array} \\ & = & \frac{1}{2\sqrt{\sin^{2} (3x) + x}} \cdot \left( 2 \sin (3x) \cos (3x) \frac{d}{dx} [3x] + 1 \right) & f(u) = \sin (u) \\ & = & \frac{1}{2\sqrt{\sin^{2} (3x) + x}} \cdot \left( 2 \sin (3x) \cos (3x) \cdot 3 + 1 \right) \\ & = & \displaystyle\frac{6 \sin (3x) \cos (3x) + 1}{2\sqrt{\sin^{2} (3x) + x}} \end{array}$$

#### Key Concepts

Let $g(x)$ be differentiable at $x$ and $f(x)$ be differentiable at $f(g(x))$. Then, if $y=f(g(x))$ and $u=g(x)$, $$\frac{dy}{dx} = \frac{dy}{du}\cdot\frac{du}{dx}.$$