Calculus I · When You Can’t Solve It, Chase It
When Newton breaks
A method you do not understand the failures of is a method you cannot trust. Newton has a clear weak spot, and it is written right into the formula: we divide by . If the slope at our guess is close to zero — if the tangent line is nearly flat — then a nearly-horizontal line crosses the axis very far away, and the next guess hurls itself off into the distance instead of homing in. (Figure 9.2: a near-flat tangent throwing far from the root.)
The cleanest disaster: try to find the root of (the cube root), whose only root is at . Its derivative is . Run Newton’s formula and watch (this is a diamond problem below, but here is the punchline): every step gives
The guess flips sign and doubles in size every single step: It runs screaming away from the very root it was supposed to find. Same elegant method, same formula, complete failure — because the function’s slope misbehaves at the root.
The lesson is not “Newton is bad.” The lesson is that fast and reliable are different promises. Newton is the fastest method in this chapter when you start near a well-behaved root, and it is the most dangerous when you don’t. Hold that thought, because the slower method we meet next is slower precisely because it is built not to blow up.
Gradient descent: just walk downhill
Now the target changes. We do not want a place where is zero; we want the place where is smallest. (Remember the reframe from Chapter 7: a “loss” — a number measuring how wrong a model is — is just a function, and learning means making it as small as possible. Finding minima is the whole game.)
Here is the most intuitive idea in the book, and a 12-year-old and a professional ML engineer use the exact same picture. Imagine standing on the graph of in the dark. You cannot see the bottom of the valley. But you can feel which way the ground slopes under your feet — that is exactly what the derivative tells you. So take a step downhill: if the ground slopes up to the right (), step left; if it slopes up to the left (), step right. Either way, step against the slope. And take a bigger step where the slope is steeper. All of that is captured in one line:
The minus sign is “go against the slope, i.e., downhill.” The number (the Greek letter eta) is how big a step you take per unit of slope — it is called the learning rate, and choosing it is the entire art. At the bottom of the valley the slope is zero, so the update stops moving: you have arrived. (Figure 9.3: a ball on a U-shaped curve taking downhill steps that shrink as it nears the bottom.)
The learning rate is everything — and we can prove it with algebra
Let us minimize the simplest possible valley, , whose bottom is obviously at . Its derivative is , so the update rule becomes:
Every step just multiplies the current position by the fixed number . But multiplying by the same number over and over is exactly a geometric sequence — the thing we studied all the way back in Chapter 1. So after steps, starting from :
And we already know, from Chapter 1, exactly when a geometric sequence shrinks to zero: when the thing being raised to the th power has size less than . So whether gradient descent works is decided entirely by the single number . Let us start at and turn the same crank for four different learning rates:
| learning rate | factor | the sequence | what happens |
|---|---|---|---|
| glides smoothly to ✓ | |||
| overshoots, but still closes in ✓ | |||
| bounces forever, never arrives ✗ | |||
| explodes off to infinity ✗ |
Read that table slowly, because it is the whole story of training a model in miniature. A small learning rate () creeps down patiently and lands. A medium one () overshoots the bottom each time but the overshoots shrink, so it spirals in. At the critical value () it bounces between the same two points forever, getting nowhere. And a too-large rate () overshoots so hard that each step lands farther out than the last, and the whole thing detonates. The condition for success is just , which works out to . (Figure 9.4: the four trajectories on the parabola — the smooth glide, the shrinking spiral, the stuck bounce, the explosion.)
There is one more magic value worth seeing: makes the factor , so — gradient descent reaches the exact minimum in a single step. Tuck that away. It is not a coincidence, and the next section explains it.
Toolkit: Gradient descent (finding a minimum)
To minimize : 1. Pick a starting guess and a learning rate . 2. Repeat: . 3. Stop when the steps become tiny (the slope is near zero — you’re at the bottom).
The learning rate is the dial that decides everything: too small and it crawls; too large and it overshoots and can explode. The sweet spot is the whole craft. Unlike Newton, gradient descent never divides by anything, so it can’t blow up from a flat spot — its failures come only from a step size you chose.