Derivative Chain Rule

# The Chain Rule

 Theorem 1 (The Chain Rule): If $f$ is a differentiable function that is a composition of two other functions $g$ and $h$ such that $f(x) = g(h(x)) = f \circ g (x)$, then $f'(x) = g'(h(x)) \cdot h'(x)$. Written in Leibniz notation, if $u = h(x)$ and $y = g(h(x))$, then $\frac{dy}{dx} = \frac{dy}{du} \cdot \frac{du}{dx}$.

We will not prove the chain rule at this time since the various proofs are rather complicated, but rather, skip directly into some examples.

## Example 1

Differentiate the function $f(x) = \sin (x^2 - 3x)$.

In this case we have a composite function. Our "inner" function can be seen as $x^2 - 3x$, while our outer function can be seen as $\sin x$. Thus we can apply the chain rule for differentiation:

(1)
\begin{align} \quad \frac{d}{dx} f(x) = \frac{d}{dx}g(h(x)) \cdot \frac{d}{dx} h(x) \\ \frac{d}{dx} f(x) = \cos(x^2 - 3x) \cdot (2x - 3) \end{align}

## Example 2

Differentiate the function $f(x) = (3x - 2)^2$.

In this case, we have a composite function again since the inner function is $3x - 2$, and the outer function is $x^2$. However, we do not necessarily need the chain rule to find the derivative of $f$ as we can expand and then differentiate this function as a polynomial. For example:

(2)
\begin{align} f(x) = (3x - 2)(3x - 2) \\ f(x) = 9x^2 -12x + 4 \\ \frac{d}{dx} f(x) = 18x - 12 \end{align}

Let's use the chain rule to see if we get the same result:

(3)
\begin{align} \quad \frac{d}{dx} f(x) = \frac{d}{dx}g(h(x)) \cdot \frac{d}{dx} h(x) \\ \frac{d}{dx} f(x) = 2(3x - 2)^1 \cdot 3 \\ \frac{d}{dx} f(x) = (6x - 4)(3) \\ \frac{d}{dx} f(x) = 18x - 12 \end{align}

Thus we get the same answer. Note that the first method is easier because the exponent is only to the power of 2, but sometimes we cannot expand easily as seen in the next example.

## Example 3

Differentiate the function $f(x) = (x^3 - 5x^2 + 7x)^{100}$.

Clearly this function can be expanded easily, so we will need to apply the chain rule to find the derivative:

(4)
\begin{align} \quad \frac{d}{dx} f(x) = \frac{d}{dx}g(h(x)) \cdot \frac{d}{dx} h(x) \\ \quad \frac{d}{dx} f(x) = 100(x^3 - 5x^2 + 7x)^{99} \cdot (3x^2 - 10x + 7) \end{align}

# The Chain Rule of a Function of Many Compositions

Suppose we have a function f(x) in the general form:

(5)
\begin{align} \: f(x) = g_{1}(g_{2}(g_{3}(...g_{k}(x)))) \quad \mathbf{or} \quad f(x) = g_{1} \circ g_{2} \circ g_{3} ... \circ g_{k} (x) \end{align}

The great thing is that we can still apply the chain rule. Let's first look at the case in which we have three functions forming a composite, namely $g_1, g_2, g_2$. Therefore:

(6)
\begin{align} f(x) = g_{1}(g_{2}(g_{3}(x))) \quad \mathbf{or} \quad f(x) = g_{1} \circ g_{2} \circ g_{3} (x) \end{align}

Now let's let $h(x) = g_2(g_3(x))$. Thus $f(x) = g_1(h(x))$, and we can solve this by using the chain rule:

(7)
\begin{align} \quad \frac{d}{dx} f(x) = \frac{d}{dx}g_{1}(h(x)) \cdot \frac{d}{dx} h(x) \\ \end{align}

Notice that we can substitute $h(x) = g_2(g_3(x))$ back into our derivative equation to obtain:

(8)
\begin{align} \quad \frac{d}{dx} f(x) = \frac{d}{dx}g_{1}(g_{2}(g_{3}(x))) \cdot \frac{d}{dx} (g_{2}(g_{3}(x))) \\ \end{align}

But now we need to simplify the expression for the derivative of h(x) = g_2(g_3(x)) . We can simply apply the chain rule again to obtain:

(9)
\begin{align} \quad \frac{d}{dx} f(x) = \frac{d}{dx}g_{1}(g_{2}(g_{3}(x))) \cdot \frac{d}{dx} g_{2}(g_{3}(x)) \cdot \frac{d}{dx} g_{3}(x) \\ \end{align}

We should be able to notice that there is a pattern with successive components of this derivative. This equation says that the derivative of $f(x)$ is equal to the derivative of $g_1$ with respect to $g_2$ with respect to $g_3$ multiplied by the derivative of $g_2$ with respect to $g_3$ multiplied by the derivative of $g_3$. In fact, it follows that a function with $k$ compositions has its derivative being equal to:

(10)
\begin{align} \quad \frac{d}{dx} f(x) = \frac{d}{dx} g_{1}(g_{2}(g_{3}(... g_{k}(x)) \cdot \frac{d}{dx} g_{2}(g_{3}(... g_{k}(x)) \cdot ... \cdot \frac{d}{dx} g_{k-1}(g_{k}(x)) \cdot \frac{d}{dx} g_{k}(x) \end{align}