LocusBlog

The chain rule, and the factor everyone drops

The chain rule differentiates a composition. If $y = f(g(x))$, then

$$\frac{d}{dx}f(g(x)) = f'(g(x))\cdot g'(x)$$

$f$ is the outside function and $g$ is the inside function. The two derivatives are read in different places: $f'$ at the inner value $g(x)$, and $g'$ at $x$. The rule holds whenever $g$ is differentiable at $x$ and $f$ is differentiable at $g(x)$, which is nearly always in a calculus course and is worth checking when it is not.

With $u = g(x)$ and $y = f(u)$ the same statement is shorter:

$$\frac{dy}{dx} = \frac{dy}{du}\cdot\frac{du}{dx}$$

That form is easier to remember and easier to abuse. It looks like $du$ cancels, and the cancellation is not what makes the rule true. $dy/du$ is one symbol for a limit, not a fraction whose parts can be moved around. What the form does capture is a rate-of-rates argument: if $u$ moves three times as fast as $x$, and $y$ moves five times as fast as $u$, then $y$ moves fifteen times as fast as $x$. Rates multiply along a chain.

Where it comes from, and where the obvious proof breaks

Start from the difference quotient and insert the inner change:

$$\frac{f(g(x+h)) - f(g(x))}{h} = \frac{f(g(x+h)) - f(g(x))}{g(x+h) - g(x)} \cdot \frac{g(x+h) - g(x)}{h}$$

Let $h \to 0$. The right factor goes to $g'(x)$. The left factor is a difference quotient for $f$ at $g(x)$, so it goes to $f'(g(x))$, and the rule falls out.

That argument is wrong as written, and not in a small way. It divides by $g(x+h) - g(x)$, which can be zero for values of $h$ arbitrarily close to zero. A constant inner function does it immediately. So does $g(x) = x^2\sin(1/x)$ with $g(0) = 0$, which is differentiable at $0$ and still has zeros crowding in on $0$ from both sides. For those $h$ the expression on the right does not exist at all.

The patch is to never divide. Fix $b = g(x)$ and define a single function that carries the outer difference quotient:

$$Q(u) = \begin{cases} \dfrac{f(u) - f(b)}{u - b}, & u \neq b \\[4pt] f'(b), & u = b \end{cases}$$

$Q$ is continuous at $b$, because saying $f$ is differentiable at $b$ is exactly saying that quotient tends to $f'(b)$. And $f(u) - f(b) = Q(u)(u - b)$ now holds for every $u$, including $u = b$, where both sides are zero. Put $u = g(x+h)$:

$$\frac{f(g(x+h)) - f(g(x))}{h} = Q(g(x+h)) \cdot \frac{g(x+h) - g(x)}{h}$$

Nothing is divided by anything that vanishes. Differentiability makes $g$ continuous, so $g(x+h) \to b$, and continuity of $Q$ makes $Q(g(x+h)) \to f'(b) = f'(g(x))$. The second factor goes to $g'(x)$. The product of the limits is the chain rule, with no case left unhandled. That repair is the standard one, and it is the reason the rule is stated with no side condition about the inner function.

Three layers, and a chain inside a product

Mechanically the rule is: differentiate the outside, leave its input alone, then multiply by the derivative of what was inside. For $y = (3x^2+1)^5$ the outside is the fifth power and the inside is $3x^2+1$:

$$y' = 5(3x^2+1)^4 \cdot 6x = 30x(3x^2+1)^4$$

At $x = 1$ that is $30 \cdot 4^4 = 7680$. A symmetric difference quotient on the original function with $h = 10^{-6}$ returns $7680.0$, so the factor of $6x$ is not decoration.

Chains nest. For $y = e^{\sin(x^2)}$ there are three layers, and you peel them outward in, multiplying as you go:

$$y' = e^{\sin(x^2)} \cdot \cos(x^2) \cdot 2x$$

At $x = 1$, $e^{\sin 1} = 2.31978$ and $\cos 1 = 0.540302$, so $y' = 2.31978 \times 0.540302 \times 2 = 2.50676$. Numerical differentiation of $e^{\sin(x^2)}$ at $x = 1$ gives $2.50676$.

The case that separates people who know the rule from people who recognise it is a chain buried inside another rule. Take $f(x) = x^2\sqrt{4x+1}$. The top level is a product, so the product rule runs first, and the chain rule handles the second factor:

$$f'(x) = 2x\sqrt{4x+1} + x^2 \cdot \frac{4}{2\sqrt{4x+1}} = 2x\sqrt{4x+1} + \frac{2x^2}{\sqrt{4x+1}}$$

Over a common denominator, $2x(4x+1) + 2x^2 = 10x^2 + 2x$, so

$$f'(x) = \frac{10x^2 + 2x}{\sqrt{4x+1}}$$

At $x = 2$ the root is $3$, and $f'(2) = (40 + 4)/3 = 44/3 = 14.667$.

Check it a second way, without the product rule. Square both sides: $f(x)^2 = x^4(4x+1) = 4x^5 + x^4$, a polynomial. Differentiate both sides, using the chain rule on the left, and you get $2f f' = 20x^4 + 4x^3$. At $x = 2$, $f(2) = 4 \cdot 3 = 12$, so

$$f'(2) = \frac{20 \cdot 16 + 4 \cdot 8}{2 \cdot 12} = \frac{352}{24} = \frac{44}{3}$$

Same number by a different route, and that route is implicit differentiation, which is the chain rule applied to a variable you never solved for.

The dropped inside factor

The failure mode is always the same shape: differentiate the outside, then forget that the inside had a derivative of its own. Ask for the derivative of $(5x-2)^4$ and the answer that comes back too often is $4(5x-2)^3$. The correct answer is

$$\frac{d}{dx}(5x-2)^4 = 4(5x-2)^3 \cdot 5 = 20(5x-2)^3$$

At $x = 1$ the true derivative is $20 \cdot 27 = 540$. The dropped-factor answer is $108$. A numerical derivative of $(5x-2)^4$ at $x = 1$ returns $540.0$, so the error is a clean factor of five, everywhere, not just at that point. The same slip turns $\cos(3x)$ into the derivative of $\sin(3x)$ instead of $3\cos(3x)$, and turns every trigonometric problem with a coefficient inside into a scaled version of the right answer - which is worse than an obvious error, because the graph still has the right shape.

The defence is to say the inside out loud before writing anything. Name $u$, write $du/dx$ next to it, and only then differentiate the outside. When the inside is $x$, its derivative is $1$ and nothing changes, which is why the rule is invisible until it is not.

Almost every derivative past the first week is a composition, so this is the rule that shows up inside the others. It runs forward through mixed product, quotient and chain problems, it runs sideways in implicit differentiation, and it runs backwards in substitution, where the factor people drop going forwards is exactly the factor they hunt for going back. Drill it on chain rule problems until the inside derivative is automatic, and read the study guide section for the outside-inside statement worked through more slowly.

References