# Chain Rule

The **chain rule** is used to differentiate composite functions. Specifically, it allows us to use differentiation rules on more complicated functions by differentiating the inner function and outer function separately.

#### Contents

## Definition

The chain rule states that given a composite function \(f(g(x))\), its derivative is the derivative of the outer function (leaving the inner function unchanged and in place) multiplied by the derivative of the inner function. Concisely,

Chain Rule:\[\frac{d}{dx} f(g(x)) \equiv f'(g(x)) \cdot g'(x).\ _\square\]

The alternative statement of the chain in terms of function composition is \[(f \circ g)' = (f' \circ g) \cdot g'.\]

Let's see how it works by taking a look at some examples.

## Evaluate \(\frac{d}{dx} ( 2x + 1) ^ 2 \).

Let \( g(x) = 2x + 1 \) and \( f(x) = x^2 \). Then, \((2x+1)^2 = f(g(x))\). We know that \( g'(x) = 2 \) and \( f'(x) = 2x \). Hence, \[\begin{align} \frac{ d}{dx} (2x+1)^2 &= f'(g(x)) \cdot g'(x) \\ &= f' (2x+1) \cdot 2 \\ &= 2(2x+1) \cdot 2 \\ &= 8x+4.\ _\square \end{align}\]

## Evaluate \( \frac{d}{dx} e^{ x^2} \).

Let \( g(x) = x^2 \) and \( f(x) = e^x \). Then, \( e^{x^2} = f (g (x)) \). We know that \( g'(x) = 2x \) and \( f'(x) = e^x \). Hence,

\[\begin{align} \frac{ d}{dx} e^{x^2} &= f'(g(x)) \cdot g'(x) \\ &= f' (x^2) \cdot 2x \\ &= e^{x^2} \cdot 2x \\ &= 2xe^{x^2}.\ _\square \end{align}\]

## Find the derivative of \(\cos^5x\).

Let \(g(x)=\cos x\) and \(f(x)=x^5\). Then, \(\cos^5x=f(g(x))\). We know that \(g'(x)=-\sin x\) and \(f'(x)=5x^4\). Hence,

\[\begin{align} \frac{d}{dx} f(g(x)) &= f'(g(x)) \cdot g'(x) \\ &= f'(\cos x) \cdot (-\sin x) \\ &= -5\cos^4x\sin x.\ _\square \end{align}\]

## Proof

Then, how do we prove the chain rule? The proof goes as follows:

We begin by recalling the definition of differentiation:

\[\frac{d}{dx}f(x) = \lim_{\Delta x\rightarrow0}\frac{f(x+\Delta x)-f(x)}{\Delta x}.\]

We thus have

\[\begin{align} \frac{d}{dx} f(g(x)) &= \lim_{\Delta x \to 0} \dfrac{f(g(x+\Delta x))-f(g(x))}{\Delta x} \\ &= \lim_{\Delta x \to 0} \dfrac{f(g(x+\Delta x))-f(g(x))}{\Delta x} \cdot \dfrac{g(x+\Delta x)-g(x)}{g(x+\Delta x)-g(x)} \\ &= \lim_{\Delta x \to 0} \dfrac{f(g(x+\Delta x))-f(g(x))}{g(x+\Delta x)-g(x)} \cdot \lim_{a \to 0} \dfrac{g(x+\Delta x)-g(x)}{\Delta x} \\ &= \lim_{\Delta x \to 0} \dfrac{f(g(x+\Delta x))-f(g(x))}{g(x+\Delta x)-g(x)} \cdot g'(x). \end{align}\]

Making the substitution \(g(x+\Delta x)-g(x) = \Delta g\), we have \(\Delta g \to 0\) as \(\Delta x \to 0\), so

\[\begin{align} \frac{d}{dx} f(g(x)) &= \lim_{\Delta g \to 0} \dfrac{f(g(x)+\Delta g)-f(g(x))}{\Delta g} \cdot g'(x) \\ &= f'(g(x)) \cdot g'(x).\ _\square \end{align}\]

## Iterated Chain Rule

At times, we may need to apply the chain rule repeatedly in order to find the derivative. For example, if \(f(x) = \sqrt{\tan (x^3)}\), the inner function is itself a composite function.

In situations like this, we must apply the chain rule more than once. Specifically, for three functions composed, we have

\[\frac{d}{dx} f(g(h(x))) = f'(g(h(x)) \cdot g'(h(x)) \cdot h'(x).\]

This can easily be extended to any number of composed functions.

## Find the derivative of \(\sqrt{\tan(x^3)}\).

We begin by identifying the given function's basic parts, which we know how to differentiate. We can call \(\sqrt{\tan(x^3)} = f(g(h(x)))\), where \(f(x) = \sqrt{x}\), \(g(x) = \tan x\) and \(h(x) = x^3\).

We then have \( f'(x) = \frac{1}{2\sqrt{x}} \), \( g'(x) = \sec^2 x \) and \( h'(x) = 3x^2 \).

Applying the chain rule, we can see that \(\frac{d}{dx} \sqrt{\tan(x^3)} = f'(g(h(x))) \cdot \frac{d}{dx} g(h(x)) \). However, in order to find the derivative of \(g(h(x))\), we have to apply the chain rule again, which gives us the following:

\[\begin{align} \frac{d}{dx} \sqrt{\tan (x^3) } &= f'(g(h(x))) \cdot \frac{d}{dx} g(h(x)) \\ &= f'(g(h(x)) \cdot \Big[g'(h(x)) \cdot h'(x)\Big] \\ &= \frac{1}{2\sqrt{\tan \left(x^3\right)}} \cdot \sec^2\left(x^3\right) \cdot 3x^2 \\ &= \frac{3x^2 \sec^2\left(x^3\right)}{2\sqrt{\tan\left(x^3\right)}}.\ _\square \end{align}\]

For a harder challenge, try: