Calculus · Chain rule

Chain rule

The chain rule says that the derivative of a composite f(g(x)) is f′(g(x)) · g′(x): near x the inner function stretches a small step by g′(x), the outer one stretches what it receives by f′ at u = g(x), and the two stretches multiply.

The chain rule in this visualization

A composite f(g(x))f(g(x)) works in two stages: the inner function g takes x to u=g(x)u = g(x), and the outer function f takes u to y=f(u)y = f(u). When g is differentiable at x and f at u=g(x)u = g(x), the chain rule says the composite's derivative is (f∘g)′(x)=f′(g(x))⋅g′(x)(f \circ g)'(x) = f'(g(x)) \cdot g'(x), or in Leibniz's notation dydx=dydu⋅dudx\frac{dy}{dx} = \frac{dy}{du} \cdot \frac{du}{dx}. The picture draws x, u and y on three parallel lines to one scale, so lengths can be compared from line to line: a step of length h on the x line is carried down through g and then f. How far apart the images of its two ends land, compared with the step they came from, is that stage's stretch factor; ends that land the other way round give a negative one.

Why the derivatives multiply

A derivative is a signed stretch factor near a point: g′(x)g'(x) says about how many times g lengthens a very short step at x. Take the step from x to x+hx + h. Its ends land Δu\Delta u apart on the u line, counted with sign, and their images land Δy\Delta y apart on the y line. Whenever Δu≠0\Delta u \ne 0, ΔyΔx=ΔyΔu⋅ΔuΔx\frac{\Delta y}{\Delta x} = \frac{\Delta y}{\Delta u} \cdot \frac{\Delta u}{\Delta x} holds exactly, for any h, even while the points in between land unevenly spaced. Shrink h and they land evenly spaced. Δu/Δx\Delta u/\Delta x heads for g′(x)g'(x), the whole for (f∘g)′(x)(f \circ g)'(x), and the outer factor for f′f' at the place the step has been carried to, u=g(x)u = g(x), not at x. For sin⁡(x2)\sin(x^2) at 2 that is cos⁡4⋅4≈−2.615\cos 4 \cdot 4 \approx -2.615; cos⁡2⋅4\cos 2 \cdot 4 measures the outer stretch at the wrong place.

Turning around, and flattening

A decreasing stage turns the step around, and its stretch factor is negative. 1−2x1 - 2x turns every step around and doubles it. Then u2u^2 at u=−1u = -1 turns it around again, so the composite increases: (−2)(−2)=4(-2)(-2) = 4. When both stages are differentiable, one with derivative 0 makes the derivative of the whole 0: it squeezes short steps to almost nothing, and the other can only multiply that by about its own derivative. x2x^2 at 0 has derivative 0, so ex2e^{x^2} has derivative 0 there, although f′(0)=1f'(0) = 1.

When Δu = 0

The product of quotients needs Δu≠0\Delta u \ne 0. x2x^2 sends both −0.5 and 0.5 to 0.25, so on that step Δu=0\Delta u = 0 and Δy/Δu\Delta y/\Delta u does not exist. Some functions make Δu=0\Delta u = 0 for steps as short as you like, so the quotient argument cannot simply leave such steps out. The repair writes the outer stage without dividing: f(u+k)−f(u)=(f′(u)+η(k)) kf(u + k) - f(u) = (f'(u) + \eta(k))\,k, where η(k)→0\eta(k) \to 0 as k→0k \to 0 and η(0)=0\eta(0) = 0, true for k=0k = 0 as well. With k=Δuk = \Delta u, Δyh=(f′(u)+η(Δu)) Δuh\frac{\Delta y}{h} = (f'(u) + \eta(\Delta u))\,\frac{\Delta u}{h}. As h→0h \to 0, Δu→0\Delta u \to 0 because g is differentiable at x, so η(Δu)→0\eta(\Delta u) \to 0 and the right side goes to f′(u) g′(x)f'(u)\,g'(x).

Things to notice

  • dydu⋅dudx\frac{dy}{du} \cdot \frac{du}{dx} looks like fractions cancelling, but dy/du is a single symbol for a derivative, not a quotient of two numbers.
  • Related rates are the chain rule with time as the variable: dydt=dydx⋅dxdt\frac{dy}{dt} = \frac{dy}{dx} \cdot \frac{dx}{dt}.

Controls

  • Drag the x line left or right to move x; it catches whole and half numbers. The wheel and the field set x too; the field takes fractions such as 1/3.
  • The fader sets the step h from 1 down to 0.001; the field takes an exact value. Choose the inner and the outer function with their keys.
  • With the keyboard, Tab to the point on the x line and use the left and right arrow keys; hold Shift for finer steps.

Related