Rung 32
Partial derivatives
Slope in one direction, while everything else holds still.
Best attempted after 21. Rules of differentiation and 28. Vectors. Nothing stops you trying this now — the gate will tell you if you were right.
The gate
Compute both partial derivatives of a two-variable function by hand, then verify each numerically by nudging only that variable. Then show, with a specific point and a drawing, that a partial derivative is the ordinary derivative of a one-dimensional slice through the surface.
Nobody checks this but you. Do it honestly and the rungs above hold; do it loosely and they will not, somewhere further up where the cause is much harder to find.
Rung 20's derivative asked how the output changes as the single input moves. With two inputs the question is incomplete: change which one?
A partial derivative answers the narrowed version. Hold every other variable
fixed, move one, and measure. That is all the notation ∂ means — an ordinary
derivative with a promise that nothing else moved.
Why this is on the ladder
Because a model does not have one parameter. It has millions, and training asks, for each one, "if I nudge just this, what happens to the error?" That question, answered a million times over, is what a training step is.
The good news is there is no new calculus here. Every rule from rung 21 applies; the only new discipline is treating the other variables as constants while you work.
Do this
Take f(x, y) = x²y + 3y.
For ∂f/∂x, treat y as a fixed number. The first term differentiates to 2xy;
the second has no x, so it is a constant and vanishes. For ∂f/∂y, treat x as
fixed: the first term gives x², the second gives 3.
Now verify at a specific point, say (2, 1), with rung 20's method: nudge x by a
small h while holding y exactly fixed, and compute the difference quotient.
Then the same for y. Both should match your hand answers to several decimals.
Then make the picture. Fix y = 1 and you have a curve in one variable — a slice
through the surface. ∂f/∂x is the ordinary slope of that curve. Draw the surface
roughly, draw the slice, mark the slope. A partial derivative is not a new kind of
object; it is rung 20 applied to a slice.
Where people get stuck
Forgetting to hold the other variable fixed numerically, and nudging both at once. The check then disagrees with the hand answer and the hand answer gets blamed. Change one variable at a time.
The other trap is thinking the partials tell you everything about how the function changes. They describe two specific directions — along the axes. What happens in a diagonal direction is not yet answered, and that gap is precisely what the next rung exists to close.
Reading
- Multivariable calculus — Khan Academy