Concept · Chapter 2: The Math Toolkit
The Chain Rule
The chain rule says the rate of change through a chain of functions is the product of the rates of change of each link — which is exactly how gradients flow backward through the layers of a network.
The problem
A neural network is a long composition of functions; we need the derivative of the final loss with respect to a weight buried many steps earlier.
The solution
Multiply the local derivatives along the path: how the loss changes with the output, times how the output changes with the hidden value, times how the hidden value changes with the weight.
The consequence
Gradients of arbitrarily deep compositions can be computed from simple local pieces — the idea behind backpropagation and automatic differentiation.
You should understand first
- Derivatives and Gradients
- The Chain Rule
Intuition: gears
Three gears are linked. Gear B turns 3 times for each turn of gear A; gear C turns 2 times for each turn of B. How many times does C turn per turn of A? . Rates along a chain multiply. That's the whole chain rule.
Tiny numeric example
A two-step computation
(a "layer"), then (a "loss"). At : , .Local derivatives
and .Multiply along the chain
.Check directly
, so at . ✓
The equation
Where it appears in AI
- Backpropagation: the gradient for every weight is a product of local derivatives along the paths from that weight to the loss.
- Vanishing gradients: multiply 50 factors of 0.5 and you get about — early layers barely learn. Multiply 50 factors of 1.5 and you get about — training explodes.
- Residual connections add a path whose local derivative is 1, which is why they make deep networks trainable (see residual connections).
Why should I care?
As a researcher
Backpropagation is the chain rule applied systematically; vanishing and exploding gradients are what happens when you multiply many small or large factors together.
As an engineer
Understanding that gradients are products along paths explains why deep networks need careful initialization, normalization and residual connections.
Modern systems that depend on it
- Backpropagation
- Automatic differentiation (PyTorch, JAX)
- Vanishing/exploding gradient analysis
- Residual connections
Historical context
Before
The chain rule is centuries-old calculus (Leibniz).
After
Reverse-mode automatic differentiation (backpropagation) applied it efficiently to networks with millions of parameters; it became the standard way to train them from the 1980s on.
Used today
Every call to loss.backward() in PyTorch applies the chain rule through the whole computation graph.
What to remember
- If y = f(g(x)), then dy/dx = f′(g(x)) · g′(x).
- Rates along a chain multiply.
- Backprop: start from the loss and multiply local derivatives backward, layer by layer.
- Many factors < 1 → vanishing gradients; many factors > 1 → exploding gradients.
Key papers
Learning representations by back-propagating errors
David E. Rumelhart, Geoffrey E. Hinton, Ronald J. Williams · 1986 · Nature
Showed that backpropagation lets multi-layer networks learn useful internal representations — the algorithm that still trains every neural network.
How to read it: Only four pages in Nature. Read it after the chain-rule concept page.
Watch
3Blue1Brown
Visualizing the chain rule and product rule | Chapter 4, Essence of calculus
The chain rule is the engine of backpropagation; this makes it feel obvious rather than memorized.
3Blue1Brown
Backpropagation calculus | Deep Learning Chapter 4
The chain rule applied to a network, step by step — the formal version of the previous video.