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 f(x,y)=12(x2+10 y2)f(x, y) = \tfrac12(x^2 + 10\,y^2), which curves ten times more steeply along yy than along xx, and start at (2,1)(2, 1), where f=7f = 7 and ∇f=(2,10)\nabla f = (2, 10). Taking a step of size η\eta against the gradient lands at (2−2η, 1−10η)(2 - 2\eta,\, 1 - 10\eta). With η=0.01\eta = 0.01, the loss barely budges, dropping to 6.016.01. With η=0.1\eta = 0.1, it falls sharply to 1.621.62. With η=0.25\eta = 0.25, it rises to 12.412.4. 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 yy-axis creeps along the flat xx-axis. Even the best fixed learning rate needs 6969 iterations to shrink the error by a factor of 10610^6 (six digits of accuracy). Stretch the curvature ratio to 10001000—our chapter's running example 12(x12+1000 x22)\tfrac12(x_1^2 + 1000\,x_2^2)—and gradient descent needs 6,9086{,}908 steps. Adding momentum brings that count down to 315315. We will work by hand on the gentler bowl, whose Hessian diag(1,10)\mathrm{diag}(1, 10) 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 κ\sqrt\kappa 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 −∇f-\nabla f without asking whether another direction might be better. To see why the negative gradient is the natural choice, expand f:Rd→Rf : \mathbb{R}^d \to \mathbb{R} to first order. A small step of size η>0\eta > 0 along a direction d\mathbf{d} changes the function value by

f(x+η d)=f(x)+η ∇f(x)⊤d+o(η).f(\mathbf{x} + \eta\,\mathbf{d}) = f(\mathbf{x}) + \eta\, \nabla f(\mathbf{x})^\top \mathbf{d} + o(\eta).

To first order, the change is simply η\eta times the directional derivative ∇f(x)⊤d\nabla f(\mathbf{x})^\top \mathbf{d}. We call d\mathbf{d} a descent direction at x\mathbf{x} whenever ∇f(x)⊤d<0\nabla f(\mathbf{x})^\top \mathbf{d} \lt 0.

Proposition (descent directions, and the steepest one). Let ff be differentiable at x\mathbf{x} with ∇f(x)≠0\nabla f(\mathbf{x}) \neq \mathbf{0}.

  1. If ∇f(x)⊤d<0\nabla f(\mathbf{x})^\top \mathbf{d} \lt 0, then f(x+η d)<f(x)f(\mathbf{x} + \eta\,\mathbf{d}) \lt f(\mathbf{x}) for every sufficiently small η>0\eta > 0.
  2. Among all unit vectors, the directional derivative is minimized uniquely by the normalized negative gradient:
min⁡∥d∥=1∇f(x)⊤d=−∥∇f(x)∥,attained only at d=−∇f(x)∥∇f(x)∥.(23.1.1)\begin{aligned} \min_{\|\mathbf{d}\| = 1} \nabla f(\mathbf{x})^\top \mathbf{d} &= -\|\nabla f(\mathbf{x})\|, \\ \textrm{attained only at }\mathbf{d} &= -\frac{\nabla f(\mathbf{x})}{\|\nabla f(\mathbf{x})\|}. \end{aligned} \tag{23.1.1}

Proof. For the first claim, define φ(η)=f(x+η d)\varphi(\eta) = f(\mathbf{x} + \eta\,\mathbf{d}). By the chain rule, φ′(0)=∇f(x)⊤d<0\varphi'(0) = \nabla f(\mathbf{x})^\top \mathbf{d} \lt 0, so the difference quotient (φ(η)−φ(0))/η(\varphi(\eta) - \varphi(0))/\eta is strictly negative for all sufficiently small η>0\eta > 0; hence φ(η)<φ(0)\varphi(\eta) \lt \varphi(0). For the second claim, the Cauchy--Schwarz inequality gives ∇f(x)⊤d≥−∥∇f(x)∥ ∥d∥=−∥∇f(x)∥\nabla f(\mathbf{x})^\top \mathbf{d} \ge -\|\nabla f(\mathbf{x})\|\,\|\mathbf{d}\| = -\|\nabla f(\mathbf{x})\| for every unit vector d\mathbf{d}, with equality if and only if d\mathbf{d} is a negative scalar multiple of ∇f(x)\nabla f(\mathbf{x}). The unique such unit vector is −∇f(x)/∥∇f(x)∥-\nabla f(\mathbf{x})/\|\nabla f(\mathbf{x})\|, and it attains the bound. ■\blacksquare

On our opening bowl, the steepest unit direction at (2,1)(2, 1) is −(2,10)/104=(−0.196,−0.981)-(2, 10)/\sqrt{104} = (-0.196, -0.981), with slope −∥∇f∥=−10.198-\|\nabla f\| = -10.198. The coordinate direction (−1,0)(-1, 0) also points downhill, but with a much gentler slope of −2-2. In fact, descent directions fill the entire open half-space of vectors making an acute angle with −∇f-\nabla f; 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, η=0.01\eta = 0.01, 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 η=0.01\eta = 0.01, each actual change matches η\eta 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) η>0\eta > 0:

xk+1=xk−η ∇f(xk).(23.1.2)\mathbf{x}_{k+1} = \mathbf{x}_k - \eta\, \nabla f(\mathbf{x}_k). \tag{23.1.2}

Throughout this section, kk indexes iterations and we abbreviate gk=∇f(xk)\mathbf{g}_k = \nabla f(\mathbf{x}_k). The first-order Taylor expansion justified the direction −gk-\mathbf{g}_k, but it says nothing about how far to trust it: once the iterate moves far enough that the gradient changes significantly, gk\mathbf{g}_k no longer describes ff. To certify a finite step size, we need a bound on how fast the gradient can vary.

Definition (LL-smoothness). A differentiable function ff is LL-smooth if its gradient changes by at most LL per unit of distance:

∥∇f(x)−∇f(y)∥  ≤  L ∥x−y∥for all x,y.(23.1.3)\|\nabla f(\mathbf{x}) - \nabla f(\mathbf{y})\| \;\le\; L\, \|\mathbf{x} - \mathbf{y}\| \qquad \textrm{for all } \mathbf{x}, \mathbf{y}. \tag{23.1.3}

When ff is twice continuously differentiable, LL-smoothness is equivalent to requiring every eigenvalue of its Hessian to lie in [−L,L][-L, L]. Bounded eigenvalues imply (23.1.3) by integrating the Hessian along the line segment from y\mathbf{y} to x\mathbf{x}, and the converse follows by taking a difference-quotient limit (exercise 2a). In short, LL caps the curvature in every direction. Our opening bowl has constant Hessian diag(1,10)\mathrm{diag}(1, 10), so L=10L = 10. By contrast, a function whose curvature grows without bound has no global smoothness constant: 14x4\tfrac14 x^4 has f′′(x)=3x2f''(x) = 3x^2, so no finite global LL 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:

f(y)  ≤  f(x)+∇f(x)⊤(y−x)+L2 ∥y−x∥2.(23.1.4)f(\mathbf{y}) \;\le\; f(\mathbf{x}) + \nabla f(\mathbf{x})^\top (\mathbf{y} - \mathbf{x}) + \tfrac{L}{2}\, \|\mathbf{y} - \mathbf{x}\|^2. \tag{23.1.4}

Geometrically, the graph of ff can never rise above its tangent plane at x\mathbf{x} by more than L2\tfrac{L}{2} times the squared distance. Before we prove this inequality, plug in a gradient step y=x−η g\mathbf{y} = \mathbf{x} - \eta\,\mathbf{g} and watch the two terms compete. The linear first-order decrease η ∥g∥2\eta\,\|\mathbf{g}\|^2 grows proportionally to η\eta, whereas the quadratic curvature penalty L2η2∥g∥2\tfrac{L}{2}\eta^2\|\mathbf{g}\|^2 grows as η2\eta^2. For small η\eta, the linear decrease wins; at η=2/L\eta = 2/L, the two terms exactly cancel.

Proposition (descent lemma). If ff is LL-smooth, then the gradient step (23.1.2) satisfies

f(xk+1)  ≤  f(xk)−η(1−Lη2)∥gk∥2.(23.1.5)f(\mathbf{x}_{k+1}) \;\le\; f(\mathbf{x}_k) - \eta \left(1 - \tfrac{L\eta}{2}\right) \|\mathbf{g}_k\|^2. \tag{23.1.5}

In particular, ff strictly decreases whenever 0<η<2/L0 \lt \eta \lt 2/L and gk≠0\mathbf{g}_k \neq \mathbf{0}. The guaranteed decrease is maximized at η=1/L\eta = 1/L, where f(xk+1)≤f(xk)−12L∥gk∥2f(\mathbf{x}_{k+1}) \le f(\mathbf{x}_k) - \tfrac{1}{2L}\|\mathbf{g}_k\|^2.

Proof. We first establish the quadratic ceiling (23.1.4). Restrict ff to the line segment between x\mathbf{x} and y\mathbf{y} via ψ(t)=f(x+t(y−x))\psi(t) = f(\mathbf{x} + t(\mathbf{y} - \mathbf{x})) for t∈[0,1]t \in [0, 1], so that ψ′(t)=∇f(x+t(y−x))⊤(y−x)\psi'(t) = \nabla f(\mathbf{x} + t(\mathbf{y}-\mathbf{x}))^\top (\mathbf{y} - \mathbf{x}). Applying the fundamental theorem of calculus, Cauchy--Schwarz, and the Lipschitz condition (23.1.3) yields

f(y)−f(x)−∇f(x)⊤(y−x)=∫01(∇f(x+t(y−x))−∇f(x))⊤(y−x) dt≤∫01L t ∥y−x∥2 dt=L2∥y−x∥2.\begin{aligned} f(\mathbf{y}) - f(\mathbf{x}) &- \nabla f(\mathbf{x})^\top (\mathbf{y}-\mathbf{x}) \\ &= \int_0^1 \big(\nabla f(\mathbf{x} + t(\mathbf{y}-\mathbf{x})) - \nabla f(\mathbf{x})\big)^\top (\mathbf{y}-\mathbf{x})\, dt \\ &\le \int_0^1 L\,t\, \|\mathbf{y}-\mathbf{x}\|^2\, dt = \tfrac{L}{2}\|\mathbf{y}-\mathbf{x}\|^2. \end{aligned}

Substituting the gradient step y=xk−η gk\mathbf{y} = \mathbf{x}_k - \eta\,\mathbf{g}_k gives

f(xk+1)  ≤  f(xk)−η ∥gk∥2+L2 η2 ∥gk∥2.f(\mathbf{x}_{k+1}) \;\le\; f(\mathbf{x}_k) - \eta\,\|\mathbf{g}_k\|^2 + \tfrac{L}{2}\,\eta^2\, \|\mathbf{g}_k\|^2.

The factor η(1−Lη/2)\eta(1 - L\eta/2) is strictly positive if and only if 0<η<2/L0 \lt \eta \lt 2/L, and it reaches its maximum at η=1/L\eta = 1/L. ■\blacksquare

Notice that the proof only compares gradients between xk\mathbf{x}_k and points along the segment to xk+1\mathbf{x}_{k+1}, so it suffices for ∇f\nabla f to be LL-Lipschitz on that segment. Let us test the lemma on our opening bowl, where ∥g∥2=104\|\mathbf{g}\|^2 = 104 and L=10L = 10. At η=1/L=0.1\eta = 1/L = 0.1, the bound guarantees f≤7−104/20=1.8f \le 7 - 104/20 = 1.8. At η=0.01\eta = 0.01, it guarantees f≤7−104⋅0.01⋅0.95=6.012f \le 7 - 104 \cdot 0.01 \cdot 0.95 = 6.012. At η=0.25>2/L\eta = 0.25 > 2/L, the factor 1−Lη/21 - L\eta/2 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: 6.01026.0102 lies just under 6.0126.012, and 1.621.62 sits cleanly below 1.81.8. At η=0.25\eta = 0.25, the bound 13.513.5 lies well above the starting value f=7f = 7, and indeed the step overshoots to 12.37512.375. Figure 23.1.1 plots both curves as functions of η\eta. Along the search direction, g⊤diag(1,10) g=1004\mathbf{g}^\top\mathrm{diag}(1, 10)\,\mathbf{g} = 1004, so the true objective is the parabola 7−104 η+502 η27 - 104\,\eta + 502\,\eta^2, while the quadratic ceiling is 7−104 η+520 η27 - 104\,\eta + 520\,\eta^2. The two parabolas hug each other so closely because this gradient points almost along the stiff axis, where the directional curvature is nearly LL.

Figure 23.1.1:

The descent lemma on the opening example. Along −g-\mathbf{g} from (2,1)(2,1), the true objective is the lower parabola and the quadratic ceiling f−η∥g∥2+L2η2∥g∥2f-\eta\|\mathbf{g}\|^2+\tfrac{L}{2}\eta^2\|\mathbf{g}\|^2 is the upper one, tangent at η=0\eta=0. Minimizing the ceiling at η=1/L=0.1\eta=1/L=0.1 guarantees f≤1.8f\le 1.8, and the step achieves 1.621.62. Beyond 2/L=0.22/L=0.2 the ceiling rises above the starting value and promises nothing; at η=0.25\eta=0.25 the objective climbs to 12.412.4.

In short, the step η=1/L\eta = 1/L minimizes the quadratic ceiling, and ff 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 ff be LL-smooth and bounded below by flowf_{\mathrm{low}}, and run (23.1.2) with η=1/L\eta = 1/L. Then for every K≥1K \ge 1,

min⁡0≤k<K∥∇f(xk)∥2  ≤  2L (f(x0)−flow)K.(23.1.6)\min_{0 \le k \lt K} \|\nabla f(\mathbf{x}_k)\|^2 \;\le\; \frac{2L\,\big(f(\mathbf{x}_0) - f_{\mathrm{low}}\big)}{K}. \tag{23.1.6}

Proof. At η=1/L\eta = 1/L, the descent lemma rearranges to ∥gk∥2≤2L (f(xk)−f(xk+1))\|\mathbf{g}_k\|^2 \le 2L\,(f(\mathbf{x}_k) - f(\mathbf{x}_{k+1})). Summing over k=0,…,K−1k = 0, \ldots, K-1, the right-hand side telescopes to 2L (f(x0)−f(xK))≤2L (f(x0)−flow)2L\,(f(\mathbf{x}_0) - f(\mathbf{x}_K)) \le 2L\,(f(\mathbf{x}_0) - f_{\mathrm{low}}). Because the minimum of KK numbers is at most their average, dividing by KK gives the bound. ■\blacksquare

Thus, among the first KK iterates, at least one has squared gradient norm O(1/K)O(1/K), using nothing beyond a lower bound on ff and a smoothness constant. Keep in mind that this result assumes a global LL; 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 f(x,y)=12x2+cos⁡yf(x, y) = \tfrac12 x^2 + \cos y, which is bounded below by −1-1 and 11-smooth (its Hessian diag(1,−cos⁡y)\mathrm{diag}(1, -\cos y) has eigenvalues in [−1,1][-1, 1]). Starting gradient descent with η=1\eta = 1 at (1,0)(1, 0) drives xx to 00 in a single step and never changes yy, since ∂f/∂y=−sin⁡y\partial f/\partial y = -\sin y vanishes at y=0y = 0. The algorithm halts at (0,0)(0, 0) with f=1f = 1—a saddle point where ff curves upward along xx and downward along yy, far from the true minimum value −1-1 at (0,π)(0, \pi). 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 (1,y0)(1, y_0) with any small y0≠0y_0 \neq 0 instead, and each step y←y+ηsin⁡yy \leftarrow y + \eta \sin y moves yy further from 00 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).

Using η=1/L\eta = 1/L presupposes that we know LL. In practice we rarely do, and even when a global LL 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 η\eta, it accepts the step only if the actual decrease achieves at least a fixed fraction c∈(0,1)c \in (0, 1) of the decrease predicted by the first-order model—the Armijo condition (or sufficient decrease condition) (Armijo, 1966):

f(x−η ∇f(x))  ≤  f(x)−c η ∥∇f(x)∥2.(23.1.7)f\big(\mathbf{x} - \eta\, \nabla f(\mathbf{x})\big) \;\le\; f(\mathbf{x}) - c\,\eta\, \|\nabla f(\mathbf{x})\|^2. \tag{23.1.7}

The right-hand side is simply the linear Taylor prediction with its slope scaled down by cc. Backtracking starts from an optimistic trial step η0\eta_0 and repeatedly halves η\eta until (23.1.7) is satisfied. By the descent lemma, the test is guaranteed to pass as soon as 1−Lη/2≥c1 - L\eta/2 \ge c, or equivalently η≤2(1−c)/L\eta \le 2(1-c)/L. Consequently, the loop always terminates in finitely many halvings and returns a step η≥min⁡(η0, (1−c)/L)\eta \ge \min\big(\eta_0,\, (1-c)/L\big)—within a factor of two of the theoretical threshold—without ever needing to know LL in advance.

Better still, this guarantee only requires LL on the region the iterates actually visit. Take the quartic f(x)=14x4f(x) = \tfrac14 x^4, which has no global LL, starting at x0=3x_0 = 3 with c=12c = \tfrac12. Because backtracking never increases ff, every iterate remains in [−3,3][-3, 3], where f′′(x)=3x2≤27f''(x) = 3x^2 \le 27. A trial step with η≤1/27\eta \le 1/27 sends xx to x(1−ηx2)x(1 - \eta x^2), which lies between 23x\tfrac23 x and xx, keeping the entire segment inside [−3,3][-3, 3] so that L=27L = 27 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 x0=3x_0 = 3: a fixed step η=0.3\eta = 0.3 (which would be completely safe near the origin) and backtracking starting from η0=1\eta_0 = 1.

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, ∣x6∣≈6.5×10103|x_6| \approx 6.5 \times 10^{103}. Because the update x↦x(1−ηx2)x \mapsto x(1 - \eta x^2) shrinks ∣x∣|x| if and only if ηx2<2\eta x^2 \lt 2, a fixed step from x0=3x_0 = 3 converges for η<2/9≈0.22\eta \lt 2/9 \approx 0.22 and diverges above it. Notice that this stability threshold is 2/92/9, not 2/f′′(x0)=2/272/f''(x_0) = 2/27; the 2/f′′(x0)2/f''(x_0) rule belongs to quadratics. A step toward the origin experiences the average of f′′f'' between 00 and xx (which is x2x^2) rather than its peak value 3x23x^2. 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 0.0310.031 on the first step. Its previous trial, 0.06250.0625, fails the Armijo test, which on this quartic holds if and only if ηx2≤0.456\eta x^2 \le 0.456 (roughly η≤0.05\eta \le 0.05 at x0=3x_0 = 3). As the iterate moves toward the origin and the curvature flattens, the accepted steps grow automatically (0.0625,0.125,0.25,0.5,1.00.0625, 0.125, 0.25, 0.5, 1.0, each close to 0.3/x20.3/x^2) 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 f′′(x)=3x2f''(x) = 3x^2 is unbounded, but it is large only where the gradient f′(x)=x3f'(x) = x^3 is large as well: 3x2≤4+∣x∣33x^2 \le 4 + |x|^3 for every xx. A twice differentiable function is (L0,L1)(L_0, L_1)-smooth if its curvature is bounded in this way by its gradient (Zhang et al., 2020):

∥∇2f(x)∥  ≤  L0+L1 ∥∇f(x)∥for all x,(23.1.8)\|\nabla^2 f(\mathbf{x})\| \;\le\; L_0 + L_1\, \|\nabla f(\mathbf{x})\| \qquad \textrm{for all } \mathbf{x}, \tag{23.1.8}

where the norm on the left is the largest absolute eigenvalue of the Hessian. Setting L1=0L_1 = 0 recovers LL-smoothness, and the quartic qualifies with L0=4L_0 = 4 and L1=1L_1 = 1. Under this condition, the step that the descent lemma can certify is no longer a constant 1/L1/L. It is of order 1/(L0+L1∥g∥)1/(L_0 + L_1\|\mathbf{g}\|): a fixed step where the gradient is small, and a fixed distance η ∥g∥\eta\,\|\mathbf{g}\| of order 1/L11/L_1 where it is large. Gradient clipping, which replaces g\mathbf{g} by min⁡(1,c/∥g∥) g\min(1, c/\|\mathbf{g}\|)\,\mathbf{g} for a threshold cc, takes steps of this form at no extra cost. On the quartic with c=1c = 1, the step η=0.3\eta = 0.3 that diverged above now moves xx by 0.30.3 per iteration until ∣x∣≤1|x| \le 1 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 6969 steps and another takes 6,9086{,}908. 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 diag(1,20)\mathrm{diag}(1, 20) with η=0.097\eta = 0.097, just below its stability ceiling 0.10.1, producing the contraction factors noted in the caption.)

Figure 23.1.2:

Gradient descent on two quadratics f(x)=12x⊤Axf(\mathbf{x})=\tfrac12\mathbf{x}^\top\mathbf{A}\mathbf{x}. 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 −0.94-0.94) while the slow axis contracts by only 0.900.90 per step.

Quadratics deserve a complete analysis because every smooth function looks like one near a strict minimum. Around a minimizer x⋆\mathbf{x}^\star with positive-definite Hessian A\mathbf{A}, the second-order Taylor expansion approximates ff by f(x⋆)+12(x−x⋆)⊤A (x−x⋆)f(\mathbf{x}^\star) + \tfrac12 (\mathbf{x}-\mathbf{x}^\star)^\top \mathbf{A}\, (\mathbf{x}-\mathbf{x}^\star). Shifting the minimizer to the origin and dropping the additive constant leaves our model problem:

f(x)=12 x⊤A x,A symmetric positive definite, with eigenvalues 0<λmin⁡=λ1≤⋯≤λd=λmax⁡.\begin{aligned} f(\mathbf{x}) &= \tfrac12\, \mathbf{x}^\top \mathbf{A}\, \mathbf{x}, \\ &\quad \mathbf{A} \textrm{ symmetric positive definite, with eigenvalues } 0 \lt \lambda_{\min} = \lambda_1 \le \cdots \le \lambda_d = \lambda_{\max}. \end{aligned}

Its gradient is Ax\mathbf{A}\mathbf{x} and its Hessian is A\mathbf{A}, so its smoothness constant is simply L=λmax⁡L = \lambda_{\max}. The ratio of the largest curvature to the smallest,

κ=λmax⁡λmin⁡,\kappa = \frac{\lambda_{\max}}{\lambda_{\min}},

is the condition number of the problem. It equals 1010 for our opening bowl diag(1,10)\mathrm{diag}(1, 10) and 10310^3 for the chapter's running example. Because A\mathbf{A} is symmetric positive definite, κ\kappa coincides with the singular-value ratio κ(A)\kappa(\mathbf{A}) 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 f(u)=λ2u2f(u) = \tfrac{\lambda}{2} u^2 with λ>0\lambda > 0. One gradient step sends uku_k to uk+1=uk−ηλuku_{k+1} = u_k - \eta\lambda u_k, so

uk+1=(1−ηλ) uk,uk=(1−ηλ)k u0.u_{k+1} = (1 - \eta\lambda)\, u_k, \qquad u_k = (1 - \eta\lambda)^k\, u_0 .

Every iteration simply multiplies the error by the same scalar factor 1−ηλ1 - \eta\lambda. Convergence occurs if and only if ∣1−ηλ∣<1|1 - \eta\lambda| \lt 1, meaning 0<η<2/λ0 \lt \eta \lt 2/\lambda. At the sweet spot η=1/λ\eta = 1/\lambda, the iterate lands on 00 in a single step. For 1/λ<η<2/λ1/\lambda \lt \eta \lt 2/\lambda, the factor is negative, so uku_k flips sign at every step while shrinking toward zero. For λ=10\lambda = 10, for instance, η=0.1\eta = 0.1 gives factor 00, η=0.19\eta = 0.19 gives −0.9-0.9, and η=0.21\eta = 0.21 gives −1.1-1.1, which diverges.

The dd-dimensional quadratic keeps the exact same structure. Since ∇f(x)=Ax\nabla f(\mathbf{x}) = \mathbf{A}\mathbf{x}, the update (23.1.2) becomes

xk+1=(I−ηA) xk.\mathbf{x}_{k+1} = (\mathbf{I} - \eta \mathbf{A})\, \mathbf{x}_k .

Each step applies the same linear operator, so after kk steps xk=(I−ηA)kx0\mathbf{x}_k = (\mathbf{I} - \eta\mathbf{A})^k\mathbf{x}_0. Because A\mathbf{A} is symmetric, it admits an orthonormal basis of eigenvectors (Section 21.3). Express xk\mathbf{x}_k in this eigenbasis with coordinates ui(k)u_i^{(k)}. The matrix I−ηA\mathbf{I} - \eta\mathbf{A} shares the same eigenvectors with eigenvalues 1−ηλi1 - \eta\lambda_i, so the coordinates decouple completely and evolve independently:

ui(k+1)=(1−ηλi) ui(k),henceui(k)=(1−ηλi)k ui(0).(23.1.9)u_i^{(k+1)} = (1 - \eta \lambda_i)\, u_i^{(k)}, \qquad \textrm{hence} \qquad u_i^{(k)} = (1 - \eta \lambda_i)^k\, u_i^{(0)}. \tag{23.1.9}

Thus, gradient descent on a dd-dimensional quadratic is nothing more than dd independent copies of the one-variable recursion—one per eigenvalue, or mode. Two consequences follow immediately from the factors 1−ηλi1 - \eta\lambda_i:

  • Convergence requires ∣1−ηλi∣<1|1 - \eta \lambda_i| \lt 1 for every mode, which reduces to 0<η<2/λmax⁡=2/L0 \lt \eta \lt 2/\lambda_{\max} = 2/L. This threshold is the stability ceiling. On quadratics, the bound 2/L2/L that the descent lemma guaranteed as sufficient is also strictly necessary. Push η\eta past it, and the stiffest mode's factor drops below −1-1: 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 ρ(η)k\rho(\eta)^k, where ρ(η)=max⁡i∣1−ηλi∣\rho(\eta) = \max_i |1 - \eta\lambda_i| is the spectral radius of I−ηA\mathbf{I} - \eta\mathbf{A}—the largest eigenvalue magnitude.

On A=diag(1,10)\mathbf{A} = \mathrm{diag}(1, 10), the stability ceiling is η=0.2\eta = 0.2. Before running the sweep below, predict which step size leaves the smallest error after 6060 steps from (1,1)(1, 1): the cautious 0.020.02, the descent-lemma favorite 0.1=1/L0.1 = 1/L, 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 η=0.02\eta = 0.02 is safe but sluggish (ρ=0.98\rho = 0.98, leaving an error of 0.30.3 after 6060 steps). At η=0.1\eta = 0.1, the stiff mode vanishes in a single step, yet the slow mode still limits the overall rate to ρ=0.9\rho = 0.9. Interestingly, η=0.19\eta = 0.19 shares that exact same rate ρ=0.9\rho = 0.9, for the opposite reason: now the stiff mode oscillates with factor −0.9-0.9. Between them, η=2/11≈0.182\eta = 2/11 \approx 0.182 balances both extremes and beats every other choice by two orders of magnitude (ρ=0.818\rho = 0.818, error 8.3×10−68.3 \times 10^{-6}). Right at the ceiling η=0.2\eta = 0.2, the stiff mode has factor −1-1, flipping between ±1\pm 1 forever so ∥x60∥=1.0\|\mathbf{x}_{60}\| = 1.0. Step just past it to η=0.21\eta = 0.21, and sixty iterations inflate the error to 3×1023 \times 10^{2}.

23.1.2.3 The Optimal Step#

Within the stable range, which fixed step size η\eta converges fastest? The sweep points directly to the answer: balance the two extreme modes. For any fixed η\eta, the map λ↦∣1−ηλ∣\lambda \mapsto |1 - \eta\lambda| traces a V-shape with its vertex at λ=1/η\lambda = 1/\eta. On the interval [λmin⁡,λmax⁡][\lambda_{\min}, \lambda_{\max}], a V-shaped function attains its maximum at one of the endpoints, so ρ(η)=max⁡(∣1−ηλmin⁡∣, ∣1−ηλmax⁡∣)\rho(\eta) = \max\big(|1 - \eta\lambda_{\min}|,\, |1 - \eta\lambda_{\max}|\big). Once η\eta passes 1/λmax⁡1/\lambda_{\max}, increasing it further helps the slow mode at λmin⁡\lambda_{\min} while hurting the stiff mode at λmax⁡\lambda_{\max}.

Proposition (optimal fixed step on a quadratic). For f(x)=12x⊤Axf(\mathbf{x}) = \tfrac12 \mathbf{x}^\top \mathbf{A} \mathbf{x}, the convergence factor ρ(η)=max⁡i∣1−ηλi∣\rho(\eta) = \max_i |1 - \eta\lambda_i| is minimized by

η⋆=2λmin⁡+λmax⁡,ρ(η⋆)=κ−1κ+1,κ=λmax⁡λmin⁡.(23.1.10)\eta^\star = \frac{2}{\lambda_{\min} + \lambda_{\max}}, \qquad \rho(\eta^\star) = \frac{\kappa - 1}{\kappa + 1}, \qquad \kappa = \frac{\lambda_{\max}}{\lambda_{\min}}. \tag{23.1.10}

Proof. For every η\eta, we have ρ(η)≥max⁡(1−ηλmin⁡, ηλmax⁡−1)\rho(\eta) \ge \max(1 - \eta\lambda_{\min},\, \eta\lambda_{\max} - 1), and the maximum of two numbers is at least any convex combination of them. Choosing the weights λmax⁡/(λmin⁡+λmax⁡)\lambda_{\max}/(\lambda_{\min}+\lambda_{\max}) and λmin⁡/(λmin⁡+λmax⁡)\lambda_{\min}/(\lambda_{\min}+\lambda_{\max}) makes the η\eta-terms cancel cleanly:

ρ(η)  ≥  λmax⁡(1−ηλmin⁡)+λmin⁡(ηλmax⁡−1)λmin⁡+λmax⁡=λmax⁡−λmin⁡λmax⁡+λmin⁡=κ−1κ+1.\rho(\eta) \;\ge\; \frac{\lambda_{\max}(1 - \eta\lambda_{\min}) + \lambda_{\min}(\eta\lambda_{\max} - 1)}{\lambda_{\min} + \lambda_{\max}} = \frac{\lambda_{\max} - \lambda_{\min}}{\lambda_{\max} + \lambda_{\min}} = \frac{\kappa - 1}{\kappa + 1}.

Equality holds only when the two terms agree, 1−ηλmin⁡=ηλmax⁡−11 - \eta\lambda_{\min} = \eta\lambda_{\max} - 1, which solves to η=η⋆\eta = \eta^\star. At η⋆\eta^\star, both endpoints equal (κ−1)/(κ+1)(\kappa - 1)/(\kappa + 1), and the V-shape keeps every interior eigenvalue below that height, so the bound is attained. ■\blacksquare

Figure 23.1.3 illustrates this proof on diag(1,10)\mathrm{diag}(1, 10): the optimal V is the one whose two endpoints sit at the same height. Here η⋆=2/11\eta^\star = 2/11 and ρ=9/11=0.818\rho = 9/11 = 0.818, so gaining six digits takes log⁡106/log⁡(11/9)≈69\log 10^6/\log(11/9) \approx 69 steps. On the chapter's running example (κ=1000\kappa = 1000), ρ=999/1001\rho = 999/1001, and those same six digits demand 6,9086{,}908 steps.

Figure 23.1.3:

The per-mode contraction factors ∣1−ηλ∣|1-\eta\lambda| form a V with its vertex at λ=1/η\lambda = 1/\eta, and the convergence factor ρ(η)\rho(\eta) is the larger of its values at the extreme eigenvalues λmin⁡=1\lambda_{\min} = 1 and λmax⁡=10\lambda_{\max} = 10. Choosing η=0.1\eta = 0.1 eliminates the stiff mode immediately but leaves the slow mode contracting at 0.90.9; the optimal step η⋆=2/(λmin⁡+λmax⁡)\eta^\star = 2/(\lambda_{\min} + \lambda_{\max}) equalizes both endpoints at (κ−1)/(κ+1)=9/11(\kappa-1)/(\kappa+1) = 9/11. Lowering either endpoint would raise the other.

When κ=1\kappa = 1 (a perfectly round bowl), ρ=0\rho = 0 and a single step lands on the minimum. For large κ\kappa, (κ−1)/(κ+1)≈1−2/κ(\kappa-1)/(\kappa+1) \approx 1 - 2/\kappa, so log⁡(1/ρ)≈2/κ\log(1/\rho) \approx 2/\kappa, and shrinking the error by a factor of ϵ\epsilon takes roughly κ2log⁡1ϵ\tfrac{\kappa}{2}\log\tfrac1\epsilon 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, η≲2/λmax⁡\eta \lesssim 2/\lambda_{\max}, leaving the flattest mode to advance by only η λmin⁡≈2/κ\eta\,\lambda_{\min} \approx 2/\kappa per iteration.

At η⋆\eta^\star, the factor ρ\rho is even stronger than an asymptotic rate. On diag(1,10)\mathrm{diag}(1, 10), the two per-mode factors are +9/11+9/11 and −9/11-9/11 (the η=2/11\eta = 2/11 row of the sweep): the slow mode contracts monotonically while the stiff mode alternates in sign. Because both coordinates shrink by the same magnitude, ∥xk∥\|\mathbf{x}_k\| contracts by (κ−1)/(κ+1)(\kappa-1)/(\kappa+1) 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 λmax⁡(∇2f)\lambda_{\max}(\nabla^2 f), and set η<2/λmax⁡\eta \lt 2/\lambda_{\max}. 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 2/η2/\eta 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 tanh⁡\tanh 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 1−ηλmax⁡1 - \eta\lambda_{\max}, which drops below −1-1 precisely when λmax⁡>2/η\lambda_{\max} > 2/\eta. 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 (2+2β)/η(2 + 2\beta)/\eta.

23.1.2.5 From Quadratics to Convex Functions#

What carries over beyond quadratics is the linear dependence on κ\kappa. A differentiable function is convex if it lies on or above each of its tangent planes, and μ\mu-strongly convex if it clears them by a quadratic margin, f(y)≥f(x)+∇f(x)⊤(y−x)+μ2∥y−x∥2f(\mathbf{y}) \ge f(\mathbf{x}) + \nabla f(\mathbf{x})^\top(\mathbf{y} - \mathbf{x}) + \tfrac{\mu}{2}\|\mathbf{y} - \mathbf{x}\|^2 for all x,y\mathbf{x}, \mathbf{y}; Section 23.3 develops both notions. If ff is LL-smooth and μ\mu-strongly convex, then at every point it is sandwiched between two quadratics of curvatures μ\mu and LL. The ratio κ=L/μ\kappa = L/\mu replaces λmax⁡/λmin⁡\lambda_{\max}/\lambda_{\min}, and gradient descent with η=1/L\eta = 1/L satisfies

f(xk)−f⋆≤(1−1κ)k(f(x0)−f⋆),(23.1.11)f(\mathbf{x}_k)-f^\star \le \Big(1-\frac{1}{\kappa}\Big)^k\big(f(\mathbf{x}_0)-f^\star\big), \tag{23.1.11}

which again requires O(κlog⁡1ϵ)O(\kappa\log\tfrac1\epsilon) iterations. If ff is smooth and convex without being strongly convex, gradient descent still converges to the global optimum, though at the slower sublinear rate O(1/k)O(1/k); 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 O(κ)O(\kappa) 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

vk+1=β vk−η ∇f(xk),xk+1=xk+vk+1,(23.1.12)\mathbf{v}_{k+1} = \beta\, \mathbf{v}_k - \eta\, \nabla f(\mathbf{x}_k), \qquad \mathbf{x}_{k+1} = \mathbf{x}_k + \mathbf{v}_{k+1}, \tag{23.1.12}

where β∈[0,1)\beta \in [0, 1) is the momentum parameter. The velocity vk\mathbf{v}_k is an exponentially decaying sum of past gradients. Since vk=xk−xk−1\mathbf{v}_k = \mathbf{x}_k - \mathbf{x}_{k-1}, eliminating v\mathbf{v} gives the equivalent two-step form

xk+1=xk−η ∇f(xk)+β (xk−xk−1).\mathbf{x}_{k+1} = \mathbf{x}_k - \eta\, \nabla f(\mathbf{x}_k) + \beta\,(\mathbf{x}_k - \mathbf{x}_{k-1}).

Each update takes a gradient step and adds β\beta times the previous displacement; setting β=0\beta = 0 recovers ordinary gradient descent.

On a quadratic, the modes once again decouple. In a single mode with gradient λuk\lambda u_k, the two-step update reads uk+1=(1+β−ηλ) uk−β uk−1u_{k+1} = (1 + \beta - \eta\lambda)\, u_k - \beta\, u_{k-1}, 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 1−β1 - \beta—where β\beta controls the damping.

Figure 23.1.4 displays the three resulting regimes on diag(1,10)\mathrm{diag}(1, 10), all using gradient descent's optimal step η=2/11\eta = 2/11. 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.

Figure 23.1.4:

Heavy ball on the κ=10\kappa=10 valley 12(x2+10y2)\tfrac12(x^2+10y^2), with all three runs using gradient descent's step η=2/11\eta=2/11. Too little momentum zigzags like gradient descent (the stiff mode's coefficient 1+β−ηλmax⁡1+\beta-\eta\lambda_{\max} is negative, giving a negative real root); the critically damped β\beta for this step is fastest; too much momentum spirals around the minimum. Reaching the optimal κ\sqrt\kappa rate of 0.520.52 requires the larger step ηHB\eta_{\mathrm{HB}} of (23.1.14), at which β=0.05\beta=0.05 would diverge.

23.1.3.2 The κ\sqrt{\kappa} Law#

We now show that with the right pair (η,β)(\eta, \beta), every mode contracts at the identical rate (κ−1)/(κ+1)(\sqrt\kappa - 1)/(\sqrt\kappa + 1). For κ=10\kappa = 10, this optimal pair is β⋆≈0.27\beta^\star \approx 0.27 and ηHB≈0.23\eta_{\mathrm{HB}} \approx 0.23, dropping the contraction factor from gradient descent's 0.820.82 to 0.520.52—reaching six digits in 2727 steps instead of 6969. Remarkably, the entire result follows from a single algebraic fact about one mode.

Proposition (heavy ball contracts every mode at β\sqrt\beta). Let 0<β<10 \lt \beta \lt 1. On f(u)=λ2u2f(u) = \tfrac{\lambda}{2}u^2, the heavy-ball iterates obey uk+1=(1+β−ηλ)uk−βuk−1u_{k+1} = (1 + \beta - \eta\lambda)u_k - \beta u_{k-1}. Whenever (1−β)2≤ηλ≤(1+β)2(1 - \sqrt\beta)^2 \le \eta\lambda \le (1 + \sqrt\beta)^2, both roots of the characteristic polynomial have modulus β\sqrt\beta, and ∣uk∣≤C k βk/2|u_k| \le C\,k\,\beta^{k/2} for k≥1k \ge 1 and a constant CC depending on u0u_0, u1u_1, and ηλ\eta\lambda. The linear factor kk is needed only at the two endpoints, where the root is repeated.

Proof. Substitute the trial solution uk=zku_k = z^k into the recurrence and divide by zk−1z^{k-1} to obtain the characteristic equation

z2−(1+β−ηλ) z+β=0.(23.1.13)z^2 - (1 + \beta - \eta\lambda)\, z + \beta = 0. \tag{23.1.13}

The product of the two roots is β\beta. They form a complex-conjugate pair whenever the discriminant (1+β−ηλ)2−4β(1 + \beta - \eta\lambda)^2 - 4\beta is negative, that is, when ∣1+β−ηλ∣<2β|1 + \beta - \eta\lambda| \lt 2\sqrt\beta, which rearranges to (1−β)2<ηλ<(1+β)2(1 - \sqrt\beta)^2 \lt \eta\lambda \lt (1 + \sqrt\beta)^2. Because complex conjugates z,zˉz, \bar z satisfy ∣z∣2=zzˉ=β|z|^2 = z\bar z = \beta, both roots have modulus β\sqrt\beta regardless of λ\lambda, and the general solution uk=azk+bzˉku_k = a z^k + b \bar z^k satisfies ∣uk∣≤(∣a∣+∣b∣)βk/2|u_k| \le (|a| + |b|)\beta^{k/2}. At the two endpoints, the discriminant vanishes and we get a double real root (1+β−ηλ)/2=±β(1 + \beta - \eta\lambda)/2 = \pm\sqrt\beta. A repeated root zz yields the general solution uk=(a+bk)zku_k = (a + bk)z^k, which accounts for the extra factor kk. ■\blacksquare

Corollary (the tuning). Place the two extreme modes right at the endpoints of the complex-root interval: ηλmin⁡=(1−β)2\eta\lambda_{\min} = (1 - \sqrt\beta)^2 and ηλmax⁡=(1+β)2\eta\lambda_{\max} = (1 + \sqrt\beta)^2. Every intermediate eigenvalue then falls inside the interval, so every single mode has root modulus β\sqrt\beta. Taking square roots gives ηλmax⁡−ηλmin⁡=2β\sqrt{\eta\lambda_{\max}} - \sqrt{\eta\lambda_{\min}} = 2\sqrt\beta and ηλmax⁡+ηλmin⁡=2\sqrt{\eta\lambda_{\max}} + \sqrt{\eta\lambda_{\min}} = 2. Solving the second equation for η\eta and dividing the first by the second gives β=(κ−1)/(κ+1)\sqrt\beta = (\sqrt\kappa - 1)/(\sqrt\kappa + 1). With the tuning

ηHB=(2λmax⁡+λmin⁡) ⁣2,β⋆=(κ−1κ+1) ⁣2,(23.1.14)\eta_{\mathrm{HB}} = \left(\frac{2}{\sqrt{\lambda_{\max}} + \sqrt{\lambda_{\min}}}\right)^{\!2}, \qquad \beta^\star = \left(\frac{\sqrt{\kappa} - 1}{\sqrt{\kappa} + 1}\right)^{\!2}, \tag{23.1.14}

heavy ball contracts every mode at the rate

ρHB=β⋆=κ−1κ+1  ≈  1−2κ.(23.1.15)\rho_{\mathrm{HB}} = \sqrt{\beta^\star} = \frac{\sqrt{\kappa} - 1}{\sqrt{\kappa} + 1} \;\approx\; 1 - \frac{2}{\sqrt{\kappa}}. \tag{23.1.15}

Compare this with (23.1.10): momentum replaces κ\kappa with κ\sqrt\kappa, slashing the iteration complexity from O(κlog⁡1ϵ)O(\kappa \log \tfrac1\epsilon) to O(κlog⁡1ϵ)O(\sqrt{\kappa} \log \tfrac1\epsilon) (Polyak, 1964). At finite kk, the double roots at the two extreme modes add a modest logarithmic overhead: the error scales as kρkk\rho^k, so with log⁡(1/ρ)≈2/κ\log(1/\rho) \approx 2/\sqrt\kappa, reaching accuracy ϵ\epsilon solves k≈κ2(log⁡1ϵ+log⁡k)k \approx \tfrac{\sqrt\kappa}{2}\big(\log\tfrac1\epsilon + \log k\big)—the asymptotic law plus a correction of order κlog⁡κ\sqrt\kappa\log\kappa.

Figure 23.1.5 makes this proof visual for κ=10\kappa = 10. On the left, the modulus of the dominant root sits flat at β\sqrt\beta 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 β⋆=0.52\sqrt{\beta^\star} = 0.52, whereas gradient descent's real multipliers stretch out to ±0.82\pm 0.82. 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 1−2/κ1 - 2/\kappa.

The proposition also explains the exact rates of the three trajectories in Figure 23.1.4, where η=2/11\eta = 2/11 places the two modes at ηλ=0.18\eta\lambda = 0.18 and 1.821.82. At β=0.85\beta = 0.85, both modes lie strictly inside the interval: the contraction rate is 0.85=0.92\sqrt{0.85} = 0.92, and the complex roots produce the spiraling overshoot. The smallest β\beta whose interval still captures the slow mode, β=(1−2/11)2≈0.33\beta = (1 - \sqrt{2/11})^2 \approx 0.33, is the fastest choice for this step size, achieving rate 0.570.57. At β=0.05\beta = 0.05, the interval [0.60,1.50][0.60, 1.50] misses both modes: the slow mode gets a real root 0.810.81, 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.

Figure 23.1.5:

Heavy ball at the tuning of (23.1.14) on the κ=10\kappa=10 example. (a) For fixed β\beta, the modulus of the larger root is flat at β\sqrt\beta 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 λ\lambda) lies on the circle of radius β⋆=0.52\sqrt{\beta^\star}=0.52, while gradient descent's factors span [−0.82,0.82][-0.82,0.82] on the real axis. The extreme modes are double roots, producing the factor kk in the error.

Be aware that this κ\sqrt\kappa 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 xk\mathbf{x}_k, but at the look-ahead point xk+β vk\mathbf{x}_k + \beta\,\mathbf{v}_k where momentum is about to carry us. Nesterov's accelerated gradient (Nesterov, 1983) updates via

vk+1=β vk−η ∇f(xk+β vk),xk+1=xk+vk+1.(23.1.16)\mathbf{v}_{k+1} = \beta\, \mathbf{v}_k - \eta\, \nabla f(\mathbf{x}_k + \beta\, \mathbf{v}_k), \qquad \mathbf{x}_{k+1} = \mathbf{x}_k + \mathbf{v}_{k+1}. \tag{23.1.16}

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 κ=L/μ\kappa = L/\mu. With η=1/L\eta = 1/L and β=(κ−1)/(κ+1)\beta = (\sqrt\kappa - 1)/(\sqrt\kappa + 1), every mode of a quadratic with eigenvalues in [μ,L][\mu, L] has characteristic roots of modulus at most 1−1/κ1 - 1/\sqrt\kappa, with a double root at the slow mode λ=μ\lambda = \mu. Consequently, the error is bounded by C k (1−1/κ)kC\,k\,(1 - 1/\sqrt\kappa)^k.

Proof. In a single mode with eigenvalue λ\lambda, write a=1−ηλ∈[0,1−1/κ]a = 1 - \eta\lambda \in [0, 1 - 1/\kappa]. The velocity update becomes vk+1=aβvk−ηλukv_{k+1} = a\beta v_k - \eta\lambda u_k, giving uk+1=auk+aβvku_{k+1} = a u_k + a\beta v_k. Substituting vk=uk−uk−1v_k = u_k - u_{k-1} yields the recurrence uk+1=(1+β)a uk−βa uk−1u_{k+1} = (1 + \beta)a\,u_k - \beta a\,u_{k-1}, whose characteristic polynomial z2−(1+β)a z+βaz^2 - (1 + \beta)a\,z + \beta a has discriminant a [(1+β)2a−4β]a\,[(1 + \beta)^2 a - 4\beta]. For our choice of β\beta, (1+β)2=4κ/(κ+1)2(1 + \beta)^2 = 4\kappa/(\sqrt\kappa + 1)^2. At the slow mode a=(κ−1)/κa = (\kappa - 1)/\kappa, the bracket evaluates to 4(κ−1)/(κ+1)2−4β=4β−4β=04(\kappa - 1)/(\sqrt\kappa + 1)^2 - 4\beta = 4\beta - 4\beta = 0, giving a double root at (1+β)a/2=(κ−1)/κ=1−1/κ(1 + \beta)a/2 = (\sqrt\kappa - 1)/\sqrt\kappa = 1 - 1/\sqrt\kappa. Every stiffer mode has a smaller aa, making the bracket strictly negative and producing complex roots (or roots at 00 when a=0a = 0) of modulus βa<β(1−1/κ)=1−1/κ\sqrt{\beta a} \lt \sqrt{\beta(1 - 1/\kappa)} = 1 - 1/\sqrt\kappa. ■\blacksquare

On quadratics, Nesterov's contraction factor is 0.6840.684 for κ=10\kappa = 10, 0.9000.900 for κ=100\kappa = 100, and 0.9680.968 for κ=1000\kappa = 1000—slightly slower than heavy ball's 0.5190.519, 0.8180.818, and 0.9390.939, yet preserving the same κ\sqrt\kappa scaling. Crucially, unlike heavy ball, Nesterov's method keeps its guarantees beyond quadratics, which we state here without proof (Nesterov, 2018). On every μ\mu-strongly convex, LL-smooth function, Nesterov's update with the same constant β\beta satisfies f(xk)−f⋆≤C (1−1/κ)kf(\mathbf{x}_k) - f^\star \le C\,(1 - 1/\sqrt\kappa)^k. (Mind the units: this bounds the function gap f−f⋆f - f^\star, 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 βk→1\beta_k \to 1 achieves f(xk)−f⋆=O(1/k2)f(\mathbf{x}_k) - f^\star = O(1/k^2), improving on gradient descent's O(1/k)O(1/k). Moreover, this speed cannot be beaten in general: no method that builds its iterates solely from past gradients can surpass O(1/k2)O(1/k^2) or the κ\sqrt\kappa 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 diag(1,κ)\mathrm{diag}(1, \kappa) starting from (1,1)(1, 1), gaining six digits should cost gradient descent roughly κ2log⁡106≈6.9 κ\tfrac{\kappa}{2}\log 10^6 \approx 6.9\,\kappa steps and heavy ball somewhat more than 6.9κ6.9\sqrt\kappa.

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 κ\kappa stays pinned at 6.96.9, reaching 6,9086{,}908 iterations at κ=1000\kappa = 1000, while heavy ball finishes in just 315315. Notice that heavy ball's ratio k/κk/\sqrt\kappa drifts gently upward (8.58.5, 9.39.3, 10.010.0) because each extreme mode has a double root: its 2×22\times 2 iteration matrix forms a Jordan block, a repeated eigenvalue with only a single eigenvector (Section 21.3.1.5), whose kk-th power brings in the factor kk. The refined prediction k≈κ2(log⁡106+log⁡k)k \approx \tfrac{\sqrt\kappa}{2}(\log 10^6 + \log k) matches closely (8.68.6, 9.29.2, 9.89.8), and at κ=104\kappa = 10^4, heavy ball takes 1,0561{,}056 steps, a ratio of 10.610.6 (exercise 5). Nesterov's 508508 iterations at κ=1000\kappa = 1000 sit cleanly between the two, just as its contraction factor 0.9680.968 versus heavy ball's 0.9390.939 predicts. Because all three methods evaluate only one gradient per step, momentum's speedup costs no extra gradient work. Yet κ\sqrt\kappa 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 κ\kappa 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 LL-smooth objective, descent is guaranteed up to η=2/L\eta = 2/L. On a quadratic, the best fixed step contracts the error by (κ−1)/(κ+1)(\kappa - 1)/(\kappa + 1) per iteration, forcing the step count to grow linearly with the condition number κ\kappa because stability is governed by the stiffest mode while progress is governed by the flattest. Momentum equalizes every mode at the shared contraction rate β\sqrt\beta, and its tuned factor (κ−1)/(κ+1)(\sqrt\kappa - 1)/(\sqrt\kappa + 1) cuts the iteration count from O(κ)O(\kappa) to O(κ)O(\sqrt\kappa) at no extra gradient cost. On neural networks, sharpness rises to the stability ceiling 2/η2/\eta 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#

  1. 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.

    1. Show that d=−P−1∇f(x)\mathbf{d} = -\mathbf{P}^{-1}\nabla f(\mathbf{x}) is a descent direction for every positive definite matrix P\mathbf{P}.
    2. Measure length by ∥d∥P=d⊤P d\|\mathbf{d}\|_{\mathbf{P}} = \sqrt{\mathbf{d}^\top \mathbf{P}\, \mathbf{d}}. Show that the minimizer of ∇f(x)⊤d\nabla f(\mathbf{x})^\top \mathbf{d} over ∥d∥P=1\|\mathbf{d}\|_{\mathbf{P}} = 1 is proportional to −P−1∇f(x)-\mathbf{P}^{-1}\nabla f(\mathbf{x}), and identify the P\mathbf{P} that recovers Newton's direction −(∇2f(x))−1∇f(x)-\big(\nabla^2 f(\mathbf{x})\big)^{-1}\nabla f(\mathbf{x}), the subject of Section 23.2. The change of variables u=P1/2d\mathbf{u} = \mathbf{P}^{1/2}\mathbf{d} reduces the problem to the Euclidean case.
  2. [code] Smoothness constants. The smoothness constant LL of (23.1.3) bounds the curvature of ff, and for a logistic loss it can be computed directly from the data.

    1. Let ff be twice continuously differentiable and LL-smooth. Show that ∥∇2f(x) v∥≤L ∥v∥\|\nabla^2 f(\mathbf{x})\,\mathbf{v}\| \le L\,\|\mathbf{v}\| for all x\mathbf{x} and v\mathbf{v}, and conclude that every Hessian eigenvalue lies in [−L,L][-L, L]. This establishes the converse direction of the equivalence stated after (23.1.3).
    2. Consider
f(w)=1n∑i=1nlog⁡(1+exp⁡(−yi xi⊤w))+ν2∥w∥2f(\mathbf{w}) = \frac1n \sum_{i=1}^n \log\big(1 + \exp(-y_i\, \mathbf{x}_i^\top \mathbf{w})\big) + \frac{\nu}{2}\|\mathbf{w}\|^2

with labels yi=±1y_i = \pm 1 and ν=0.1\nu = 0.1—the loss function that we will use in the data cell of Section 23.2.1, where xi⊤\mathbf{x}_i^\top is the ii-th row of X∈Rn×d\mathbf{X} \in \mathbb{R}^{n \times d} (n=200n = 200, d=5d = 5, with independent standard Gaussian entries). Show that L=λmax⁡(X⊤X)/(4n)+νL = \lambda_{\max}(\mathbf{X}^\top \mathbf{X})/(4n) + \nu is a valid smoothness constant and that the Hessian attains this bound at w=0\mathbf{w} = \mathbf{0}.

  1. Compute this LL for a 200×5200 \times 5 matrix X\mathbf{X} of standard Gaussian entries and labels yi∈{±1}y_i \in \{\pm 1\} drawn with P(yi=1)=1/(1+exp⁡(−xi⊤wtrue))P(y_i = 1) = 1/(1 + \exp(-\mathbf{x}_i^\top \mathbf{w}_{\mathrm{true}})) for wtrue=(1,−2,1.5,0,2)\mathbf{w}_{\mathrm{true}} = (1, -2, 1.5, 0, 2). It comes out near 0.40.4 for every draw; explain why using λmax⁡(X⊤X)/n≈(1+d/n)2\lambda_{\max}(\mathbf{X}^\top\mathbf{X})/n \approx (1 + \sqrt{d/n})^2 for standard Gaussian entries. Count how many steps η=0.5\eta = 0.5 (the reference step) and η=1/L\eta = 1/L each need from w=0\mathbf{w} = \mathbf{0} to reach ∥∇f(w)∥≤10−10\|\nabla f(\mathbf{w})\| \le 10^{-10}. Which is faster, and does η=0.5\eta = 0.5 stay below 2/L2/L?
  1. [code] Clipping on the quartic. Take f(x)=14x4f(x) = \tfrac14 x^4 and the clipped update x←x−ηmin⁡(1,c/∣g∣) gx \leftarrow x - \eta \min(1, c/|g|)\, g with g=x3g = x^3.

    1. Show that 3x2≤4+∣x∣33x^2 \le 4 + |x|^3 for all xx, with equality at ∣x∣=2|x| = 2, so that ff satisfies (23.1.8) with L0=4L_0 = 4 and L1=1L_1 = 1. Show also that no L0L_0 works with L1=0L_1 = 0.
    2. Run the clipped update from x0=3x_0 = 3 with η=0.3\eta = 0.3 and c=1c = 1, the step at which the unclipped iteration reached 6.5×101036.5 \times 10^{103} in six steps. How many steps are clipped, and how far does each of them move xx?
    3. Show that the clipped update decreases ∣x∣|x| at every step, from every starting point x0≠0x_0 \neq 0, whenever η c2/3<2\eta\, c^{2/3} \lt 2. Treat the clipped case ∣x∣>c1/3|x| > c^{1/3} and the unclipped case separately. Why can no fixed step without clipping have this property?
  2. Steepest descent in other norms. ● Problem 1b measures length by a norm ∥⋅∥P\|\cdot\|_{\mathbf{P}} induced by an inner product. Norms that do not come from an inner product produce steepest directions of a very different form.

    1. Find the minimizers of ∇f(x)⊤d\nabla f(\mathbf{x})^\top \mathbf{d} over ∥d∥∞=1\|\mathbf{d}\|_\infty = 1 and over ∥d∥1=1\|\mathbf{d}\|_1 = 1, together with their minimal slopes, and state when each minimizer is unique.
    2. Let the parameter be a matrix whose gradient G\mathbf{G} has reduced SVD G=U diag(σi) V⊤\mathbf{G} = \mathbf{U}\, \mathrm{diag}(\sigma_i)\, \mathbf{V}^\top, let the directional slope of D\mathbf{D} be tr⁡(G⊤D)\operatorname{tr}(\mathbf{G}^\top \mathbf{D}), and measure length by the spectral norm ∥D∥2\|\mathbf{D}\|_2. Show that the minimal slope over ∥D∥2≤1\|\mathbf{D}\|_2 \le 1 is −∑iσi-\sum_i \sigma_i, attained at D=−UV⊤\mathbf{D} = -\mathbf{U} \mathbf{V}^\top—the polar factor that Muon applies to its momentum matrix (Section 9.6). Writing tr⁡(G⊤D)=∑iσi ui⊤D vi\operatorname{tr}(\mathbf{G}^\top \mathbf{D}) = \sum_i \sigma_i\, \mathbf{u}_i^\top \mathbf{D}\, \mathbf{v}_i is a helpful first step. This is the steepest-descent perspective of Bernstein and Newhouse (2024).
  3. [code] Heavy ball: the double root and the factor kk. ● Apply heavy ball (23.1.12) to f(u)=λ2u2f(u) = \tfrac{\lambda}{2} u^2.

    1. Write one iteration as a linear map on the state (uk,uk−1)(u_k, u_{k-1}) and show that the characteristic polynomial of its 2×22 \times 2 matrix is (23.1.13).
    2. At the tuning (23.1.14), the two extreme modes have double eigenvalues β⋆\sqrt{\beta^\star} and −β⋆-\sqrt{\beta^\star}. Show that the matrix then has only a single eigenvector, and that the kk-th power of the Jordan block (ρ10ρ)\left(\begin{smallmatrix}\rho&1\\0&\rho\end{smallmatrix}\right) has entry kρk−1k\rho^{k-1} above the diagonal.
    3. With ∥ek∥≈kρk\|\mathbf{e}_k\| \approx k\rho^k and log⁡(1/ρ)≈2/κ\log(1/\rho) \approx 2/\sqrt\kappa, solve k=κ2(log⁡1ϵ+log⁡k)k = \tfrac{\sqrt\kappa}{2}\big(\log\tfrac1\epsilon + \log k\big) numerically for ϵ=10−6\epsilon = 10^{-6} and κ∈{10,100,1000}\kappa \in \{10, 100, 1000\}, and compare k/κk/\sqrt\kappa with the momentum cell's column 8.58.5, 9.39.3, 10.010.0.
    4. Run the momentum cell's heavy ball at κ=104\kappa = 10^4 and compare its step count with your prediction. Explain why the ratio k/κk/\sqrt\kappa never settles to a constant as κ\kappa grows.
  4. [code] Heavy ball beyond quadratics. ● Lessard et al. (2016) define a one-dimensional function through its gradient:

∇f(x)={25x,x<1,x+24,1≤x<2,25x−24,x≥2.\nabla f(x) = \begin{cases} 25x, & x \lt 1, \\ x + 24, & 1 \le x \lt 2, \\ 25x - 24, & x \ge 2. \end{cases}
  1. Show that ff is μ\mu-strongly convex with μ=1\mu = 1 and LL-smooth with L=25L = 25.
  2. Run heavy ball with the tuning (23.1.14) for 300300 steps from x0=3.3x_0 = 3.3 with zero initial velocity, and run Nesterov's method (23.1.16) with η=1/L\eta = 1/L and β=(κ−1)/(κ+1)\beta = (\sqrt{\kappa} - 1)/(\sqrt{\kappa} + 1) from the same start, where κ=L/μ\kappa = L/\mu. Plot xkx_k against kk for both methods.
  3. The heavy-ball iterates approach a period-three cycle that visits the piece x<1x \lt 1 twice and the piece x≥2x \ge 2 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.
  4. Repeat the heavy-ball run from a grid of starting points on [−6,6][-6, 6] and report the fraction that land on the cycle. Every piece of ff is a quadratic with curvature in [μ,L][\mu, L]; why does the per-mode analysis behind (23.1.15) fail to apply to ff?
  1. [code] A lower bound for first-order methods. ● This problem derives the O(1/k2)O(1/k^2) 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 xk∈x0+span{∇f(x0),…,∇f(xk−1)}\mathbf{x}_k \in \mathbf{x}_0 + \mathrm{span}\{\nabla f(\mathbf{x}_0), \ldots, \nabla f(\mathbf{x}_{k-1})\}; take x0=0\mathbf{x}_0 = \mathbf{0}. For p≤dp \le d, let Ap∈Rd×d\mathbf{A}_p \in \mathbb{R}^{d \times d} be zero except for its leading p×pp \times p block, which is tridiagonal with 22 on the diagonal and −1-1 on both off-diagonals, and define
fp(x)=L4(12 x⊤Ap x−x1).f_p(\mathbf{x}) = \frac{L}{4} \left( \tfrac12\, \mathbf{x}^\top \mathbf{A}_p\, \mathbf{x} - x_1 \right).
  1. Show that fpf_p is convex and LL-smooth.
  2. Show that if x\mathbf{x} is supported on the first jj coordinates, then ∇fp(x)\nabla f_p(\mathbf{x}) is supported on the first j+1j + 1. Conclude that the kk-th iterate of every first-order method is supported on the first kk coordinates.
  3. Show that the minimizer of fpf_p has entries xi⋆=1−i/(p+1)x_i^\star = 1 - i/(p+1) for i≤pi \le p and zero beyond, that the minimum value is −L8(1−1p+1)-\frac{L}{8}\big(1 - \frac{1}{p+1}\big), and that ∥x⋆∥2≤(p+1)/3\|\mathbf{x}^\star\|^2 \le (p+1)/3.
  4. Let 2k+1≤d2k + 1 \le d. The functions f2k+1f_{2k+1} and fkf_k agree on all vectors supported on the first kk coordinates. Use this fact to show that every first-order method applied to f2k+1f_{2k+1} satisfies, with x⋆\mathbf{x}^\star the minimizer of f2k+1f_{2k+1},
f2k+1(xk)−min⁡f2k+1  ≥  3L ∥x0−x⋆∥232 (k+1)2.f_{2k+1}(\mathbf{x}_k) - \min f_{2k+1} \;\ge\; \frac{3L\, \|\mathbf{x}_0 - \mathbf{x}^\star\|^2}{32\,(k+1)^2}.

Because the construction requires d≥2k+1d \ge 2k + 1, the bound governs roughly the first d/2d/2 iterations. In fixed dimension, long runs can eventually do better asymptotically, but for neural networks with dd in the millions this restriction never bites.

  1. For k∈{5,10,25,50,100,200,400}k \in \{5, 10, 25, 50, 100, 200, 400\}, run kk steps of gradient descent with η=1/L\eta = 1/L and of Nesterov's update (23.1.16) with η=1/L\eta = 1/L and βj=(j−1)/(j+2)\beta_j = (j-1)/(j+2) at step j=1,2,…j = 1, 2, \ldots on f2k+1f_{2k+1} with d=2k+1d = 2k + 1, and divide each suboptimality gap by the lower bound. Which ratio stays bounded as kk grows?
  1. [code] Edge of stability with momentum. ●● Cohen et al. (2021) report that when momentum is added, the sharpness settles at a threshold different from 2/η2/\eta.
    1. Use the iteration matrix from problem 5a to show that heavy ball (23.1.12) on f(x)=λ2x2f(x) = \tfrac{\lambda}{2} x^2 with 0≤β<10 \le \beta \lt 1 converges if and only if 0<ηλ<2+2β0 \lt \eta\lambda \lt 2 + 2\beta. Derive the corresponding stability interval for Nesterov's update (23.1.16).
    2. Modify the edge-of-stability experiment of Section 9.1.4 to train with heavy ball and with Nesterov's update for β∈{0.25,0.5}\beta \in \{0.25, 0.5\}, choosing for each run a step size whose predicted threshold lies between 55 and 1212. Track the sharpness against both 2/η2/\eta and your threshold from (a).
    3. At which threshold does the sharpness settle? What does this imply for choosing η\eta from a sharpness measured at initialization when training with momentum?

Discussions