23.1 Gradient Descent and Curvature
In practice, a learning rate is usually chosen by trial and error: we pick a value, watch the loss, and turn it down if training blows up. Because every step moves opposite the gradient of the loss, the gradient fixes the direction and the learning rate sets only the distance. Yet a poor choice of distance turns training either painfully slow or unstable. How far can we trust a step along the gradient, and how many iterations does that limit force upon us?
A function of just two variables already exposes the difficulty. Consider the elliptical bowl , which curves ten times more steeply along than along , and start at , where and . Taking a step of size against the gradient lands at . With , the loss barely budges, dropping to . With , it falls sharply to . With , it rises to . Every one of those steps pointed downhill; only the step length changed.
The culprit is curvature. A step short enough to stay safe along the steep -axis creeps along the flat -axis. Even the best fixed learning rate needs iterations to shrink the error by a factor of (six digits of accuracy). Stretch the curvature ratio to —our chapter's running example —and gradient descent needs steps. Adding momentum brings that count down to . We will work by hand on the gentler bowl, whose Hessian keeps every number easy to check, and quote the corresponding counts for the stiffer running example.
We build the analysis in three stages. First, we formalize smoothness to turn the local linear approximation of Section 22.2 into a guarantee on finite steps, yielding the descent lemma (23.1.5). Next, we solve gradient descent exactly on quadratics, where the ratio of curvatures emerges as the condition number and fixes the optimal step (23.1.10). Finally, we introduce momentum and derive its convergence law (23.1.15). Throughout this section, our methods only respect curvature without modeling it; methods that model curvature directly, such as Newton's method, appear in Section 23.2. We also assume exact gradients here, leaving the noisy gradients of minibatch training to Section 23.4. All code below is plain NumPy, so each update can be read directly against its equation.
23.1.1 Descent Directions and Smoothness#
Every gradient step settles two questions: which way to move, and how far. The first has an immediate answer from the first-order Taylor expansion. The second requires knowing how quickly the gradient itself can change—an assumption that turns a local linear approximation into a guarantee for steps of finite length.
23.1.1.1 The Steepest Direction#
In our opening example, we stepped along without asking whether another direction might be better. To see why the negative gradient is the natural choice, expand to first order. A small step of size along a direction changes the function value by
To first order, the change is simply times the directional derivative . We call a descent direction at whenever .
Proposition (descent directions, and the steepest one). Let be differentiable at with .
- If , then for every sufficiently small .
- Among all unit vectors, the directional derivative is minimized uniquely by the normalized negative gradient:
Proof. For the first claim, define . By the chain rule, , so the difference quotient is strictly negative for all sufficiently small ; hence . For the second claim, the Cauchy--Schwarz inequality gives for every unit vector , with equality if and only if is a negative scalar multiple of . The unique such unit vector is , and it attains the bound.
On our opening bowl, the steepest unit direction at is , with slope . The coordinate direction also points downhill, but with a much gentler slope of . In fact, descent directions fill the entire open half-space of vectors making an acute angle with ; the negative gradient simply picks out the steepest one. Because this result governs slopes (the limit of vanishingly short steps), we next check how faithfully those slopes predict the actual decrease over a small finite step, , across four unit directions.
def f(v):
return 0.5 * (v[0]**2 + 10 * v[1]**2)
def grad(v):
return np.array([v[0], 10 * v[1]])
x = np.array([2.0, 1.0])
g = grad(x)
steepest = -g / np.linalg.norm(g)
candidates = [('steepest -grad/|grad|', steepest),
('diagonal -(1,1)/sqrt(2)', -np.ones(2) / np.sqrt(2)),
('axis (-1,0)', np.array([-1.0, 0.0])),
('uphill +(1,1)/sqrt(2)', np.ones(2) / np.sqrt(2))]
eta = 0.01
for name, d in candidates:
print(f'{name}: slope = {g @ d:+8.4f}, '
f'f(x + eta d) - f(x) = {f(x + eta * d) - f(x):+.6f}')
steepest -grad/|grad|: slope = -10.1980, f(x + eta d) - f(x) = -0.101498
diagonal -(1,1)/sqrt(2): slope = -8.4853, f(x + eta d) - f(x) = -0.084578
axis (-1,0): slope = -2.0000, f(x + eta d) - f(x) = -0.019950
uphill +(1,1)/sqrt(2): slope = +8.4853, f(x + eta d) - f(x) = +0.085128
At , each actual change matches times the directional slope to within one percent, so the first-order model is a reliable guide for short steps. Differentiability promises nothing beyond that: a decrease for sufficiently small steps. How small is "sufficiently small" is the question we turn to next.
23.1.1.2 Smoothness and the Descent Lemma#
Gradient descent repeats the steepest-descent step with a fixed step size (or learning rate) :
Throughout this section, indexes iterations and we abbreviate . The first-order Taylor expansion justified the direction , but it says nothing about how far to trust it: once the iterate moves far enough that the gradient changes significantly, no longer describes . To certify a finite step size, we need a bound on how fast the gradient can vary.
Definition (-smoothness). A differentiable function is -smooth if its gradient changes by at most per unit of distance:
When is twice continuously differentiable, -smoothness is equivalent to requiring every eigenvalue of its Hessian to lie in . Bounded eigenvalues imply (23.1.3) by integrating the Hessian along the line segment from to , and the converse follows by taking a difference-quotient limit (exercise 2a). In short, caps the curvature in every direction. Our opening bowl has constant Hessian , so . By contrast, a function whose curvature grows without bound has no global smoothness constant: has , so no finite global exists. We will handle that case shortly using backtracking line search.
Smoothness upgrades the local tangent plane into a global upper bound—a quadratic ceiling:
Geometrically, the graph of can never rise above its tangent plane at by more than times the squared distance. Before we prove this inequality, plug in a gradient step and watch the two terms compete. The linear first-order decrease grows proportionally to , whereas the quadratic curvature penalty grows as . For small , the linear decrease wins; at , the two terms exactly cancel.
Proposition (descent lemma). If is -smooth, then the gradient step (23.1.2) satisfies
In particular, strictly decreases whenever and . The guaranteed decrease is maximized at , where .
Proof. We first establish the quadratic ceiling (23.1.4). Restrict to the line segment between and via for , so that . Applying the fundamental theorem of calculus, Cauchy--Schwarz, and the Lipschitz condition (23.1.3) yields
Substituting the gradient step gives
The factor is strictly positive if and only if , and it reaches its maximum at .
Notice that the proof only compares gradients between and points along the segment to , so it suffices for to be -Lipschitz on that segment. Let us test the lemma on our opening bowl, where and . At , the bound guarantees . At , it guarantees . At , the factor turns negative and the bound rises above the starting value, offering no guarantee at all. How tight are these bounds compared with the values the three steps actually reach?
x, L = np.array([2.0, 1.0]), 10.0
g = grad(x)
for eta in (0.01, 0.1, 0.25):
bound = f(x) - eta * (1 - L * eta / 2) * (g @ g)
print(f'eta = {eta:4.2f}: bound {bound:7.4f}, actual {f(x - eta * g):7.4f}')
eta = 0.01: bound 6.0120, actual 6.0102
eta = 0.10: bound 1.8000, actual 1.6200
eta = 0.25: bound 13.5000, actual 12.3750
For the two stable steps, the bounds are remarkably tight: lies just under , and sits cleanly below . At , the bound lies well above the starting value , and indeed the step overshoots to . Figure 23.1.1 plots both curves as functions of . Along the search direction, , so the true objective is the parabola , while the quadratic ceiling is . The two parabolas hug each other so closely because this gradient points almost along the stiff axis, where the directional curvature is nearly .
The descent lemma on the opening example. Along from , the true objective is the lower parabola and the quadratic ceiling is the upper one, tangent at . Minimizing the ceiling at guarantees , and the step achieves . Beyond the ceiling rises above the starting value and promises nothing; at the objective climbs to .
In short, the step minimizes the quadratic ceiling, and is guaranteed to lie beneath that ceiling. Section 22.1 develops the same geometric argument in one variable.
23.1.1.3 Stationary Points Without Convexity#
Surprisingly, the descent lemma alone, without any convexity assumption, already places a quantitative limit on a long run: the gradient cannot stay large forever.
Proposition (gradient descent finds approximate stationary points). Let be -smooth and bounded below by , and run (23.1.2) with . Then for every ,
Proof. At , the descent lemma rearranges to . Summing over , the right-hand side telescopes to . Because the minimum of numbers is at most their average, dividing by gives the bound.
Thus, among the first iterates, at least one has squared gradient norm , using nothing beyond a lower bound on and a smoothness constant. Keep in mind that this result assumes a global ; ReLU networks are not smooth, so for them the bound serves as an idealized model rather than a formal guarantee.
A small gradient, however, does not guarantee a minimum. Consider , which is bounded below by and -smooth (its Hessian has eigenvalues in ). Starting gradient descent with at drives to in a single step and never changes , since vanishes at . The algorithm halts at with —a saddle point where curves upward along and downward along , far from the true minimum value at . The theorem still holds, because the gradient vanishes at the saddle, yet it cannot tell us which kind of stationary point we reached. The stall itself is an accident of the starting point. Start at with any small instead, and each step moves further from until the run settles at a minimum. In general, the starting points from which gradient descent converges to a saddle with a direction of negative curvature form a set of measure zero (Section 9.1.2), so a random initialization avoids it, although the iterates can linger nearby for a long time. For convex objectives, the question does not arise: every stationary point is automatically a global minimum (Section 23.3).
23.1.1.4 Backtracking Line Search#
Using presupposes that we know . In practice we rarely do, and even when a global exists, the local curvature varies across the loss landscape, making a single global constant overly conservative. A line search adapts the step size at run time. Given a candidate step , it accepts the step only if the actual decrease achieves at least a fixed fraction of the decrease predicted by the first-order model—the Armijo condition (or sufficient decrease condition) (Armijo, 1966):
The right-hand side is simply the linear Taylor prediction with its slope scaled down by . Backtracking starts from an optimistic trial step and repeatedly halves until (23.1.7) is satisfied. By the descent lemma, the test is guaranteed to pass as soon as , or equivalently . Consequently, the loop always terminates in finitely many halvings and returns a step —within a factor of two of the theoretical threshold—without ever needing to know in advance.
Better still, this guarantee only requires on the region the iterates actually visit. Take the quartic , which has no global , starting at with . Because backtracking never increases , every iterate remains in , where . A trial step with sends to , which lies between and , keeping the entire segment inside so that suffices locally. Since the quartic's curvature is steep far from the origin and vanishes near zero, no single fixed step size suits the entire trajectory. Let us compare both strategies from : a fixed step (which would be completely safe near the origin) and backtracking starting from .
quartic = lambda v: 0.25 * (v ** 4).sum()
quartic_grad = lambda v: v ** 3
x = np.array([3.0])
for _ in range(6): # fixed step, too large at x0
x = x - 0.3 * quartic_grad(x)
print(f'fixed eta = 0.3 from x0 = 3: |x_6| = {abs(x[0]):.2e} (diverged)')
x, etas = np.array([3.0]), []
for _ in range(25): # backtracking line search
g = quartic_grad(x)
eta = 1.0
while quartic(x - eta * g) > quartic(x) - 0.5 * eta * (g * g).sum():
eta *= 0.5 # Armijo fails: halve the step
x = x - eta * g
etas.append(eta)
print('accepted steps:', np.array(etas[:8]), '...')
print(f'backtracking from x0 = 3: f(x_25) = {quartic(x):.2e} (monotone descent)')
fixed eta = 0.3 from x0 = 3: |x_6| = 6.52e+103 (diverged)
accepted steps: [0.03125 0.0625 0.125 0.25 0.5 1. 1. 1. ] ...
backtracking from x0 = 3: f(x_25) = 1.09e-04 (monotone descent)
The fixed step explodes immediately: after just six iterations, . Because the update shrinks if and only if , a fixed step from converges for and diverges above it. Notice that this stability threshold is , not ; the rule belongs to quadratics. A step toward the origin experiences the average of between and (which is ) rather than its peak value . The descent lemma must guard against the worst-case curvature along the segment and therefore certifies only a third of the true safe range.
Backtracking, by contrast, accepts on the first step. Its previous trial, , fails the Armijo test, which on this quartic holds if and only if (roughly at ). As the iterate moves toward the origin and the curvature flattens, the accepted steps grow automatically (, each close to ) because the line search probes the local curvature on the fly. Deep learning training rarely uses backtracking, since a minibatch loss is too noisy to compare two candidate steps reliably and each trial costs an extra forward pass. Instead, training usually specifies the step size in advance via a schedule (Section 9.7).
23.1.1.5 Relaxed Smoothness and Gradient Clipping#
A schedule cannot react when the iterate enters a region of high curvature. The safeguard that training uses for this is gradient clipping, and the quartic shows why it works. The curvature is unbounded, but it is large only where the gradient is large as well: for every . A twice differentiable function is -smooth if its curvature is bounded in this way by its gradient (Zhang et al., 2020):
where the norm on the left is the largest absolute eigenvalue of the Hessian. Setting recovers -smoothness, and the quartic qualifies with and . Under this condition, the step that the descent lemma can certify is no longer a constant . It is of order : a fixed step where the gradient is small, and a fixed distance of order where it is large. Gradient clipping, which replaces by for a threshold , takes steps of this form at no extra cost. On the quartic with , the step that diverged above now moves by per iteration until and converges from there (Exercise 3).
23.1.2 The Quadratic Model and the Condition Number#
In the opening, we promised to explain why one bowl takes steps and another takes . Both objectives are quadratics, and on a quadratic we can solve gradient descent in closed form. Remarkably, the iteration count boils down to a single quantity: the ratio of the largest curvature to the smallest.
23.1.2.1 Ill-Conditioned Valleys#
Before writing any algebra, look at Figure 23.1.2, which contrasts gradient descent on two quadratics. On a round bowl, the iterates march almost straight to the minimum. In an elongated valley, the walls are steep while the floor is flat: any step near the stability ceiling imposed by the walls overshoots across the valley and bounces from wall to wall, while barely inching along the floor. The result is the classic zigzag trajectory. (The valley shown uses with , just below its stability ceiling , producing the contraction factors noted in the caption.)
Gradient descent on two quadratics . Left: on a well-conditioned bowl, the iterates head nearly straight to the minimum. Right: in an ill-conditioned valley, a step near the stability ceiling makes the steep mode overshoot and alternate (factor ) while the slow axis contracts by only per step.
Quadratics deserve a complete analysis because every smooth function looks like one near a strict minimum. Around a minimizer with positive-definite Hessian , the second-order Taylor expansion approximates by . Shifting the minimizer to the origin and dropping the additive constant leaves our model problem:
Its gradient is and its Hessian is , so its smoothness constant is simply . The ratio of the largest curvature to the smallest,
is the condition number of the problem. It equals for our opening bowl and for the chapter's running example. Because is symmetric positive definite, coincides with the singular-value ratio introduced in Section 21.5.3.2.
23.1.2.2 Per-Mode Contraction and the Stability Ceiling#
The zigzagging in Figure 23.1.2 comes directly from the step-size ceiling enforced by the steepest direction. To pinpoint that ceiling and see how severely it slows down the flat direction, let us solve gradient descent on a quadratic exactly—starting, as always, with a single variable.
Take with . One gradient step sends to , so
Every iteration simply multiplies the error by the same scalar factor . Convergence occurs if and only if , meaning . At the sweet spot , the iterate lands on in a single step. For , the factor is negative, so flips sign at every step while shrinking toward zero. For , for instance, gives factor , gives , and gives , which diverges.
The -dimensional quadratic keeps the exact same structure. Since , the update (23.1.2) becomes
Each step applies the same linear operator, so after steps . Because is symmetric, it admits an orthonormal basis of eigenvectors (Section 21.3). Express in this eigenbasis with coordinates . The matrix shares the same eigenvectors with eigenvalues , so the coordinates decouple completely and evolve independently:
Thus, gradient descent on a -dimensional quadratic is nothing more than independent copies of the one-variable recursion—one per eigenvalue, or mode. Two consequences follow immediately from the factors :
- Convergence requires for every mode, which reduces to . This threshold is the stability ceiling. On quadratics, the bound that the descent lemma guaranteed as sufficient is also strictly necessary. Push past it, and the stiffest mode's factor drops below : that coordinate oscillates with growing amplitude even while all other modes decay cleanly.
- Speed is governed by the slowest mode. The error norm decays as , where is the spectral radius of —the largest eigenvalue magnitude.
On , the stability ceiling is . Before running the sweep below, predict which step size leaves the smallest error after steps from : the cautious , the descent-lemma favorite , or something closer to the ceiling?
A = np.diag([1.0, 10.0]) # eigenvalues 1 and 10, so L = 10
x0 = np.array([1.0, 1.0])
def run_gd(A, x0, eta, steps):
xs = [x0]
for _ in range(steps):
xs.append(xs[-1] - eta * (A @ xs[-1]))
return np.array(xs)
print(' eta |1-eta*1| |1-eta*10| spectral radius |x_60|')
for eta in [0.02, 0.10, 2 / 11, 0.19, 0.20, 0.21]:
f1, f10 = abs(1 - eta * 1.0), abs(1 - eta * 10.0)
print(f'{eta:5.3f} {f1:6.3f} {f10:6.3f} {max(f1, f10):6.3f} '
f'{np.linalg.norm(run_gd(A, x0, eta, 60)[-1]):9.1e}')
eta |1-eta*1| |1-eta*10| spectral radius |x_60|
0.020 0.980 0.800 0.980 3.0e-01
0.100 0.900 0.000 0.900 1.8e-03
0.182 0.818 0.818 0.818 8.3e-06
0.190 0.810 0.900 0.900 1.8e-03
0.200 0.800 1.000 1.000 1.0e+00
0.210 0.790 1.100 1.100 3.0e+02
The cautious is safe but sluggish (, leaving an error of after steps). At , the stiff mode vanishes in a single step, yet the slow mode still limits the overall rate to . Interestingly, shares that exact same rate , for the opposite reason: now the stiff mode oscillates with factor . Between them, balances both extremes and beats every other choice by two orders of magnitude (, error ). Right at the ceiling , the stiff mode has factor , flipping between forever so . Step just past it to , and sixty iterations inflate the error to .
23.1.2.3 The Optimal Step#
Within the stable range, which fixed step size converges fastest? The sweep points directly to the answer: balance the two extreme modes. For any fixed , the map traces a V-shape with its vertex at . On the interval , a V-shaped function attains its maximum at one of the endpoints, so . Once passes , increasing it further helps the slow mode at while hurting the stiff mode at .
Proposition (optimal fixed step on a quadratic). For , the convergence factor is minimized by
Proof. For every , we have , and the maximum of two numbers is at least any convex combination of them. Choosing the weights and makes the -terms cancel cleanly:
Equality holds only when the two terms agree, , which solves to . At , both endpoints equal , and the V-shape keeps every interior eigenvalue below that height, so the bound is attained.
Figure 23.1.3 illustrates this proof on : the optimal V is the one whose two endpoints sit at the same height. Here and , so gaining six digits takes steps. On the chapter's running example (), , and those same six digits demand steps.
The per-mode contraction factors form a V with its vertex at , and the convergence factor is the larger of its values at the extreme eigenvalues and . Choosing eliminates the stiff mode immediately but leaves the slow mode contracting at ; the optimal step equalizes both endpoints at . Lowering either endpoint would raise the other.
When (a perfectly round bowl), and a single step lands on the minimum. For large , , so , and shrinking the error by a factor of takes roughly iterations: the iteration count of gradient descent grows linearly with the condition number. The bottleneck is easy to see in one sentence: stability forces the step to obey the stiffest mode, , leaving the flattest mode to advance by only per iteration.
At , the factor is even stronger than an asymptotic rate. On , the two per-mode factors are and (the row of the sweep): the slow mode contracts monotonically while the stiff mode alternates in sign. Because both coordinates shrink by the same magnitude, contracts by on every single step, not just on average.
23.1.2.4 The Edge of Stability#
The stability ceiling suggests a simple recipe for neural networks: compute the sharpness, the largest Hessian eigenvalue , and set . In practice, training a neural network does not cooperate, because the Hessian evolves along the trajectory. Under full-batch gradient descent, the sharpness typically climbs until it hits roughly and then hovers right around that threshold; meanwhile, the loss decreases over the long run even though it jumps upward on many individual steps (Cohen et al., 2021). Section 9.1.4 runs this experiment on a small network and examines it in detail. Here we ask a narrower question: how much of this behavior does our quadratic model explain?
Roughly half. In the Hessian's eigenbasis, the top mode's multiplier is , which drops below precisely when . That coordinate then alternates in sign with growing amplitude, explaining how a loss that trends downward overall can spike on individual steps. On a fixed quadratic, however, that growth would run away to infinity. What pulls the sharpness back down instead lies outside the quadratic approximation: the third-order Taylor term, which the quadratic model ignores, turns the oscillation into a gradual drift toward flatter regions of lower sharpness (Damian et al., 2023). Exercise 8 shows that adding momentum shifts this stability threshold to .
23.1.2.5 From Quadratics to Convex Functions#
What carries over beyond quadratics is the linear dependence on . A differentiable function is convex if it lies on or above each of its tangent planes, and -strongly convex if it clears them by a quadratic margin, for all ; Section 23.3 develops both notions. If is -smooth and -strongly convex, then at every point it is sandwiched between two quadratics of curvatures and . The ratio replaces , and gradient descent with satisfies
which again requires iterations. If is smooth and convex without being strongly convex, gradient descent still converges to the global optimum, though at the slower sublinear rate ; drop convexity altogether, and only the stationarity bound (23.1.6) remains. The proofs rely on convexity and are developed in Section 23.3.3.3, which also compares these general bounds against the sharper rate attained on quadratics.
23.1.3 Momentum and Acceleration#
Gradient descent requires iterations because a single step size must simultaneously accommodate the stiffest and flattest modes. Momentum keeps the same single gradient evaluation per step, yet changes the update rule so that both modes can contract at the same rate.
23.1.3.1 Heavy-Ball Momentum#
The geometry of the valley immediately suggests what to change. Along the steep walls, consecutive gradients point in opposite directions (the zigzagging in Figure 23.1.2), so averaging recent gradients cancels the oscillation. Along the flat floor, consecutive gradients are small but consistently aligned, so accumulating them builds speed. One simple mechanism does both: give the iterate a velocity with memory. Heavy-ball momentum (Polyak, 1964) replaces the plain gradient step with
where is the momentum parameter. The velocity is an exponentially decaying sum of past gradients. Since , eliminating gives the equivalent two-step form
Each update takes a gradient step and adds times the previous displacement; setting recovers ordinary gradient descent.
On a quadratic, the modes once again decouple. In a single mode with gradient , the two-step update reads , so each iterate depends on its two predecessors. A second-order recurrence of this form is the discrete counterpart of a damped harmonic oscillator—a heavy ball rolling in a bowl with friction —where controls the damping.
Figure 23.1.4 displays the three resulting regimes on , all using gradient descent's optimal step . With too little momentum, the path zigzags much like plain gradient descent. With just the right amount, it settles smoothly after a single overshoot. With too much momentum, the ball carries excess inertia and spirals around the minimum. Next, we attach exact convergence rates to all three regimes—and discover that achieving the fastest possible rate also calls for a larger step size.
Heavy ball on the valley , with all three runs using gradient descent's step . Too little momentum zigzags like gradient descent (the stiff mode's coefficient is negative, giving a negative real root); the critically damped for this step is fastest; too much momentum spirals around the minimum. Reaching the optimal rate of requires the larger step of (23.1.14), at which would diverge.
23.1.3.2 The Law#
We now show that with the right pair , every mode contracts at the identical rate . For , this optimal pair is and , dropping the contraction factor from gradient descent's to —reaching six digits in steps instead of . Remarkably, the entire result follows from a single algebraic fact about one mode.
Proposition (heavy ball contracts every mode at ). Let . On , the heavy-ball iterates obey . Whenever , both roots of the characteristic polynomial have modulus , and for and a constant depending on , , and . The linear factor is needed only at the two endpoints, where the root is repeated.
Proof. Substitute the trial solution into the recurrence and divide by to obtain the characteristic equation
The product of the two roots is . They form a complex-conjugate pair whenever the discriminant is negative, that is, when , which rearranges to . Because complex conjugates satisfy , both roots have modulus regardless of , and the general solution satisfies . At the two endpoints, the discriminant vanishes and we get a double real root . A repeated root yields the general solution , which accounts for the extra factor .
Corollary (the tuning). Place the two extreme modes right at the endpoints of the complex-root interval: and . Every intermediate eigenvalue then falls inside the interval, so every single mode has root modulus . Taking square roots gives and . Solving the second equation for and dividing the first by the second gives . With the tuning
heavy ball contracts every mode at the rate
Compare this with (23.1.10): momentum replaces with , slashing the iteration complexity from to (Polyak, 1964). At finite , the double roots at the two extreme modes add a modest logarithmic overhead: the error scales as , so with , reaching accuracy solves —the asymptotic law plus a correction of order .
Figure 23.1.5 makes this proof visual for . On the left, the modulus of the dominant root sits flat at across the entire complex-root interval. On the right, in the complex plane, every mode's root pair lies squarely on the circle of radius , whereas gradient descent's real multipliers stretch out to . By allowing the roots to move off the real axis, momentum lets the stiff and flat modes share a single small modulus instead of forcing the flat mode to crawl at .
The proposition also explains the exact rates of the three trajectories in Figure 23.1.4, where places the two modes at and . At , both modes lie strictly inside the interval: the contraction rate is , and the complex roots produce the spiraling overshoot. The smallest whose interval still captures the slow mode, , is the fastest choice for this step size, achieving rate . At , the interval misses both modes: the slow mode gets a real root , while the stiff mode gets a negative real root that flips sign on every step—an alternation that a continuous-time physical oscillator can never produce.
Heavy ball at the tuning of (23.1.14) on the example. (a) For fixed , the modulus of the larger root is flat at wherever the roots are complex; the optimal tuning places the two extreme modes at the ends of that interval. (b) In the complex plane, every mode's root pair (labeled by its eigenvalue ) lies on the circle of radius , while gradient descent's factors span on the real axis. The extreme modes are double roots, producing the factor in the error.
Be aware that this theorem holds strictly for quadratics. Lessard et al. (2016) constructed a one-dimensional, smooth, strongly convex function on which heavy ball with the tuning (23.1.14) fails to converge from certain initializations, trapping the iterates in a stable limit cycle (exercise 6). Thus, the widespread use of heavy-ball momentum in deep learning (Sutskever et al., 2013) rests on the local quadratic picture and empirical success rather than a global convergence theorem.
23.1.3.3 Nesterov's Look-Ahead#
One small modification recovers a global guarantee: evaluate the gradient not at the current position , but at the look-ahead point where momentum is about to carry us. Nesterov's accelerated gradient (Nesterov, 1983) updates via
That shift in evaluation point is the only difference from heavy ball. Intuitively, if momentum is about to carry the iterate past the minimum, the gradient at the look-ahead point already points back uphill and applies the brakes before the overshoot occurs.
Proposition (Nesterov on quadratics). Let . With and , every mode of a quadratic with eigenvalues in has characteristic roots of modulus at most , with a double root at the slow mode . Consequently, the error is bounded by .
Proof. In a single mode with eigenvalue , write . The velocity update becomes , giving . Substituting yields the recurrence , whose characteristic polynomial has discriminant . For our choice of , . At the slow mode , the bracket evaluates to , giving a double root at . Every stiffer mode has a smaller , making the bracket strictly negative and producing complex roots (or roots at when ) of modulus .
On quadratics, Nesterov's contraction factor is for , for , and for —slightly slower than heavy ball's , , and , yet preserving the same scaling. Crucially, unlike heavy ball, Nesterov's method keeps its guarantees beyond quadratics, which we state here without proof (Nesterov, 2018). On every -strongly convex, -smooth function, Nesterov's update with the same constant satisfies . (Mind the units: this bounds the function gap , which scales as the squared distance, so its exponent is half the exponent in the quadratic proposition.) On smooth convex functions without strong convexity, a schedule achieves , improving on gradient descent's . Moreover, this speed cannot be beaten in general: no method that builds its iterates solely from past gradients can surpass or the dependence in the worst case, provided the dimension is large relative to the number of iterations (Nemirovski and Yudin, 1983). Exercise 7 constructs the worst-case function that proves this limit.
Let us now verify the iteration counts we quoted at the start of the section. On starting from , gaining six digits should cost gradient descent roughly steps and heavy ball somewhat more than .
def iterations(lam, eta, beta=0.0, lookahead=False, tol=1e-6):
"""Steps until |x_k| <= tol |x_0| on f(x) = sum_i lam_i x_i^2 / 2."""
x, v = np.array([1.0, 1.0]), np.zeros(2)
n0 = np.linalg.norm(x)
for k in range(1, 10**6):
g = lam * (x + beta * v) if lookahead else lam * x
v = beta * v - eta * g
x = x + v
if np.linalg.norm(x) <= tol * n0:
return k
print('kappa GD heavy ball Nesterov GD/kappa HB/sqrt(kappa)')
for kappa in [10.0, 100.0, 1000.0]:
lam, sk = np.array([1.0, kappa]), np.sqrt(kappa)
gd = iterations(lam, 2 / (1 + kappa))
hb = iterations(lam, (2 / (1 + sk))**2, ((sk - 1) / (sk + 1))**2)
na = iterations(lam, 1 / kappa, (sk - 1) / (sk + 1), lookahead=True)
print(f'{kappa:5.0f} {gd:7d} {hb:9d} {na:10d} '
f'{gd / kappa:7.1f} {hb / sk:7.1f}')
kappa GD heavy ball Nesterov GD/kappa HB/sqrt(kappa)
10 69 27 43 6.9 8.5
100 691 93 155 6.9 9.3
1000 6908 315 508 6.9 10.0
The table confirms every prediction. Gradient descent's step count divided by stays pinned at , reaching iterations at , while heavy ball finishes in just . Notice that heavy ball's ratio drifts gently upward (, , ) because each extreme mode has a double root: its iteration matrix forms a Jordan block, a repeated eigenvalue with only a single eigenvector (Section 21.3.1.5), whose -th power brings in the factor . The refined prediction matches closely (, , ), and at , heavy ball takes steps, a ratio of (exercise 5). Nesterov's iterations at sit cleanly between the two, just as its contraction factor versus heavy ball's predicts. Because all three methods evaluate only one gradient per step, momentum's speedup costs no extra gradient work. Yet is also the limit of what gradients alone can achieve: by the first-order lower bound, no method built solely from past gradients can beat it in high dimensions. Removing the dependence on altogether requires a step that actually models the curvature (Section 23.2).
23.1.4 Summary#
Smoothness caps how far a gradient step can be trusted: on an -smooth objective, descent is guaranteed up to . On a quadratic, the best fixed step contracts the error by per iteration, forcing the step count to grow linearly with the condition number because stability is governed by the stiffest mode while progress is governed by the flattest. Momentum equalizes every mode at the shared contraction rate , and its tuned factor cuts the iteration count from to at no extra gradient cost. On neural networks, sharpness rises to the stability ceiling of the chosen step size, a phenomenon that the quadratic model explains only in part. Three questions remain open: what an optimizer can achieve when it models curvature directly (Section 23.2), when a stationary point is guaranteed to be a global minimum (Section 23.3), and what changes when gradients are noisy (Section 23.4).
23.1.5 Exercises#
-
Preconditioned descent directions. The proposition of Section 23.1.1.1 measures the length of a direction with the Euclidean norm. Choosing a different norm yields a different steepest-descent direction.
- Show that is a descent direction for every positive definite matrix .
- Measure length by . Show that the minimizer of over is proportional to , and identify the that recovers Newton's direction , the subject of Section 23.2. The change of variables reduces the problem to the Euclidean case.
-
[code] Smoothness constants. The smoothness constant of (23.1.3) bounds the curvature of , and for a logistic loss it can be computed directly from the data.
- Let be twice continuously differentiable and -smooth. Show that for all and , and conclude that every Hessian eigenvalue lies in . This establishes the converse direction of the equivalence stated after (23.1.3).
- Consider
with labels and —the loss function that we
will use in the data cell of Section 23.2.1, where
is the -th row of
(, , with
independent standard Gaussian entries). Show that
is a valid
smoothness constant and that the Hessian attains this bound at
.
- Compute this for a matrix of standard Gaussian entries and labels drawn with for . It comes out near for every draw; explain why using for standard Gaussian entries. Count how many steps (the reference step) and each need from to reach . Which is faster, and does stay below ?
-
[code] Clipping on the quartic. Take and the clipped update with .
- Show that for all , with equality at , so that satisfies (23.1.8) with and . Show also that no works with .
- Run the clipped update from with and , the step at which the unclipped iteration reached in six steps. How many steps are clipped, and how far does each of them move ?
- Show that the clipped update decreases at every step, from every starting point , whenever . Treat the clipped case and the unclipped case separately. Why can no fixed step without clipping have this property?
-
Steepest descent in other norms. ● Problem 1b measures length by a norm induced by an inner product. Norms that do not come from an inner product produce steepest directions of a very different form.
- Find the minimizers of over and over , together with their minimal slopes, and state when each minimizer is unique.
- Let the parameter be a matrix whose gradient has reduced SVD , let the directional slope of be , and measure length by the spectral norm . Show that the minimal slope over is , attained at —the polar factor that Muon applies to its momentum matrix (Section 9.6). Writing is a helpful first step. This is the steepest-descent perspective of Bernstein and Newhouse (2024).
-
[code] Heavy ball: the double root and the factor . ● Apply heavy ball (23.1.12) to .
- Write one iteration as a linear map on the state and show that the characteristic polynomial of its matrix is (23.1.13).
- At the tuning (23.1.14), the two extreme modes have double eigenvalues and . Show that the matrix then has only a single eigenvector, and that the -th power of the Jordan block has entry above the diagonal.
- With and , solve numerically for and , and compare with the momentum cell's column , , .
- Run the momentum cell's heavy ball at and compare its step count with your prediction. Explain why the ratio never settles to a constant as grows.
-
[code] Heavy ball beyond quadratics. ● Lessard et al. (2016) define a one-dimensional function through its gradient:
- Show that is -strongly convex with and -smooth with .
- Run heavy ball with the tuning (23.1.14) for steps from with zero initial velocity, and run Nesterov's method (23.1.16) with and from the same start, where . Plot against for both methods.
- The heavy-ball iterates approach a period-three cycle that visits the piece twice and the piece once. Express the heavy-ball update across these pieces as a linear system for the three cycle points, solve it, and compare your solution with the simulation.
- Repeat the heavy-ball run from a grid of starting points on and report the fraction that land on the cycle. Every piece of is a quadratic with curvature in ; why does the per-mode analysis behind (23.1.15) fail to apply to ?
- [code] A lower bound for first-order methods. ● This problem derives the part of the bound of Nemirovski and Yudin (1983) quoted in Section 23.1.3 (the smooth convex case), following the construction of Nesterov (2018). Here, a first-order method is any algorithm whose iterates satisfy ; take . For , let be zero except for its leading block, which is tridiagonal with on the diagonal and on both off-diagonals, and define
- Show that is convex and -smooth.
- Show that if is supported on the first coordinates, then is supported on the first . Conclude that the -th iterate of every first-order method is supported on the first coordinates.
- Show that the minimizer of has entries for and zero beyond, that the minimum value is , and that .
- Let . The functions and agree on all vectors supported on the first coordinates. Use this fact to show that every first-order method applied to satisfies, with the minimizer of ,
Because the construction requires , the bound governs roughly the first iterations. In fixed dimension, long runs can eventually do better asymptotically, but for neural networks with in the millions this restriction never bites.
- For , run steps of gradient descent with and of Nesterov's update (23.1.16) with and at step on with , and divide each suboptimality gap by the lower bound. Which ratio stays bounded as grows?
- [code] Edge of stability with momentum. ●●
Cohen et al. (2021) report that when momentum is added, the
sharpness settles at a threshold different from .
- Use the iteration matrix from problem 5a to show that heavy ball (23.1.12) on with converges if and only if . Derive the corresponding stability interval for Nesterov's update (23.1.16).
- Modify the edge-of-stability experiment of Section 9.1.4 to train with heavy ball and with Nesterov's update for , choosing for each run a step size whose predicted threshold lies between and . Track the sharpness against both and your threshold from (a).
- At which threshold does the sharpness settle? What does this imply for choosing from a sharpness measured at initialization when training with momentum?