Type at least 2 letters. Enter opens the first result, Esc closes.

    Optimization · Lesson 3 · Gradient descent and curvature

    Convergence rates of gradient descent and line search

    Intermediate 70 min 4 interactive figures 3 videos Colab notebook

    Before this lesson: lesson 01 (the gradient descent update and the 1D factor 1−ηλ1 - \eta\lambda), lesson 02 (LL-smoothness, strong convexity, the descent lemma, the PL inequality and κ=L/μ\kappa = L/\mu), and linear algebra 06 (a symmetric matrix has an orthonormal basis of eigenvectors). Time: about 70 minutes, plus the notebook.


    Why this matters #

    Every optimizer you use is gradient descent plus something: SGD adds noise, momentum adds memory, Adam adds a per-coordinate scale. The theory of plain gradient descent answers three practical questions. How large can the learning rate be before training diverges? (η<2/λmax⁡\eta < 2/\lambda_{\max}.) How many steps are needed? (About κlog⁡(1/ε)\kappa\log(1/\varepsilon) for strongly convex problems, about 1/ε1/\varepsilon for convex ones.) How do we choose the step without knowing LL? (A line search. It is standard in full-batch problems such as scientific fits, scipy.optimize.minimize and L-BFGS. In stochastic deep learning, a hand-tuned schedule replaces it; see lesson 07.)

    1. Predict first #

    2. The picture #

    Notation for the whole lesson: x⋆x^\star is a minimizer, f⋆=f(x⋆)f^\star = f(x^\star), and ek=xk−x⋆e_k = x_k - x^\star is the error after kk steps.

    One dimension (lesson 01). For f(x)=λ2x2f(x) = \tfrac{\lambda}{2}x^2, one step gives xk+1=xk−ηλxk=(1−ηλ)xkx_{k+1} = x_k - \eta\lambda x_k = (1 - \eta\lambda)x_k. So xk=(1−ηλ)kx0x_k = (1 - \eta\lambda)^k x_0. The error shrinks exactly when ∣1−ηλ∣<1|1 - \eta\lambda| < 1, that is, when 0<η<2/λ0 < \eta < 2/\lambda.

    Two dimensions. Take f(x)=12x⊤Axf(x) = \tfrac12 x^\top A x with a symmetric positive definite AA. Write its eigenvalues as μ=λ1≤λ2=L\mu = \lambda_1 \le \lambda_2 = L, with orthonormal eigenvectors q1q_1 (the flat direction) and q2q_2 (the steep direction). Write the error in this basis: ek=c1,k q1+c2,k q2e_k = c_{1,k}\,q_1 + c_{2,k}\,q_2. The gradient is Aek=λ1c1,kq1+λ2c2,kq2Ae_k = \lambda_1 c_{1,k}q_1 + \lambda_2 c_{2,k}q_2, so one step gives

    c1,k+1=(1−ημ) c1,k,c2,k+1=(1−ηL) c2,k.c_{1,k+1} = (1 - \eta\mu)\,c_{1,k}, \qquad c_{2,k+1} = (1 - \eta L)\,c_{2,k}.

    The two components do not interact. Each one is a 1D problem from lesson 01, with its own factor.

    Interactive figure: loading…

    Press Play, then try the three presets (the slider η⋅L/2\eta \cdot L/2 is the step in units of 2/L2/L). The contours belong to f=12x⊤Axf = \tfrac12 x^\top A x with μ=1\mu = 1 and L=κL = \kappa; the dashed lines are the eigen-directions q1q_1 (flat) and q2q_2 (steep). The blue path is gradient descent. The bars show the two error components with their sign. With η=1/L\eta = 1/L the steep component dies in one step, and the flat one shrinks by only 1−1/κ1 - 1/\kappa per step. With η=0.97⋅2/L\eta = 0.97 \cdot 2/L the steep component flips sign at every step (zig-zag). On the log chart, the blue curve ∥ek∥\|e_k\| always ends up parallel to the slower dashed line.

    One step size for all directions. The total error shrinks only as fast as the slowest component. So the factor per step is the larger of the two:

    ρ(η)=max⁡(∣1−ημ∣, ∣1−ηL∣).\rho(\eta) = \max\big(|1 - \eta\mu|,\ |1 - \eta L|\big).

    Plot both terms against η\eta: each is a V shape. ∣1−ημ∣|1 - \eta\mu| has its tip at η=1/μ\eta = 1/\mu, and ∣1−ηL∣|1 - \eta L| has its tip at η=1/L\eta = 1/L. A small η\eta makes the flat factor close to 1 (slow). A large η\eta makes the steep factor larger than 1 (divergence). The best compromise is where the two V's cross.

    Interactive figure: loading…

    Drag on the chart to move the step size η\eta (or use the slider η⋅L/2\eta \cdot L/2, the step in units of 2/L2/L). The aqua V is ∣1−ημ∣|1 - \eta\mu|, the magenta V is ∣1−ηL∣|1 - \eta L|, and the thick dark curve is their maximum ρ(η)\rho(\eta). Above the dashed line ρ=1\rho = 1 there is no convergence: this starts at the yellow line 2/L2/L. The lowest point of the thick curve is the best step η⋆=2/(μ+L)\eta^\star = 2/(\mu + L). Change μ\mu and LL: the best factor depends only on κ=L/μ\kappa = L/\mu.

    From a factor to a number of steps. If ∥ek∥≤ρk∥e0∥\|e_k\| \le \rho^k\|e_0\|, then ∥ek∥≤ε∥e0∥\|e_k\| \le \varepsilon\|e_0\| as soon as ρk≤ε\rho^k \le \varepsilon, that is, after

    k  ≥  ln⁡(1/ε)ln⁡(1/ρ) steps.k \;\ge\; \frac{\ln(1/\varepsilon)}{\ln(1/\rho)} \text{ steps.}

    For ρ=0.9\rho = 0.9 and ε=10−6\varepsilon = 10^{-6} this is 13.8/0.105≈13113.8/0.105 \approx 131 steps. For ρ\rho close to 1, ln⁡(1/ρ)≈1−ρ\ln(1/\rho) \approx 1 - \rho, so the number of steps is about ln⁡(1/ε)/(1−ρ)\ln(1/\varepsilon)/(1 - \rho).

    Quick check

    ff is a quadratic with κ=L/μ=100\kappa = L/\mu = 100. With the best fixed step 2/(μ+L)2/(\mu + L), about how many steps reduce ∥ek∥\|e_k\| by a factor 10610^6?

    Quick check

    A quadratic has μ=1\mu = 1 and L=10L = 10. You choose η=1/μ=1\eta = 1/\mu = 1, the step that solves the flat direction in one step. What happens?

    3. Definitions and main results #

    Throughout this section μ\mu and LL are the strong convexity and smoothness constants of lesson 02, and κ=L/μ\kappa = L/\mu. For a quadratic with Hessian AA, they are μ=λmin⁡(A)\mu = \lambda_{\min}(A) and L=λmax⁡(A)L = \lambda_{\max}(A).

    Linear and sublinear convergence #

    A sequence of errors converges linearly with factor ρ<1\rho < 1 if it is bounded by CρkC\rho^k. On a log scale this is a straight line going down. Every digit of accuracy costs the same number of steps, ln⁡10/ln⁡(1/ρ)\ln 10/\ln(1/\rho). A sequence converges sublinearly if it goes to zero more slowly than every CρkC\rho^k, for example like C/kC/k. On a log scale the curve bends and flattens: with C/kC/k, each new digit costs ten times more steps than the one before.

    Theorem 1 (gradient descent on a quadratic) #

    Let f(x)=12x⊤Ax−b⊤xf(x) = \tfrac12 x^\top A x - b^\top x with AA symmetric and all eigenvalues in [μ,L][\mu, L], μ>0\mu > 0. Gradient descent with a fixed step η\eta satisfies ∥ek∥≤ρ(η)k∥e0∥\|e_k\| \le \rho(\eta)^k\|e_0\| with

    ρ(η)=max⁡(∣1−ημ∣, ∣1−ηL∣).\rho(\eta) = \max\big(|1 - \eta\mu|,\ |1 - \eta L|\big).

    It converges from every x0x_0 if and only if 0<η<2/λmax⁡(A)0 < \eta < 2/\lambda_{\max}(A). The best fixed step is η⋆=2/(μ+L)\eta^\star = 2/(\mu + L), with factor ρ⋆=(κ−1)/(κ+1)\rho^\star = (\kappa - 1)/(\kappa + 1). The step 1/L1/L gives ρ=1−1/κ\rho = 1 - 1/\kappa.

    Proof.

    1. The minimizer solves Ax⋆=bAx^\star = b. So ∇f(xk)=Axk−b=A(xk−x⋆)=Aek\nabla f(x_k) = Ax_k - b = A(x_k - x^\star) = Ae_k, and ek+1=ek−ηAek=(I−ηA) eke_{k+1} = e_k - \eta A e_k = (I - \eta A)\,e_k.
    2. Write A=QΛQ⊤A = Q\Lambda Q^\top with orthonormal eigenvectors qiq_i and eigenvalues λi\lambda_i. The component of the error along qiq_i is multiplied by 1−ηλi1 - \eta\lambda_i at every step. Because the qiq_i are orthonormal, ∥ek∥2=∑i(1−ηλi)2kci,02≤max⁡i∣1−ηλi∣2k ∥e0∥2\|e_k\|^2 = \sum_i (1 - \eta\lambda_i)^{2k} c_{i,0}^2 \le \max_i |1 - \eta\lambda_i|^{2k}\,\|e_0\|^2. Equality holds when e0e_0 lies along the worst qiq_i.
    3. ∣1−ηλ∣|1 - \eta\lambda| is a convex function of λ\lambda (a V shape), so its maximum over [μ,L][\mu, L] is at an end point. This gives ρ(η)\rho(\eta).
    4. Every component goes to zero for every start exactly when ∣1−ηλi∣<1|1 - \eta\lambda_i| < 1, that is, 0<ηλi<20 < \eta\lambda_i < 2, for all ii. The strictest of these conditions is the one for λmax⁡\lambda_{\max}.
    5. For η≤1/L\eta \le 1/L, ρ=1−ημ\rho = 1 - \eta\mu, which decreases with η\eta. For η≥1/μ\eta \ge 1/\mu, ρ=ηL−1\rho = \eta L - 1, which increases. In between, ρ\rho is the larger of the decreasing 1−ημ1 - \eta\mu and the increasing ηL−1\eta L - 1. It is smallest where they are equal: 1−ημ=ηL−11 - \eta\mu = \eta L - 1 gives η=2/(μ+L)\eta = 2/(\mu + L) and ρ=(L−μ)/(L+μ)=(κ−1)/(κ+1)\rho = (L - \mu)/(L + \mu) = (\kappa - 1)/(\kappa + 1).
    6. For η=1/L\eta = 1/L: ρ=max⁡(1−μ/L, 0)=1−1/κ\rho = \max(1 - \mu/L,\ 0) = 1 - 1/\kappa. ■\blacksquare

    Iteration counts. For large κ\kappa, ln⁡κ+1κ−1≈2/κ\ln\tfrac{\kappa + 1}{\kappa - 1} \approx 2/\kappa. So the best step needs about κ2ln⁡(1/ε)\tfrac{\kappa}{2}\ln(1/\varepsilon) steps, and the step 1/L1/L about κln⁡(1/ε)\kappa\ln(1/\varepsilon). Both are O(κlog⁡(1/ε))O(\kappa\log(1/\varepsilon)).

    κ\kappa best step: ⌈ln⁡106/ln⁡κ+1κ−1⌉\lceil \ln 10^6/\ln\frac{\kappa+1}{\kappa-1} \rceil step 1/L1/L: ⌈ln⁡106/ln⁡κκ−1⌉\lceil \ln 10^6/\ln\frac{\kappa}{\kappa-1} \rceil
    10 69 132
    100 691 1,375
    1,000 6,908 13,809

    The function value converges twice as fast in the exponent: f(xk)−f⋆=12ek⊤Aek=12∑iλi(1−ηλi)2kci,02f(x_k) - f^\star = \tfrac12 e_k^\top A e_k = \tfrac12\sum_i \lambda_i(1 - \eta\lambda_i)^{2k}c_{i,0}^2, so it decays like ρ2k\rho^{2k}.

    Does the rate depend on the dimension? No. Theorem 1 uses only the two extreme eigenvalues. A quadratic with a million variables and κ=10\kappa = 10 needs the same 69 steps for a factor 10610^6 as a 2D one (each step costs more, of course).

    Beyond quadratics. For any LL-smooth, μ\mu-strongly convex ff, the step 2/(μ+L)2/(\mu + L) still gives ∥ek∥≤(κ−1κ+1)k∥e0∥\|e_k\| \le \big(\tfrac{\kappa - 1}{\kappa + 1}\big)^k\|e_0\| (Nesterov, Lectures on Convex Optimization, Thm 2.1.15; Bubeck, Thm 3.12). The quadratic shows that no fixed step does better on the whole class. Near a minimizer of a smooth ff, gradient descent behaves like gradient descent on the quadratic model with A=∇2f(x⋆)A = \nabla^2 f(x^\star). So local convergence needs η<2/λmax⁡(∇2f(x⋆))\eta < 2/\lambda_{\max}(\nabla^2 f(x^\star)).

    Quick check

    Problem P has 10610^6 variables and Hessian eigenvalues in [1,10][1, 10]. Problem Q has 2 variables and eigenvalues 11 and 100100. Both are quadratics and use their best fixed step. Which needs more steps to reduce ∥ek∥\|e_k\| by 10610^6?

    Theorem 2 (linear rate with the step 1/L1/L) #

    Let ff be LL-smooth and μ\mu-strongly convex. Gradient descent with η=1/L\eta = 1/L satisfies

    f(xk)−f⋆≤(1−μL)k(f(x0)−f⋆).f(x_k) - f^\star \le \Big(1 - \frac{\mu}{L}\Big)^k\big(f(x_0) - f^\star\big).

    Proof.

    1. The descent lemma of lesson 02 with y=x−1L∇f(x)y = x - \tfrac1L\nabla f(x) gives f(y)≤f(x)−1L∥∇f(x)∥2+L2⋅1L2∥∇f(x)∥2f(y) \le f(x) - \tfrac1L\|\nabla f(x)\|^2 + \tfrac{L}{2}\cdot\tfrac{1}{L^2}\|\nabla f(x)\|^2. So one step decreases ff by at least ∥∇f(xk)∥2/(2L)\|\nabla f(x_k)\|^2/(2L):  f(xk+1)≤f(xk)−12L∥∇f(xk)∥2\ f(x_{k+1}) \le f(x_k) - \tfrac{1}{2L}\|\nabla f(x_k)\|^2.
    2. Strong convexity implies the PL inequality (lesson 02): ∥∇f(xk)∥2≥2μ (f(xk)−f⋆)\|\nabla f(x_k)\|^2 \ge 2\mu\,(f(x_k) - f^\star).
    3. Put step 2 into step 1 and subtract f⋆f^\star: f(xk+1)−f⋆≤(1−μ/L)(f(xk)−f⋆)f(x_{k+1}) - f^\star \le (1 - \mu/L)(f(x_k) - f^\star).
    4. Apply step 3 kk times. ■\blacksquare

    Since (1−1/κ)k≤e−k/κ(1 - 1/\kappa)^k \le e^{-k/\kappa}, after k≥κln⁡((f(x0)−f⋆)/ε)k \ge \kappa\ln\big((f(x_0) - f^\star)/\varepsilon\big) steps we have f(xk)−f⋆≤εf(x_k) - f^\star \le \varepsilon. The proof uses only the descent lemma and PL. So it also holds for nonconvex functions that satisfy the PL inequality (Garrigos and Gower, Thm 3.9).

    Theorem 3 (the O(1/k)O(1/k) rate for convex functions) #

    Without strong convexity (μ=0\mu = 0) the linear rate disappears. Look at a 2D example first.

    Example. f(x)=12(x12+μx22)f(x) = \tfrac12(x_1^2 + \mu x_2^2) with a small μ>0\mu > 0, so L=1L = 1. Use η=1\eta = 1 and x0=(1,1)x_0 = (1, 1). The first coordinate is solved in one step. The second one is (1−μ)k(1 - \mu)^k. So f(xk)=μ2(1−μ)2kf(x_k) = \tfrac{\mu}{2}(1 - \mu)^{2k} for k≥1k \ge 1. As μ→0\mu \to 0 the factor 1−μ1 - \mu goes to 1: no linear rate holds for all μ\mu at once. But the gap stays small. At k=100k = 100 the worst μ\mu is about 1/2011/201, with gap 9.2×10−49.2 \times 10^{-4}. This is below the bound of the theorem below, L∥x0−x⋆∥2/(2k)=2/200=0.01L\|x_0 - x^\star\|^2/(2k) = 2/200 = 0.01. At the same time x100,2≈0.61x_{100,2} \approx 0.61: the iterate is still far from x⋆=0x^\star = 0. Without strong convexity, f(xk)f(x_k) converges like 1/k1/k, but xkx_k itself can converge very slowly.

    Theorem 3. Let ff be convex and LL-smooth with a minimizer x⋆x^\star. Gradient descent with η=1/L\eta = 1/L satisfies

    f(xk)−f⋆≤L ∥x0−x⋆∥22k.f(x_k) - f^\star \le \frac{L\,\|x_0 - x^\star\|^2}{2k}.

    Why this is true. Each step decreases ff (descent lemma). Convexity says: if f(x)f(x) is far above f⋆f^\star, then the gradient points well toward x⋆x^\star, so the step brings xx closer to x⋆x^\star. The squared distance to x⋆x^\star can only shrink a limited total amount, ∥x0−x⋆∥2\|x_0 - x^\star\|^2. So the sum of all gaps is bounded, and the last gap is at most the average.

    Proof of Theorem 3 (5 steps)

    Write x+=x−1L∇f(x)x^+ = x - \tfrac1L\nabla f(x) for one step from xx, and g=∇f(x)g = \nabla f(x).

    1. Descent lemma (step 1 of Theorem 2): f(x+)≤f(x)−12L∥g∥2f(x^+) \le f(x) - \tfrac{1}{2L}\|g\|^2.
    2. First-order condition of convexity (lesson 02), from xx toward x⋆x^\star: f⋆≥f(x)+g⊤(x⋆−x)f^\star \ge f(x) + g^\top(x^\star - x), so f(x)≤f⋆+g⊤(x−x⋆)f(x) \le f^\star + g^\top(x - x^\star).
    3. Add the two inequalities and complete the square:
    f(x+)−f⋆≤g⊤(x−x⋆)−12L∥g∥2=L2(∥x−x⋆∥2−∥x+−x⋆∥2).f(x^+) - f^\star \le g^\top(x - x^\star) - \tfrac{1}{2L}\|g\|^2 = \tfrac{L}{2}\big(\|x - x^\star\|^2 - \|x^+ - x^\star\|^2\big).

    (Expand ∥x+−x⋆∥2=∥x−x⋆∥2−2Lg⊤(x−x⋆)+1L2∥g∥2\|x^+ - x^\star\|^2 = \|x - x^\star\|^2 - \tfrac2L g^\top(x - x^\star) + \tfrac{1}{L^2}\|g\|^2 to check the equality.) 4. Apply step 3 to the steps xi→xi+1x_i \to x_{i+1} for i=0,…,k−1i = 0, \dots, k-1 and add them. The right side telescopes (each middle term appears once with ++ and once with −-):

    ∑i=1k(f(xi)−f⋆)≤L2(∥x0−x⋆∥2−∥xk−x⋆∥2)≤L2∥x0−x⋆∥2.\sum_{i=1}^{k}\big(f(x_i) - f^\star\big) \le \tfrac{L}{2}\big(\|x_0 - x^\star\|^2 - \|x_k - x^\star\|^2\big) \le \tfrac{L}{2}\|x_0 - x^\star\|^2 .
    1. By step 1, f(xi)f(x_i) never increases. So the last gap is at most the average of the kk gaps: f(xk)−f⋆≤1k∑i=1k(f(xi)−f⋆)≤L∥x0−x⋆∥22kf(x_k) - f^\star \le \tfrac1k\sum_{i=1}^k\big(f(x_i) - f^\star\big) \le \tfrac{L\|x_0 - x^\star\|^2}{2k}. ■\blacksquare

    So accuracy ε\varepsilon needs O(L∥x0−x⋆∥2/ε)O(L\|x_0 - x^\star\|^2/\varepsilon) steps. This is not the best possible. For every method that moves only along the gradients it has seen, and every k≤(n−1)/2k \le (n - 1)/2, there are LL-smooth convex functions on Rn\mathbb{R}^n with f(xk)−f⋆≥3L∥x0−x⋆∥2/(32(k+1)2)f(x_k) - f^\star \ge 3L\|x_0 - x^\star\|^2/\big(32(k + 1)^2\big) (Nesterov's lower bound; Bubeck, Thm 3.14). Accelerated methods reach this O(1/k2)O(1/k^2) rate: lesson 04.

    Line search: choosing the step along a direction #

    Fix a point xx and a descent direction dd, that is, a direction with ∇f(x)⊤d<0\nabla f(x)^\top d < 0 (for gradient descent, d=−∇f(x)d = -\nabla f(x)). Look at ff only along the ray from xx:

    φ(α)=f(x+αd).\varphi(\alpha) = f(x + \alpha d).

    Its slope is φ′(α)=∇f(x+αd)⊤d\varphi'(\alpha) = \nabla f(x + \alpha d)^\top d, and φ′(0)=∇f(x)⊤d<0\varphi'(0) = \nabla f(x)^\top d < 0.

    A line search chooses the step length α>0\alpha > 0. We use α\alpha for this step and keep η\eta for a fixed step. A good step is not too long (the value must drop enough) and not too short (the slope must have become flatter). The Armijo and Wolfe conditions make these two words precise.

    Armijo condition (sufficient decrease). With a constant 0<c1<10 < c_1 < 1:

    φ(α)≤φ(0)+c1 α φ′(0).\varphi(\alpha) \le \varphi(0) + c_1\,\alpha\,\varphi'(0).

    The right side is the tangent line at 0, with its slope made less steep by the factor c1c_1. Near α=0\alpha = 0 the curve lies below this line (because c1<1c_1 < 1). Steps that are too long go above it.

    Backtracking. Choose α0>0\alpha_0 > 0 and a shrink factor 0<τ<10 < \tau < 1 (often τ=1/2\tau = 1/2). Try α0,τα0,τ2α0,…\alpha_0, \tau\alpha_0, \tau^2\alpha_0, \dots and accept the first trial that satisfies Armijo.

    Interactive figure: loading…

    Press Next trial to run backtracking one trial at a time. The black curve is φ(α)\varphi(\alpha), the grey dashed line is the tangent at 0, and the yellow line is the Armijo line. The violet circles are the trials α0,τα0,…\alpha_0, \tau\alpha_0, \dots; the filled one is accepted. The bands below show where Armijo holds, where the curvature condition holds, and where both hold (the Wolfe set); c2c_2 is the curvature constant defined below. Try the wavy slice: the Wolfe set has several pieces. Move c1c_1 toward 0.5 and see the Armijo set shrink.

    On a quadratic first. Along d=−gd = -g with g=∇f(x)g = \nabla f(x), a quadratic gives φ(α)=f(x)−α g⊤g+α22 g⊤Ag\varphi(\alpha) = f(x) - \alpha\,g^\top g + \tfrac{\alpha^2}{2}\,g^\top A g. Armijo asks −α g⊤g+α22g⊤Ag≤−c1α g⊤g-\alpha\,g^\top g + \tfrac{\alpha^2}{2}g^\top A g \le -c_1\alpha\,g^\top g. Divide by α>0\alpha > 0: it holds exactly when

    α≤2(1−c1) g⊤gg⊤Ag=2(1−c1) α⋆,\alpha \le 2(1 - c_1)\,\frac{g^\top g}{g^\top A g} = 2(1 - c_1)\,\alpha^\star ,

    where α⋆=g⊤g/g⊤Ag\alpha^\star = g^\top g/g^\top A g is the exact line search step (the minimizer of φ\varphi). Since g⊤Ag≤L g⊤gg^\top A g \le L\,g^\top g, every α≤2(1−c1)/L\alpha \le 2(1 - c_1)/L passes.

    Theorem 4 (backtracking stops, with a step that is not too short) #

    Let ff be LL-smooth, d=−∇f(x)≠0d = -\nabla f(x) \ne 0, α0>0\alpha_0 > 0, τ∈(0,1)\tau \in (0, 1) and c1∈(0,1)c_1 \in (0, 1). Backtracking stops after finitely many trials, and the accepted step satisfies

    α≥min⁡(α0, 2τ(1−c1)/L).\alpha \ge \min\big(\alpha_0,\ 2\tau(1 - c_1)/L\big).

    Proof.

    1. Descent lemma with y=x−α∇f(x)y = x - \alpha\nabla f(x): f(x−α∇f)≤f(x)−α(1−Lα/2) ∥∇f∥2f(x - \alpha\nabla f) \le f(x) - \alpha(1 - L\alpha/2)\,\|\nabla f\|^2.
    2. Armijo asks f(x−α∇f)≤f(x)−c1α∥∇f∥2f(x - \alpha\nabla f) \le f(x) - c_1\alpha\|\nabla f\|^2. By step 1 this holds when 1−Lα/2≥c11 - L\alpha/2 \ge c_1, that is, for every α≤2(1−c1)/L\alpha \le 2(1 - c_1)/L.
    3. The trials α0τj\alpha_0\tau^j go to 0. So after finitely many trials one is below 2(1−c1)/L2(1 - c_1)/L, and the search stops there or earlier.
    4. If the accepted α\alpha is not α0\alpha_0, the trial before it, α/τ\alpha/\tau, failed. By step 2 it was larger than 2(1−c1)/L2(1 - c_1)/L. So α>2τ(1−c1)/L\alpha > 2\tau(1 - c_1)/L. Either way, α≥min⁡(α0, 2τ(1−c1)/L)\alpha \ge \min(\alpha_0,\ 2\tau(1 - c_1)/L). ■\blacksquare

    Consequence. Each accepted step decreases ff by at least c1αmin⁡∥∇f∥2c_1\alpha_{\min}\|\nabla f\|^2, with αmin⁡=min⁡(α0,2τ(1−c1)/L)\alpha_{\min} = \min(\alpha_0, 2\tau(1 - c_1)/L), and we never needed to know LL. With PL this gives the factor 1−2μc1αmin⁡1 - 2\mu c_1\alpha_{\min} per step, a linear rate like Theorem 2. Where ff is flatter, the search accepts longer steps.

    The Wolfe conditions #

    Armijo alone accepts tiny steps: every small enough α\alpha passes. The curvature condition rules them out. With a second constant c2c_2:

    • weak Wolfe curvature condition: φ′(α)≥c2 φ′(0)\varphi'(\alpha) \ge c_2\,\varphi'(0). The slope has risen from φ′(0)<0\varphi'(0) < 0 to at least c2φ′(0)c_2\varphi'(0), so the step went far enough to flatten the descent.
    • strong Wolfe curvature condition: ∣φ′(α)∣≤c2 ∣φ′(0)∣|\varphi'(\alpha)| \le c_2\,|\varphi'(0)|. Also, the slope may not be large and positive: the step may not overshoot far onto the other side of the valley.

    The (weak or strong) Wolfe conditions are Armijo plus one of these, with 0<c1<c2<10 < c_1 < c_2 < 1. The order c1<c2c_1 < c_2 guarantees that such steps exist when ff is smooth and bounded below along the ray (Nocedal and Wright, Lemma 3.1). Usual values (Nocedal and Wright, §3.1): c1=10−4c_1 = 10^{-4}; c2=0.9c_2 = 0.9 for Newton and quasi-Newton methods, c2=0.1c_2 = 0.1 for nonlinear conjugate gradient. scipy.optimize.line_search and PyTorch's LBFGS(line_search_fn="strong_wolfe") use c1=10−4c_1 = 10^{-4} and c2=0.9c_2 = 0.9.

    Quick check

    A line search accepts the step α=10−9\alpha = 10^{-9} on a problem where α≈0.1\alpha \approx 0.1 would be good. Which condition would have rejected this step?

    Theorem 5 (the curvature condition gives y⊤s>0y^\top s > 0) #

    Let dkd_k be a descent direction at xkx_k and xk+1=xk+αkdkx_{k+1} = x_k + \alpha_k d_k with αk>0\alpha_k > 0 satisfying the weak curvature condition with c2<1c_2 < 1. Then sk=xk+1−xks_k = x_{k+1} - x_k and yk=∇f(xk+1)−∇f(xk)y_k = \nabla f(x_{k+1}) - \nabla f(x_k) satisfy yk⊤sk>0y_k^\top s_k > 0.

    Proof.

    1. sk=αkdks_k = \alpha_k d_k, so yk⊤sk=αk(∇f(xk+1)⊤dk−∇f(xk)⊤dk)y_k^\top s_k = \alpha_k\big(\nabla f(x_{k+1})^\top d_k - \nabla f(x_k)^\top d_k\big).
    2. The curvature condition says ∇f(xk+1)⊤dk≥c2 ∇f(xk)⊤dk\nabla f(x_{k+1})^\top d_k \ge c_2\,\nabla f(x_k)^\top d_k.
    3. So yk⊤sk≥αk(c2−1) ∇f(xk)⊤dk>0y_k^\top s_k \ge \alpha_k(c_2 - 1)\,\nabla f(x_k)^\top d_k > 0, because c2−1<0c_2 - 1 < 0 and ∇f(xk)⊤dk<0\nabla f(x_k)^\top d_k < 0. ■\blacksquare

    Why quasi-Newton methods need it. BFGS (lesson 10) builds a matrix Bk+1≈∇2fB_{k+1} \approx \nabla^2 f that satisfies the secant equation Bk+1sk=ykB_{k+1}s_k = y_k. If Bk+1B_{k+1} is positive definite, then sk⊤yk=sk⊤Bk+1sk>0s_k^\top y_k = s_k^\top B_{k+1}s_k > 0. So positive curvature along the step is necessary, and the BFGS update keeps its matrix positive definite exactly when y⊤s>0y^\top s > 0. Then the next direction −Bk+1−1∇f-B_{k+1}^{-1}\nabla f is a descent direction. For strictly convex ff, y⊤s>0y^\top s > 0 holds for every step. For nonconvex ff, Armijo alone does not guarantee it; the curvature condition does.

    Fixed step against backtracking on Rosenbrock #

    The Rosenbrock function f(x,y)=(1−x)2+100(y−x2)2f(x, y) = (1 - x)^2 + 100(y - x^2)^2 has its minimizer at (1,1)(1, 1), at the end of a long, curved, narrow valley. At the minimizer the Hessian eigenvalues are about 1001.6 and 0.399 (κ≈2508\kappa \approx 2508). So a fixed step must be below 2/1001.6≈0.00199682/1001.6 \approx 0.0019968 to converge to (1,1)(1, 1).

    Interactive figure: loading…

    Compare the fixed step (blue) with Armijo backtracking (violet, dashed), both started at (−1.2,1)(-1.2, 1). Try the three presets for η\eta. With η=0.0021\eta = 0.0021, just above 2/λmax⁡2/\lambda_{\max} at the minimizer, the fixed step never settles: it stays near the minimizer and bounces across the valley. Look at the long violet jump: with α0=1\alpha_0 = 1, backtracking sometimes accepts a long step across the bend of the valley, because it lowers ff enough. Then switch α0\alpha_0 to "2 × last step" and compare the number of function evaluations.

    From (−1.2,1)(-1.2, 1), counting steps until f(xk)≤10−10f(x_k) \le 10^{-10} (checked in the notebook):

    Method Steps Function evaluations
    fixed η=0.001\eta = 0.001 26,593 (none needed)
    fixed η=0.0019\eta = 0.0019 13,966 (none needed)
    fixed η=0.0021\eta = 0.0021 does not converge
    backtracking, α0=1\alpha_0 = 1, τ=0.5\tau = 0.5, c1=10−4c_1 = 10^{-4} 10,616 105,522
    backtracking, α0=2×\alpha_0 = 2 \times last step 11,966 23,940

    Backtracking found a step close to the best fixed step without knowing LL: most accepted steps are 2−9≈0.001952^{-9} \approx 0.00195. But it does not remove the ill-conditioning. It still needs about ten thousand steps, because the problem has κ≈2508\kappa \approx 2508. Starting each search from the last step (warm start) cuts the cost from about 10 to about 2 function evaluations per step.

    Answers to section 1. (1) About 350. Here κ=50\kappa = 50, the best factor is 49/51≈0.96149/51 \approx 0.961, and ln⁡(106)/ln⁡(51/49)≈345.3\ln(10^6)/\ln(51/49) \approx 345.3, so 346 steps. The step 1/L1/L needs 684 by the same formula. (2) It fails. With η=2.1/L\eta = 2.1/L the factor on x2x_2 is ∣1−2.1∣=1.1|1 - 2.1| = 1.1, so that error grows like 1.1k1.1^k. There is a hard wall at 2/L2/L, not a gradual slowdown.

    4. Worked example #

    f(x)=12x⊤Axf(x) = \tfrac12 x^\top A x with A=(5335)A = \begin{pmatrix} 5 & 3 \\ 3 & 5 \end{pmatrix}, so x⋆=0x^\star = 0 and f⋆=0f^\star = 0. The eigenvalues are μ=2\mu = 2 with q1=(1,−1)/2q_1 = (1, -1)/\sqrt2 and L=8L = 8 with q2=(1,1)/2q_2 = (1, 1)/\sqrt2. So κ=4\kappa = 4.

    (a) Three step sizes. Steps to shrink ∥ek∥\|e_k\| by 10610^6: ⌈ln⁡(106)/ln⁡(1/ρ)⌉\lceil\ln(10^6)/\ln(1/\rho)\rceil.

    Step η\eta factor on q1q_1: ∣1−2η∣\lvert 1 - 2\eta\rvert factor on q2q_2: ∣1−8η∣\lvert 1 - 8\eta\rvert ρ\rho steps
    1/L=0.1251/L = 0.125 0.75 0 0.75 ⌈48.02⌉=49\lceil 48.02\rceil = 49
    2/(μ+L)=0.22/(\mu + L) = 0.2 0.6 0.6 0.6=(κ−1)/(κ+1)0.6 = (\kappa - 1)/(\kappa + 1) ⌈27.05⌉=28\lceil 27.05\rceil = 28
    0.26>2/L=0.250.26 > 2/L = 0.25 0.48 1.08 1.08 diverges

    (b) Iterates with η=0.2\eta = 0.2 from x0=(1,0)x_0 = (1, 0). ∇f(x0)=Ax0=(5,3)\nabla f(x_0) = Ax_0 = (5, 3), so x1=(1,0)−0.2 (5,3)=(0,−0.6)x_1 = (1, 0) - 0.2\,(5, 3) = (0, -0.6). Then ∇f(x1)=(−1.8,−3)\nabla f(x_1) = (-1.8, -3) and x2=(0,−0.6)−0.2 (−1.8,−3)=(0.36,0)x_2 = (0, -0.6) - 0.2\,(-1.8, -3) = (0.36, 0). In the same way x3=(0,−0.216)x_3 = (0, -0.216). Why so regular? Since x0=(q1+q2)/2x_0 = (q_1 + q_2)/\sqrt2, we get xk=0.6k(q1+(−1)kq2)/2x_k = 0.6^k\big(q_1 + (-1)^k q_2\big)/\sqrt2: the norm shrinks by exactly 0.6 per step, and the q2q_2 component flips sign at every step.

    (c) Theorem 2 with η=1/L\eta = 1/L. f(x0)=12⋅5=2.5f(x_0) = \tfrac12 \cdot 5 = 2.5. After one step only the q1q_1 component is left, and f(xk)=0.5⋅0.5625kf(x_k) = 0.5 \cdot 0.5625^k for k≥1k \ge 1: 0.281, 0.158, 0.089, … The bound 2.5⋅0.75k2.5 \cdot 0.75^k gives 1.875, 1.406, 1.055, … It holds, but it is loose: on a quadratic the gap decays like ρ2=0.5625\rho^2 = 0.5625 per step, while the general bound has 1−μ/L=0.751 - \mu/L = 0.75.

    (d) Backtracking from x0=(1,0)x_0 = (1, 0) with α0=1\alpha_0 = 1, τ=0.5\tau = 0.5, c1=10−4c_1 = 10^{-4}. Here g=(5,3)g = (5, 3), g⊤g=34g^\top g = 34 and g⊤Ag=260g^\top A g = 260. So φ(α)=2.5−34α+130α2\varphi(\alpha) = 2.5 - 34\alpha + 130\alpha^2, and the Armijo line is 2.5−10−4⋅34 α=2.5−0.0034 α2.5 - 10^{-4}\cdot 34\,\alpha = 2.5 - 0.0034\,\alpha.

    α\alpha φ(α)\varphi(\alpha) Armijo line accepted? φ′(α)=−34+260α\varphi'(\alpha) = -34 + 260\alpha
    1 98.5 2.4966 no 226
    0.5 18 2.4983 no 96
    0.25 2.125 2.49915 yes (first pass) 31
    0.125 0.28125 2.49958 (would pass too) −1.5

    Backtracking accepts α=0.25=2/L\alpha = 0.25 = 2/L. This is allowed: Armijo holds for every α≤2(1−c1)α⋆≈0.2615\alpha \le 2(1 - c_1)\alpha^\star \approx 0.2615, where α⋆=34/260≈0.1308\alpha^\star = 34/260 \approx 0.1308 is the exact step. Theorem 4 guarantees only α≥min⁡(1, 2⋅0.5⋅0.9999/8)≈0.125\alpha \ge \min(1,\ 2 \cdot 0.5 \cdot 0.9999/8) \approx 0.125. One step of length 2/L2/L is fine; the limit 2/L2/L is about a fixed step repeated forever.

    (e) Wolfe at α=0.25\alpha = 0.25 with c2=0.9c_2 = 0.9 and φ′(0)=−34\varphi'(0) = -34. Weak: 31≥0.9⋅(−34)=−30.631 \ge 0.9\cdot(-34) = -30.6 holds. Strong: ∣31∣≤0.9⋅34=30.6|31| \le 0.9 \cdot 34 = 30.6 fails, just barely: the step overshoots the minimum of φ\varphi onto a steep upward slope. At α=0.125\alpha = 0.125, ∣−1.5∣≤30.6|-1.5| \le 30.6, so strong Wolfe holds there. scipy.optimize.line_search (strong Wolfe) returns α=0.1308=α⋆\alpha = 0.1308 = \alpha^\star here.

    (f) The curvature pair of the step 0.25. s=x1−x0=−0.25 (5,3)=(−1.25,−0.75)s = x_1 - x_0 = -0.25\,(5, 3) = (-1.25, -0.75), y=As=(−8.5,−7.5)y = As = (-8.5, -7.5), and y⊤s=10.625+5.625=16.25>0y^\top s = 10.625 + 5.625 = 16.25 > 0. On a strictly convex quadratic, y⊤s=s⊤As>0y^\top s = s^\top A s > 0 for every step. The curvature condition matters for nonconvex ff.

    Quick check

    In (d), you change only α0\alpha_0 from 1 to 0.3. Which step does backtracking accept now?

    5. In code #

    Closed forms and SciPy check the worked example. The notebook has these cells and the exercises.

    import numpy as np
    from scipy.optimize import line_search
    
    A = np.array([[5.0, 3.0], [3.0, 5.0]])
    mu, L = np.linalg.eigvalsh(A)                          # 2.0 8.0
    for eta in (1 / L, 2 / (mu + L), 0.26):
        T = np.eye(2) - eta * A                            # e_{k+1} = T e_k
        rho = max(abs(np.linalg.eigvals(T)))               # spectral radius of T
        k = int(np.ceil(np.log(1e6) / np.log(1 / rho))) if rho < 1 else None
        print(eta, round(rho, 4), k)                       # 0.125 0.75 49 | 0.2 0.6 28 | 0.26 1.08 None
    
    x0 = np.array([1.0, 0.0])
    T = np.eye(2) - 0.2 * A
    print([np.linalg.matrix_power(T, k) @ x0 for k in (1, 2, 3)])   # (0, -0.6), (0.36, 0), (0, -0.216)
    
    f = lambda x: 0.5 * x @ A @ x
    grad = lambda x: A @ x
    g = grad(x0)
    phi = lambda a: f(x0 - a * g)                          # f along d = -g
    dphi = lambda a: -grad(x0 - a * g) @ g                 # its slope
    for a in (1, 0.5, 0.25, 0.125):                        # the backtracking table
        print(a, phi(a), phi(a) <= f(x0) - 1e-4 * a * (g @ g), dphi(a))
    # 1 98.5 False 226 | 0.5 18.0 False 96 | 0.25 2.125 True 31 | 0.125 0.28125 True -1.5
    alpha = line_search(f, grad, x0, -g, c1=1e-4, c2=0.9)[0]
    print(alpha, g @ g / (g @ A @ g))                      # 0.13077 0.13077: the exact step
    

    The O(1/k)O(1/k) example of section 3, from the closed form:

    import numpy as np
    
    k = 100                                        # f = (x1^2 + mu x2^2)/2, L = 1, step 1, x0 = (1, 1)
    mus = np.logspace(-6, 0, 200_001)
    gap = 0.5 * mus * (1 - mus) ** (2 * k)         # f(x_k) - f*, closed form
    i = gap.argmax()
    print(mus[i], gap[i], 2 / (2 * k))             # 0.004975 (about 1/201)  0.000917  0.01 (bound)
    print((1 - mus[i]) ** k)                       # 0.607: x_k is still far from x* = 0
    

    6. Where it shows up #

    • Learning rates in deep learning. η<2/λmax⁡\eta < 2/\lambda_{\max} is why a learning rate that is too large makes the loss explode within a few steps. In full-batch training of neural networks, the largest Hessian eigenvalue (the sharpness) rises until it hovers near 2/η2/\eta: the edge of stability (Cohen et al. 2021; lesson 11).
    • Preconditioning beats tuning. Making κ\kappa ten times smaller saves about a factor 10 in steps, however well the step is tuned. This is the reason for feature scaling (lesson 02), Adam (lesson 06) and matrix preconditioners (lesson 12).
    • Full-batch problems in science. With exact gradients (inverse problems, PDE-constrained fits, the L-BFGS phase after Adam in physics-informed neural networks), quasi-Newton methods with a Wolfe line search are the default: scipy.optimize.minimize(method="L-BFGS-B") or torch.optim.LBFGS(line_search_fn="strong_wolfe"). There is no learning rate to tune. For a discretized 1D Laplacian on NN grid points, κ\kappa grows like N2N^2, so plain gradient descent needs O(N2)O(N^2) steps.
    • Why not in stochastic deep learning? Armijo compares function values. With minibatch noise these values are noisy, and each trial costs a forward pass. Stochastic line searches exist for models that interpolate the data (Vaswani et al., NeurIPS 2019), but learning-rate schedules are the standard.

    7. Common mistakes #

    • "1/L1/L is the best step." It maximizes the guaranteed decrease of the descent lemma. On quadratics 2/(μ+L)2/(\mu + L) is better, and every η<2/L\eta < 2/L converges.
    • Mixing the two rates. On a quadratic, ∥xk−x⋆∥\|x_k - x^\star\| decays like ρk\rho^k and f(xk)−f⋆f(x_k) - f^\star like ρ2k\rho^{2k}. And ρ=(κ−1)/(κ+1)≈1−2/κ\rho = (\kappa - 1)/(\kappa + 1) \approx 1 - 2/\kappa means about κ2ln⁡(1/ε)\tfrac{\kappa}{2}\ln(1/\varepsilon) steps, not ln⁡(1/ε)\ln(1/\varepsilon).
    • Reading the O(1/k)O(1/k) bound as convergence of xkx_k. It bounds f(xk)−f⋆f(x_k) - f^\star only. The iterate can still be far from x⋆x^\star.
    • Choosing the step from the flat direction. η=1/μ\eta = 1/\mu solves the flat direction and blows up the steep one. The steep direction sets the limit.
    • A large c1c_1. It rejects good steps; use c1=10−4c_1 = 10^{-4}. Newton-type methods also need c1<1/2c_1 < 1/2, so that the full step α=1\alpha = 1 is accepted near the minimizer.
    • Weak Wolfe for nonlinear conjugate gradient. It can accept an overshooting step (the step α=0.25\alpha = 0.25 above). The convergence theory of nonlinear CG (Fletcher–Reeves) needs strong Wolfe with c2<1/2c_2 < 1/2. For BFGS weak Wolfe is enough, but most libraries use strong Wolfe.
    • Armijo alone for BFGS on a nonconvex ff. Then y⊤s≤0y^\top s \le 0 can happen, and the update loses positive definiteness.
    • Floating point near the minimum. When c1α∥∇f∥2c_1\alpha\|\nabla f\|^2 is below the rounding error of ff (about 10−16∣f∣10^{-16}|f|), Armijo cannot see the decrease, and the search stalls.

    8. Check yourself #

    1. A quadratic has Hessian eigenvalues 0.5, 2 and 10. Give the stability limit, the best fixed step and its factor, the factor of the step 1/L1/L, and the steps to reduce ∥ek∥\|e_k\| by 10610^6 with each.
      AnswerStability: η<2/10=0.2\eta < 2/10 = 0.2. Best step: 2/10.5≈0.1902/10.5 \approx 0.190, ρ=19/21≈0.905\rho = 19/21 \approx 0.905, ⌈138.04⌉=139\lceil 138.04\rceil = 139 steps. Step 1/L=0.11/L = 0.1: ρ=1−0.5/10=0.95\rho = 1 - 0.5/10 = 0.95, ⌈269.3⌉=270\lceil 269.3\rceil = 270 steps. The middle eigenvalue 2 does not matter.
    2. In the proof of Theorem 3, where is convexity used, and where is the monotone decrease of f(xi)f(x_i) used?
      AnswerConvexity in step 2, f(x)≤f⋆+∇f(x)⊤(x−x⋆)f(x) \le f^\star + \nabla f(x)^\top(x - x^\star). It turns the gap into a difference of squared distances, which telescopes. The monotone decrease in step 5, to bound the last gap by the average of all gaps.
    3. ff is convex and LL-smooth with L=4L = 4 and ∥x0−x⋆∥=5\|x_0 - x^\star\| = 5. How many steps with η=1/L\eta = 1/L guarantee f(xk)−f⋆≤10−3f(x_k) - f^\star \le 10^{-3}?
      AnswerL∥x0−x⋆∥2/(2k)≤10−3L\|x_0 - x^\star\|^2/(2k) \le 10^{-3} gives k≥4⋅25/(2⋅10−3)=50,000k \ge 4 \cdot 25/(2 \cdot 10^{-3}) = 50{,}000 steps.
    4. For L=8L = 8, α0=1\alpha_0 = 1, τ=0.5\tau = 0.5, c1=10−4c_1 = 10^{-4}: which step does backtracking guarantee along −∇f-\nabla f? Can it accept a step larger than 2/L2/L?
      Answerα≥min⁡(1, 2⋅0.5⋅0.9999/8)≈0.125\alpha \ge \min(1,\ 2 \cdot 0.5 \cdot 0.9999/8) \approx 0.125. Yes: on a quadratic Armijo accepts every α≤2(1−c1) g⊤g/g⊤Ag\alpha \le 2(1 - c_1)\,g^\top g/g^\top A g. This is larger than 2/L2/L when gg lies mostly in flat directions. The limit 2/L2/L is about a fixed step repeated forever, not about one step.
    5. Why does BFGS need y⊤s>0y^\top s > 0, and which line-search condition gives it?
      AnswerThe secant equation Bs=yBs = y with B≻0B \succ 0 forces s⊤y=s⊤Bs>0s^\top y = s^\top B s > 0, and the BFGS update keeps BB positive definite exactly when y⊤s>0y^\top s > 0. The (weak or strong) Wolfe curvature condition gives y⊤s≥α(c2−1)∇f(x)⊤d>0y^\top s \ge \alpha(c_2 - 1)\nabla f(x)^\top d > 0.
    Recall cardsAnswer in your head first, then reveal. Add the cards to your review deck to see them again just before you would forget.
    1. Convergence factor of gradient descent with step η\eta on a quadratic with eigenvalues in [μ,L][\mu, L]?

    2. For which fixed steps does gradient descent converge on a quadratic, from every start?

    3. Best fixed step on a quadratic, and its factor?

    4. About how many gradient descent steps does κ=100\kappa = 100 need for a factor 10610^6, with the best step?

    5. Rate of gradient descent with step 1/L1/L on an LL-smooth, μ\mu-strongly convex ff?

    6. Rate of gradient descent with step 1/L1/L on an LL-smooth convex ff?

    7. State the Armijo condition.

    8. State the weak and the strong Wolfe curvature conditions.

    9. Usual line-search constants for quasi-Newton methods?

    10. Why do quasi-Newton methods need the curvature condition?

    Open the review →

    9. Interview angle #

    • "Which learning rate makes gradient descent diverge on a quadratic?" — η>2/λmax⁡\eta > 2/\lambda_{\max}. At exactly 2/λmax⁡2/\lambda_{\max} the steepest component bounces forever without shrinking.
    • "What is the convergence rate of gradient descent?" — Convex and LL-smooth: O(1/k)O(1/k) in ff. Strongly convex: linear, (1−μ/L)k(1 - \mu/L)^k, so O(κlog⁡(1/ε))O(\kappa\log(1/\varepsilon)) steps. Best fixed step on a quadratic: 2/(μ+L)2/(\mu + L), factor (κ−1)/(κ+1)(\kappa - 1)/(\kappa + 1).
    • "κ=104\kappa = 10^4: how many steps for six digits?" — About κ2ln⁡106≈69,000\tfrac{\kappa}{2}\ln 10^6 \approx 69{,}000 with the best step, and κln⁡106≈138,000\kappa\ln 10^6 \approx 138{,}000 with 1/L1/L.
    • "What are the Wolfe conditions, and why does L-BFGS need them?" — Sufficient decrease plus curvature. The curvature condition gives y⊤s>0y^\top s > 0, which keeps the BFGS matrix positive definite.
    • "Why don't we use line searches to train neural networks?" — Minibatch losses are noisy and each trial costs a forward pass; schedules are cheaper and work well.

    10. Practice #

    The notebook for this lesson runs in Colab. It has four exercises, each with a check cell and a folded solution:

    1. Run gradient descent on quadratics with κ=4,10,50\kappa = 4, 10, 50 and compare the measured factor per step with (κ−1)/(κ+1)(\kappa - 1)/(\kappa + 1).
    2. Check the O(1/k)O(1/k) bound on a convex least-squares problem that is not strongly convex (a rank-deficient design matrix).
    3. Implement Armijo backtracking, reproduce the table of the worked example, and run it on Rosenbrock.
    4. Write a Wolfe check (weak and strong) and test the step that scipy.optimize.line_search returns.

    11. Watch and read #

    Strang runs gradient descent with exact line search on f=12(x2+by2)f = \tfrac12(x^2 + by^2) and finds the factor (1−b)/(1+b)(1 - b)/(1 + b) per step, the same factor as the best fixed step of Theorem 1.
    Open on YouTube · the player loads from youtube-nocookie.com when you press play
    Watch for backtracking line search and the convergence proofs for convex and strongly convex functions.
    Open on YouTube · the player loads from youtube-nocookie.com when you press play
    The two conditions explained on the 1D function φ(α)\varphi(\alpha), as in the Armijo figure above.
    Open on YouTube · the player loads from youtube-nocookie.com when you press play