Quick Context
When a function feeds into another — y = f(g(x)) — a change in x must travel through both to reach y. The chain rule says the sensitivities simply multiply.
dy/dx = (dy/du) × (du/dx)
The Gear Analogy
Picture two gears. Turning the first makes the second turn 3× as fast; that second gear drives a third at 2×. Turn the first gear once and the last one spins 6 times — the ratios multiplied.
Derivatives are exactly these ratios: how much does the output move per unit of input? Press Nudge x and watch a small change in x produce a change in u, which produces a change in y — each link scaling the one before.
Reading the Diagram
The chain strip shows x → u → y with each link's local derivative underneath. The app also computes a numeric check — the slope measured by actually nudging x by a tiny amount — and it always matches the product. The rule is not an approximation.
This Is Backpropagation
A neural network is a deep composition: input → layer 1 → layer 2 → … → loss. To learn, you need the derivative of the loss with respect to a weight buried near the start. The chain rule provides it by multiplying every local derivative along the path:
∂L/∂w₁ = (∂L/∂a₃)(∂a₃/∂a₂)(∂a₂/∂a₁)(∂a₁/∂w₁)
Backpropagation is nothing more than this product, computed efficiently from the output backwards so shared terms are reused.
Why Deep Networks Struggle
Multiplying many numbers together is unstable. If each local derivative is less than 1, the product shrinks toward zero — the vanishing gradient. If each is greater than 1, it explodes.
Choose the sigmoid outer function and slide x outwards. Its derivative never exceeds 0.25, so stacking ten sigmoid layers scales the gradient by at most 0.25¹⁰ ≈ 0.00000095. That is precisely why ReLU replaced sigmoid in deep networks, and why LSTMs added a gated path that avoids repeated multiplication.
Interactive Exploration Guide
- Start with g = 2x+1, f = u². The product of local slopes matches the numeric check exactly.
- Press Nudge. Watch a small Δx become a larger Δu and then a larger Δy — magnification compounding through the chain.
- Set the inner function to sin(x) and slide to where its slope is zero. The total derivative collapses to zero too — one flat link kills the whole chain, however steep the others are.
- Switch the outer to sigmoid and push x to ±3. dy/du shrinks toward nothing: the saturation that stalls deep networks.
Key Takeaway
Nested functions multiply their slopes. That gives you the derivative of arbitrarily deep compositions — and because multiplication compounds, it also explains why gradients vanish or explode in deep networks.