5.3 Chain Rule

The chain rule is the rule of differentiation for the composition of two or more functions. It is used to find the derivative of a composite function $h(x) = f(g(x))$.

The chain rule states that the derivative of $h(x)$ is the derivative of the outer function evaluated at the inner function, multiplied by the derivative of the inner function:

$h'(x) = f'(g(x)) \cdot g'(x)$

EXAMPLE 1

Let $h(x) = \sin(2x^2+3)$.

  • Inner function: $g(x) = 2x^2+3 \implies g'(x) = 4x$
  • Outer function: $f(u) = \sin u \implies f'(u) = \cos u$
By the chain rule: $$ \begin{aligned} h'(x) &= f'(g(x)) \cdot g'(x) \\ &= \cos(2x^2+3) \cdot (4x) \\ &= \mathbf{4x \cos(2x^2+3)} \end{aligned} $$

EXAMPLE 2

Let $h(x) = e^{5x+3}$.

  • Inner function: $g(x) = 5x+3 \implies g'(x) = 5$
  • Outer function: $f(u) = e^u \implies f'(u) = e^u$
By the chain rule: $$ h'(x) = f'(g(x)) \cdot g'(x) = e^{5x+3} \cdot 5 = \mathbf{5e^{5x+3}} $$ We can find the second derivative as well (inner function is again $5x+3$): $$ h''(x) = 5 \cdot e^{5x+3} \cdot 5 = \mathbf{25e^{5x+3}} $$

EXAMPLE 3

Let $h(x) = e^{\sin x}$.

  • Inner function: $g(x) = \sin x \implies g'(x) = \cos x$
  • Outer function: $f(u) = e^u \implies f'(u) = e^u$
By the chain rule: $$ h'(x) = e^{\sin x} \cdot \cos x = \mathbf{e^{\sin x}\cos x} $$

EXAMPLE 4

Let $h(x) = \ln(x^2+4)$.

  • Inner function: $g(x) = x^2+4 \implies g'(x) = 2x$
  • Outer function: $f(u) = \ln u \implies f'(u) = \dfrac{1}{u}$
By the chain rule: $$ h'(x) = \dfrac{1}{x^2+4} \cdot (2x) = \mathbf{\dfrac{2x}{x^2+4}} $$

EXAMPLE 5

Let $h(x) = \sqrt{3x^2+5x+2}$.

  • Inner function: $g(x) = 3x^2+5x+2 \implies g'(x) = 6x+5$
  • Outer function: $f(u) = \sqrt{u} \implies f'(u) = \dfrac{1}{2\sqrt{u}}$
By the chain rule: $$ \begin{aligned} h'(x) &= \dfrac{1}{2\sqrt{3x^2+5x+2}} \cdot (6x+5) \\ &= \mathbf{\dfrac{6x+5}{2\sqrt{3x^2+5x+2}}} \end{aligned} $$

EXAMPLE 6

Let $h(x) = \sqrt{\cos x}$.

  • Inner function: $g(x) = \cos x \implies g'(x) = -\sin x$
  • Outer function: $f(u) = \sqrt{u} \implies f'(u) = \dfrac{1}{2\sqrt{u}}$
By the chain rule: $$ h'(x) = \dfrac{1}{2\sqrt{\cos x}} \cdot (-\sin x) = \mathbf{\dfrac{-\sin x}{2\sqrt{\cos x}}} $$

EXAMPLE 7

Consider the function $h(x) = (2x^2+3)^2$.

If we first expand:
$h(x) = 4x^4 + 12x^2 + 9$
Then $h'(x) = \mathbf{16x^3 + 24x}$

If we follow the chain rule:
  • Inner function: $g(x) = 2x^2+3 \implies g'(x) = 4x$
  • Outer function: $f(u) = u^2 \implies f'(u) = 2u$
$h'(x) = 2(2x^2+3)^1 \cdot (4x) = 8x(2x^2+3) = \mathbf{16x^3 + 24x}$

But what about $h(x) = (2x^2+3)^{10}$?
Do not attempt to expand, it will be laborious! Using the chain rule:
  • Inner function: $g(x) = 2x^2+3 \implies g'(x) = 4x$
  • Outer function: $f(u) = u^{10} \implies f'(u) = 10u^9$
$h'(x) = 10(2x^2+3)^9 \cdot (4x) = \mathbf{40x(2x^2+3)^9}$

NOTICE: Linear Substitutions

In many examples, the inner function is $g(x) = ax+b$ (linear) so that $g'(x) = a$. Hence, we differentiate the outer function and simply multiply the result by the constant scalar $a$.

A confusing case of the chain rule is the differentiation of the function $\sin^n x$ (or $\cos^n x$). Remember that:

$\sin^n x$ means $(\sin x)^n$

EXAMPLE 8

  • For $h(x) = \sin^3 x$:
    Inner: $g(x) = \sin x \implies g'(x) = \cos x$
    Outer: $f(u) = u^3 \implies f'(u) = 3u^2$
    $h'(x) = 3(\sin x)^2 \cdot (\cos x) = \mathbf{3\sin^2 x \cos x}$
  • For $h(x) = \sin^2 x$:
    Inner: $g(x) = \sin x \implies g'(x) = \cos x$
    Outer: $f(u) = u^2 \implies f'(u) = 2u$
    $h'(x) = 2(\sin x)^1 \cdot (\cos x) = \mathbf{2\sin x \cos x}$
  • For $h(x) = \cos^5 x$:
    Inner: $g(x) = \cos x \implies g'(x) = -\sin x$
    Outer: $f(u) = u^5 \implies f'(u) = 5u^4$
    $h'(x) = 5(\cos x)^4 \cdot (-\sin x) = \mathbf{-5\cos^4 x \sin x}$
  • For $h(x) = \dfrac{1}{\sin x} = (\sin x)^{-1}$:
    Inner: $g(x) = \sin x \implies g'(x) = \cos x$
    Outer: $f(u) = u^{-1} \implies f'(u) = -1u^{-2}$
    $h'(x) = -1(\sin x)^{-2} \cdot (\cos x) = \mathbf{-\dfrac{\cos x}{\sin^2 x}}$
  • For $h(x) = \dfrac{1}{\cos^2 x} = (\cos x)^{-2}$:
    Inner: $g(x) = \cos x \implies g'(x) = -\sin x$
    Outer: $f(u) = u^{-2} \implies f'(u) = -2u^{-3}$
    $h'(x) = -2(\cos x)^{-3} \cdot (-\sin x) = \mathbf{\dfrac{2\sin x}{\cos^3 x}}$

It is possible to have a "double chain", which is the derivative of the composition of three functions. We systematically identify the layers from outside to inside.

EXAMPLE 9

  • a) Let $h(x) = \ln(\sin(3x+1))$
    Inner: $g(x) = \sin(3x+1) \implies g'(x) = 3\cos(3x+1)$
    Outer: $f(u) = \ln u \implies f'(u) = \dfrac{1}{u}$
    $$ h'(x) = \dfrac{1}{\sin(3x+1)} \cdot [3\cos(3x+1)] = \mathbf{3\dfrac{\cos(3x+1)}{\sin(3x+1)}} $$
  • b) Let $h(x) = 3\sin^5(x^2+1) = 3[\sin(x^2+1)]^5$
    Inner: $g(x) = \sin(x^2+1) \implies g'(x) = \cos(x^2+1) \cdot (2x)$
    Outer: $f(u) = 3u^5 \implies f'(u) = 15u^4$
    $$ \begin{aligned} h'(x) &= 15[\sin(x^2+1)]^4 \cdot [\cos(x^2+1) \cdot (2x)] \\ &= \mathbf{30x\sin^4(x^2+1)\cos(x^2+1)} \end{aligned} $$
  • c) Let $h(x) = e^{\sin(3x)}$
    Inner: $g(x) = \sin(3x) \implies g'(x) = 3\cos(3x)$
    Outer: $f(u) = e^u \implies f'(u) = e^u$
    $$ h'(x) = e^{\sin(3x)} \cdot [3\cos(3x)] = \mathbf{3e^{\sin(3x)}\cos(3x)} $$
  • d) Let $h(x) = \sqrt{\sin^2 x + \sin(2x)}$
    Inner: $g(x) = \sin^2 x + \sin(2x) \implies g'(x) = 2\sin x\cos x + 2\cos(2x)$
    Outer: $f(u) = \sqrt{u} \implies f'(u) = \dfrac{1}{2\sqrt{u}}$
    $$ \begin{aligned} h'(x) &= \dfrac{1}{2\sqrt{\sin^2 x + \sin(2x)}} \cdot (2\sin x\cos x + 2\cos(2x)) \\ &= \mathbf{\dfrac{\sin x\cos x + \cos(2x)}{\sqrt{\sin^2 x + \sin(2x)}}} \end{aligned} $$

We may also encounter a combination of differentiation rules.

EXAMPLE 10

Find the derivative of $h(x) = e^{2x}\sin(3x)$.

Solution: We have a product of two discrete functions, so we apply the product rule. For each individual function, we apply the chain rule.
  • First piece: $e^{2x} \implies$ Inner $2x$, Outer $e^u \implies$ derivative is $2e^{2x}$
  • Second piece: $\sin(3x) \implies$ Inner $3x$, Outer $\sin u \implies$ derivative is $3\cos(3x)$
$h'(x) = (e^{2x})'\sin(3x) + e^{2x}(\sin(3x))'$
$h'(x) = \mathbf{2e^{2x}\sin(3x) + 3e^{2x}\cos(3x)}$

EXAMPLE 11

Find the derivative of $h(x) = e^{x^2\sin x}$.

Solution: Here we apply the chain rule where the inner function requires the product rule.
  • Inner: $g(x) = x^2\sin x \implies g'(x) = 2x\sin x + x^2\cos x$
  • Outer: $f(u) = e^u \implies f'(u) = e^u$
$h'(x) = e^{x^2\sin x} \cdot (2x\sin x + x^2\cos x) = \mathbf{e^{x^2\sin x}(2x\sin x + x^2\cos x)}$

EXAMPLE 12

Differentiate the following abstract functions ($f$ is an unknown differentiable function):

Function Derivative
$h(x) = \sin(f(x))$ $h'(x) = \cos(f(x)) \cdot f'(x)$
(Inner: $f(x)$, Outer: $\sin u$)
$h(x) = f(\sin x)$ $h'(x) = f'(\sin x) \cdot \cos x$
(Inner: $\sin x$, Outer: $f(u)$)
$h(x) = [f(x)]^5$ $h'(x) = 5[f(x)]^4 \cdot f'(x)$
(Inner: $f(x)$, Outer: $u^5$)
$h(x) = f(x^5)$ $h'(x) = f'(x^5) \cdot 5x^4$
(Inner: $x^5$, Outer: $f(u)$)

Visualizing the Chain Rule (Leibniz Notation)

In Leibniz notation, we explicitly define the intermediate variable $u$. Let $y$ depend on $u$, and $u$ depend on $x$. We map the chain:

y u x

The chain rule states that

$\dfrac{dy}{dx} = \dfrac{dy}{du} \cdot \dfrac{du}{dx}$
[Notice: It is easy to remember this algebraic formula, as it visually mirrors the multiplication of fractions.]
Look at $y = (2x^2+3)^{10}$ again. Set $u = 2x^2+3$ and then $y = u^{10}$. The chain rule yields $$ \dfrac{dy}{dx} = \dfrac{dy}{du} \cdot \dfrac{du}{dx} = 10u^9 \cdot (4x) = 10(2x^2+3)^9 \cdot (4x) = \mathbf{40x(2x^2+3)^9} $$

EXAMPLE 13

Let $y = e^{\sin x}$. Then $y = e^u$ where $u = \sin x$. $$ \dfrac{dy}{dx} = \dfrac{dy}{du} \cdot \dfrac{du}{dx} = e^u \cdot \cos x = \mathbf{e^{\sin x}\cos x} $$

EXAMPLE 14 (Mainly for HL)

Let $P = Q^3$ and $Q = \ln R$. Find $\dfrac{dP}{dR}$ in terms of $R$.

We have the sequence:
P Q R
(as P depends on Q and Q depends on R)
The chain rule provides $$ \dfrac{dP}{dR} = \dfrac{dP}{dQ} \cdot \dfrac{dQ}{dR} = 3Q^2 \cdot \dfrac{1}{R} = \mathbf{3(\ln R)^2 \dfrac{1}{R}} $$