Module contents
Lesson 8 of 27Core 110 min

Convergence analysis of first-order methods

Prove the classical gradient-descent rates: O(1/k) for L-smooth convex functions, linear for strongly convex functions, and O(1/k) for squared gradient norm in nonconvex functions. Introduce the Polyak-Łojasiewicz condition, giving linear convergence without convexity and helping explain training of overparameterized models.

After this lesson you can

  • Distinguish sublinear, linear, superlinear and quadratic rates and translate them into iterations for precision ε.
  • Prove the descent lemma and use it to bound decrease per iteration.
  • Prove the GD rate f(x_k) − f* ≤ L‖x₀ − x*‖²/(2k) for L-smooth convex functions.
  • Prove linear convergence with factor (1 − μ/L) under strong convexity or the PL condition.
  • Prove that for nonconvex L-smooth functions min‖∇f(xᵢ)‖² decreases as O(1/k) and explain what reaching a stationary point means.

Before you start

Motivation: a loss curve is a falsifiable prediction

You launch training and loss decreases. The useful question is not “does it decrease?” but “how fast, and how much remains?” A convergence theorem answers with explicit assumptions: “if ff is LL-smooth and convex, then f(xk)−f⋆≤L∥x0−x⋆∥2/(2k)f(\vb{x}_k) - f^\star \le L\norm{\vb{x}_0 - \vb{x}^\star}^2/(2k)”. It is a prediction you can falsify by plotting: if actual loss exceeds the bound, your code has an error or an assumption fails.

Three situations where this interpretation saves hours:

  • Budget. If the curve is a straight line on a semilog scale with slope log⁡ρ\log\rho, you know iterations remaining to accuracy ε\varepsilon without running them: k≈ln⁡(1/ε)/ln⁡(1/ρ)k \approx \ln(1/\varepsilon)/\ln(1/\rho). If instead it is a log-log line of slope −1-1, each extra decimal digit costs ten times the previous iterations.
  • Diagnosis. Logistic regression with ℓ2\ell_2 regularization converges linearly; without it, on separable data, only as 1/k1/k. Poorly conditioned ridge converges linearly but with ρ\rho near 1. Curve shape reveals which assumption fails or which constant dominates.
  • Design. Step η\eta, choosing GD or an accelerated method, and the value of a preconditioner follow from constants LL, μ\mu and κ\kappa in the rates. In overparameterized networks where nothing is convex, training curves still fall as straight semilog lines: this lesson’s Polyak-Łojasiewicz condition explains why.

This lesson proves four basic gradient-descent rates with step η=1/L\eta = 1/L and compares them with reality in each figure. The map:

Assumption on ffGD guarantee with η=1/L\eta = 1/LIterations for accuracy ε\varepsilon
convex and LL-smoothf(xk)−f⋆≤L∥x0−x⋆∥22kf(\vb{x}_k) - f^\star \le \dfrac{L\norm{\vb{x}_0 - \vb{x}^\star}^2}{2k}O(1/ε)\bigO(1/\varepsilon)
μ\mu-strongly convex and LL-smoothf(xk)−f⋆≤(1−μL)k (f(x0)−f⋆)f(\vb{x}_k) - f^\star \le \big(1 - \tfrac{\mu}{L}\big)^k\,\big(f(\vb{x}_0) - f^\star\big)O(κlog⁡(1/ε))\bigO\big(\kappa\log(1/\varepsilon)\big)
only LL-smooth and bounded belowmin⁡i<k∥∇f(xi)∥2≤2L (f(x0)−f⋆)k\min_{i<k}\norm{\grad f(\vb{x}_i)}^2 \le \dfrac{2L\,(f(\vb{x}_0) - f^\star)}{k}O(1/ε2)\bigO(1/\varepsilon^2) for ∥∇f∥≤ε\norm{\grad f} \le \varepsilon
LL-smooth and μ\mu-PL (without convexity)same linear rate as row 2O(κlog⁡(1/ε))\bigO\big(\kappa\log(1/\varepsilon)\big)

Convergence orders: what “fast” means

Comparing algorithms needs vocabulary. Let ek>0e_k > 0 measure error at iteration kk, e.g. f(xk)−f⋆f(\vb{x}_k) - f^\star or ∥xk−x⋆∥\norm{\vb{x}_k - \vb{x}^\star}, with ek→0e_k \to 0.

The names come from graphs. If ek+1=ρ eke_{k+1} = \rho\,e_k, then log⁡ek=log⁡e0+klog⁡ρ\log e_k = \log e_0 + k\log\rho is a straight line in kk (semilog scale): “linear”. Slope reveals constant ρ\rho: each iteration gains −log⁡10ρ-\log_{10}\rho decimal digits. But the same sequence is far from a line on log-log. Conversely, if ek=C k−pe_k = C\,k^{-p}, then log⁡ek=log⁡C−plog⁡k\log e_k = \log C - p\log k is a straight line in log⁡k\log k (log-log) of slope −p-p, and a flattening curve on semilog.

What about higher orders? If ek+1=C ek qe_{k+1} = C\,e_k^{\,q}, taking logarithms gives log⁡ek+1=qlog⁡ek+log⁡C\log e_{k+1} = q\log e_k + \log C: plotting log⁡ek+1\log e_{k+1} against log⁡ek\log e_k gives a line of slope qq. This measures order without knowing the method. For quadratic convergence, log⁡ek≈−c 2k\log e_k \approx -c\,2^k: correct digits double each step, and on semilog the curve plunges ever faster.

In iterations to reach accuracy ε\varepsilon (with e0≈1e_0 \approx 1):

TypeModelIterations for ε\varepsilonWith ε=10−6\varepsilon = 10^{-6}
sublinear, p=1/2p = 1/2ek≈k−1/2e_k \approx k^{-1/2}ε−2\varepsilon^{-2}101210^{12}
sublinear, p=1p = 1ek≈k−1e_k \approx k^{-1}ε−1\varepsilon^{-1}10610^{6}
sublinear, p=2p = 2ek≈k−2e_k \approx k^{-2}ε−1/2\varepsilon^{-1/2}10310^{3}
linear, ρ=0.9\rho = 0.9ek≈0.9ke_k \approx 0.9^kln⁡(1/ε)/ln⁡(1/ρ)\ln(1/\varepsilon)/\ln(1/\rho)132132
linear, ρ=0.99\rho = 0.99ek≈0.99ke_k \approx 0.99^ksame13751375
linear, ρ=0.999\rho = 0.999ek≈0.999ke_k \approx 0.999^ksame1380913809
quadratic, e0=1/2e_0 = 1/2ek+1=ek2e_{k+1} = e_k^2log⁡2log⁡1/2ε\log_2\log_{1/2}\varepsilon55

Two things stand out. First, a linear rate with ρ\rho very near 1 can be practically worse than a sublinear one with large pp: 0.999k0.999^k needs 13809 steps for six digits, versus only a thousand for k−2k^{-2}. Second, for ρ\rho near 1, ln⁡(1/ρ)≈1−ρ\ln(1/\rho) \approx 1 - \rho, and linear cost is ≈ln⁡(1/ε)/(1−ρ)\approx \ln(1/\varepsilon)/(1 - \rho). With ρ=1−1/κ\rho = 1 - 1/\kappa this becomes κln⁡(1/ε)\kappa\ln(1/\varepsilon): the preceding lesson’s condition number.

The first interactive is a detective game. Seven actual error sequences (gradient descent on different problems, bisection, Newton, secant) are unlabeled: decide their type from the curve alone.

InteractiveRate detective
  • error sequence
Scale
40 %
My diagnosis
R2R^2 on semilog1.0000
R2R^2 on log-log0.9862
ρ^\hat\rho (semilog slope)0.9344
p^\hat p (log-log slope)9.00
q^\hat q (order)1.00
Correct0 of 0
On a linear scale most curves look alike: they fall quickly and then hug the axis, making their rates hard to distinguish.
Choose a case and explore four scales. In “Linear” nearly all curves look alike: they decrease and hug the axis. In “Semilog” a line reveals linear rate; in “Log-log”, sublinear; in “Order”, plot log⁡ek+1\log e_{k+1} against log⁡ek\log e_k and the slope is order qq (the dotted diagonal is q=1q = 1). Readings calculate three least-squares fits over the window chosen with “Fit from”: compare both R2R^2 values and decide. Then press “Check”. Move the window in case 1 to separate transient from asymptotic rate, and inspect case 7 on log-log: does it look sublinear? Is it?

What you should have seen:

  • Linear scale distinguishes nothing. Often used for loss curves, it is least informative: every converging sequence resembles a flattening exponential.
  • Each type has its scale. Linear sequences (cases 1, 5 and 7) are semilog lines, with ρ^\hat\rho equal to the theoretical constant. Sublinear ones (2 and 4) are log-log lines with p^≈1\hat p \approx 1 and p^≈2\hat p \approx 2. Newton and secant plunge on semilog, with q^≈2\hat q \approx 2 and q^≈1.6\hat q \approx 1.6.
  • Order separates sublinear and linear from superlinear. In the (log⁡ek,log⁡ek+1)(\log e_k, \log e_{k+1}) plane, linear and sublinear sequences parallel the diagonal (q=1q = 1); only superlinear ones separate. Secant order q^≈1.6\hat q \approx 1.6 is the golden ratio (1+5)/2(1 + \sqrt5)/2.
  • A line in one window is not proof. In case 7 (ρ=0.996\rho = 0.996 per step), the log-log curve looks “almost straight”: a short window of a slow exponential resembles a power. Case 1’s transient shows the reverse: before the slowest mode dominates, apparent slope exceeds the asymptotic slope. A rate is asymptotic behavior, read at the curve’s end.

The descent lemma: what one step guarantees

All rates in this lesson follow from a one-line inequality. Recall the smoothness assumption: ∇f\grad f is LL-Lipschitz, ∥∇f(x)−∇f(y)∥≤L∥x−y∥\norm{\grad f(\vb{x}) - \grad f(\vb{y})} \le L\norm{\vb{x} - \vb{y}}.

The descent lemma does not require convexity. Part (a) is the quadratic upper bound of lesson 3, reconstructed step by step in the first exercise. Part (b) is a substitution.

Proof

Apply (a) with y=x+=x−η∇f(x)\vb{y} = \vb{x}^+ = \vb{x} - \eta\grad f(\vb{x}), so y−x=−η∇f(x)\vb{y} - \vb{x} = -\eta\grad f(\vb{x}):

f(x+)≤f(x)−η∥∇f(x)∥2+L2η2∥∇f(x)∥2=f(x)−η(1−Lη2)∥∇f(x)∥2.f(\vb{x}^+) \le f(\vb{x}) - \eta\norm{\grad f(\vb{x})}^2 + \frac{L}{2}\eta^2\norm{\grad f(\vb{x})}^2 = f(\vb{x}) - \eta\Big(1 - \frac{L\eta}{2}\Big)\norm{\grad f(\vb{x})}^2.

Function η↦η(1−Lη/2)\eta \mapsto \eta(1 - L\eta/2) is a parabola maximized at η=1/L\eta = 1/L, where it equals 1/(2L)1/(2L). ■\blacksquare

∎

Two everyday observations. First, descent is guaranteed iff η<2/L\eta < 2/L, because factor 1−Lη/21 - L\eta/2 is positive exactly in that range, with maximum guarantee at η=1/L\eta = 1/L. Bound 2/L2/L is tight: for f(x)=L2x2f(x) = \frac{L}{2}x^2 with η=2/L\eta = 2/L, each step is x+=−xx^+ = -x and value does not decrease. Second, inequality (b) concerns the next iterate, not the minimum: it holds anywhere, including far from a minimum and in nonconvex regions.

InteractiveThe descent lemma, step by step
xₖx⁺
k = 0
  • ff
  • parabola QkQ_k with curvature LL
  • tangent at xkx_k
Function value by iteration and cumulative bound f(x0)−∑i<kη(1−Lη/2)f′(xi)2f(x_0) - \sum_{i<k}\eta(1 - L\eta/2)f'(x_i)^2
  • actual f(xk)f(x_k)
  • cumulative bound
  • min⁡f\min f
1.00
1.00
3.9
f(xk)f(x_k)16.629
f′(xk)2f'(x_k)^2116.546
Guaranteed decrease7.2841
Actual decrease9.1923
actual / guaranteed1.26
Bound at x+x^+holds
η=1/L\eta = 1/L: the next iterate is exactly the minimum of the parabola. This step maximizes the guaranteed decrease, ∥∇f∥2/(2L)\norm{\nabla f}^2/(2L).
Each iteration draws the red curvature-LL parabola tangent to ff at xkx_k. The next iterate x+x^+ lies on the parabola axis and the red bar measures its guaranteed decrease, η(1−Lη/2)f′(xk)2\eta(1 - L\eta/2)f'(x_k)^2; blue measures actual decrease of ff (at least as much while LL is true). With η=1/L\eta = 1/L, x+x^+ minimizes the parabola. Raise ηL\eta L toward 2 and see the guarantee vanish; pass 2 and GD may increase. Lower “Assumed L” below 1: the parabola crosses ff and stops bounding it. Choose nonconvex functions: the lemma still holds each step. Below, the sum of guaranteed decreases is always bounded by f(x0)−min⁡ff(x_0) - \min f.

The figure’s lower graph anticipates the next argument. Sum inequality (b) over iterations and the left side telescopes: f(xk)≤f(x0)−∑i<kη(1−Lη/2)∥∇f(xi)∥2f(\vb{x}_k) \le f(\vb{x}_0) - \sum_{i<k}\eta(1 - L\eta/2)\norm{\grad f(\vb{x}_i)}^2. Since f≥f⋆f \ge f^\star, total guaranteed decreases cannot exceed f(x0)−f⋆f(\vb{x}_0) - f^\star. That observation alone, without convexity, proves the nonconvex result. Convexity and a little more algebra yield rate 1/k1/k.

Convex and LL-smooth functions: rate O(1/k)\bigO(1/k)

Add convexity. Now error f(x)−f⋆f(\vb{x}) - f^\star relates to the gradient via the first-order condition f(x⋆)≥f(x)+∇f(x)⊤(x⋆−x)f(\vb{x}^\star) \ge f(\vb{x}) + \grad f(\vb{x})\T(\vb{x}^\star - \vb{x}), i.e.

f(x)−f⋆≤∇f(x)⊤(x−x⋆).f(\vb{x}) - f^\star \le \grad f(\vb{x})\T(\vb{x} - \vb{x}^\star).

The O(1/k)\bigO(1/k) rate of GD on convex functions requires knowing LL but neither μ\mu nor dimension: it is independent of nn.

Proof

Write gi=∇f(xi)\vb{g}_i = \grad f(\vb{x}_i), so xi+1=xi−gi/L\vb{x}_{i+1} = \vb{x}_i - \vb{g}_i/L. There are four steps.

1. Combine descent and convexity. The descent lemma gives f(xi+1)≤f(xi)−12L∥gi∥2f(\vb{x}_{i+1}) \le f(\vb{x}_i) - \frac{1}{2L}\norm{\vb{g}_i}^2, and convexity gives f(xi)−f⋆≤gi⊤(xi−x⋆)f(\vb{x}_i) - f^\star \le \vb{g}_i\T(\vb{x}_i - \vb{x}^\star). Subtract f⋆f^\star from the first and substitute the second:

f(xi+1)−f⋆≤gi⊤(xi−x⋆)−12L∥gi∥2.f(\vb{x}_{i+1}) - f^\star \le \vb{g}_i\T(\vb{x}_i - \vb{x}^\star) - \frac{1}{2L}\norm{\vb{g}_i}^2.

2. Complete the square. With a=xi−x⋆\vb{a} = \vb{x}_i - \vb{x}^\star, ∥a−gi/L∥2=∥a∥2−2Lgi⊤a+1L2∥gi∥2\norm{\vb{a} - \vb{g}_i/L}^2 = \norm{\vb{a}}^2 - \frac{2}{L}\vb{g}_i\T\vb{a} + \frac{1}{L^2}\norm{\vb{g}_i}^2, so

gi⊤a−12L∥gi∥2=L2(∥a∥2−∥a−gi/L∥2)=L2(∥xi−x⋆∥2−∥xi+1−x⋆∥2).\vb{g}_i\T\vb{a} - \frac{1}{2L}\norm{\vb{g}_i}^2 = \frac{L}{2}\Big(\norm{\vb{a}}^2 - \norm{\vb{a} - \vb{g}_i/L}^2\Big) = \frac{L}{2}\Big(\norm{\vb{x}_i - \vb{x}^\star}^2 - \norm{\vb{x}_{i+1} - \vb{x}^\star}^2\Big).

Thus 0≤f(xi+1)−f⋆≤L2(∥xi−x⋆∥2−∥xi+1−x⋆∥2)0 \le f(\vb{x}_{i+1}) - f^\star \le \frac{L}{2}\big(\norm{\vb{x}_i - \vb{x}^\star}^2 - \norm{\vb{x}_{i+1} - \vb{x}^\star}^2\big). The first inequality gives the theorem’s last claim: distance to x⋆\vb{x}^\star does not increase.

3. Telescope. Sum over i=0,…,k−1i = 0, \dots, k - 1:

∑i=0k−1(f(xi+1)−f⋆)≤L2(∥x0−x⋆∥2−∥xk−x⋆∥2)≤L2∥x0−x⋆∥2.\sum_{i=0}^{k-1}\big(f(\vb{x}_{i+1}) - f^\star\big) \le \frac{L}{2}\Big(\norm{\vb{x}_0 - \vb{x}^\star}^2 - \norm{\vb{x}_k - \vb{x}^\star}^2\Big) \le \frac{L}{2}\norm{\vb{x}_0 - \vb{x}^\star}^2.

4. Monotonicity. The descent lemma guarantees f(xi)f(\vb{x}_i) does not increase, so f(xk)≤f(xi+1)f(\vb{x}_k) \le f(\vb{x}_{i+1}) for every i≤k−1i \le k - 1; the step-3 sum has kk terms, each ≥f(xk)−f⋆\ge f(\vb{x}_k) - f^\star. Thus k (f(xk)−f⋆)≤L2∥x0−x⋆∥2k\,(f(\vb{x}_k) - f^\star) \le \frac{L}{2}\norm{\vb{x}_0 - \vb{x}^\star}^2. ■\blacksquare

∎

Four comments on what has and has not been proved.

  • Iterates remain in a ball. Monotonicity of ∥xk−x⋆∥\norm{\vb{x}_k - \vb{x}^\star} (step 2) avoids assuming bounded sublevel sets: the proof itself keeps iterates within B‾(x⋆,∥x0−x⋆∥)\overline{B}(\vb{x}^\star, \norm{\vb{x}_0 - \vb{x}^\star}).
  • Shorter steps. With η≤1/L\eta \le 1/L the same argument gives f(xk)−f⋆≤∥x0−x⋆∥2/(2ηk)f(\vb{x}_k) - f^\star \le \norm{\vb{x}_0 - \vb{x}^\star}^2/(2\eta k). Reducing the step worsens the constant proportionally.
  • No minimizer. If ff does not attain its infimum (e.g. logistic regression with separable data and no ℓ2\ell_2), the argument holds with any comparison point z\vb{z} instead of x⋆\vb{x}^\star: f(xk)≤f(z)+L∥x0−z∥2/(2k)f(\vb{x}_k) \le f(\vb{z}) + L\norm{\vb{x}_0 - \vb{z}}^2/(2k). Check this in the lab.
  • This is GD’s limit. Worst-case analysis (Drori and Teboulle, 2014; Taylor, Hendrickx and Glineur, 2017) shows that with η=1/L\eta = 1/L the exact constant is L∥x0−x⋆∥2/(4k+2)L\norm{\vb{x}_0 - \vb{x}^\star}^2/(4k + 2), slightly less than half the proved bound, but the exponent of kk does not improve. Exceeding 1/k1/k requires another method: Nesterov accelerated gradient reaches O(1/k2)\bigO(1/k^2), and lower bounds show that is optimal for first-order methods.

How closely does the bound match reality? We need a family of problems with tiny but known μ>0\mu > 0. A quadratic with eigenvalues λi=(i/n)q\lambda_i = (i/n)^q works: a spectrum with many nearly zero eigenvalues, so f(xk)−f⋆=12∑iλix0,i2(1−ηλi)2kf(\vb{x}_k) - f^\star = \frac12\sum_i\lambda_i x_{0,i}^2(1 - \eta\lambda_i)^{2k} can be evaluated in closed form.

InteractiveThe 1/k1/k bound versus reality
k ≈ 1/(ημ)
  • actual f(xk)−f⋆f(x_k) - f^\star
  • proven bound
1.00
2.00
k axis
μ=λmin⁡\mu = \lambda_{\min} (tiny)2.8e−4
kk with f−f⋆≤10−4f - f^\star \le 10^{-4}, real85
kk guaranteed by the bound5000
bound / actual58.8×
The bound R2/(2ηk)R^2/(2\eta k) is a line with slope −1-1 on a log-log plot and the actual curve lies below it. While k≪1/(ημ)k \ll 1/(\eta\mu), GD does not yet detect μ>0\mu > 0; later the curve bends downward (linear convergence).
A convex quadratic with L=1L = 1 and spectrum λi=(i/n)q\lambda_i = (i/n)^q with n=60n = 60: blue is exact f(xk)−f⋆f(x_k) - f^\star and dashed red is theorem bound R2/(2ηk)R^2/(2\eta k) (log-log line of slope −1-1). Raise “Spectrum” to accumulate tiny eigenvalues: the actual curve stays closer to the bound longer. The vertical line marks k≈1/(ημ)k \approx 1/(\eta\mu), when GD “discovers” μ>0\mu > 0 and the curve breaks downward linearly. For steps above 1/L1/L the bound is no longer proved.

Strongly convex functions: linear convergence

If ff is also μ\mu-strongly convex, error does more than decrease: it is multiplied by a constant below 1 each step. The key inequality from lesson 3 is f(x)−f⋆≤∥∇f(x)∥2/(2μ)f(\vb{x}) - f^\star \le \norm{\grad f(\vb{x})}^2/(2\mu): a large gradient certifies a large error, so the lemma’s guaranteed decrease is proportional to error.

The linear GD rate on strongly convex functions depends only on κ\kappa: the condition number fixes the contraction factor.

Proof

By the descent lemma with η=1/L\eta = 1/L, f(xk+1)−f⋆≤f(xk)−f⋆−12L∥∇f(xk)∥2f(\vb{x}_{k+1}) - f^\star \le f(\vb{x}_k) - f^\star - \frac{1}{2L}\norm{\grad f(\vb{x}_k)}^2. From lesson 3, ∥∇f(xk)∥2≥2μ (f(xk)−f⋆)\norm{\grad f(\vb{x}_k)}^2 \ge 2\mu\,(f(\vb{x}_k) - f^\star). Substitution gives

f(xk+1)−f⋆≤(1−μL)(f(xk)−f⋆),f(\vb{x}_{k+1}) - f^\star \le \Big(1 - \frac{\mu}{L}\Big)\big(f(\vb{x}_k) - f^\star\big),

and induction gives the first bound. For the second, μ2∥xk−x⋆∥2≤f(xk)−f⋆\frac{\mu}{2}\norm{\vb{x}_k - \vb{x}^\star}^2 \le f(\vb{x}_k) - f^\star. Finally (1−1/κ)k≤e−k/κ(1 - 1/\kappa)^k \le e^{-k/\kappa}, which is ≤ε/(f(x0)−f⋆)\le \varepsilon/(f(\vb{x}_0) - f^\star) when k≥κln⁡((f(x0)−f⋆)/ε)k \ge \kappa\ln\big((f(\vb{x}_0) - f^\star)/\varepsilon\big). ■\blacksquare

∎

Notice how little was needed: strong convexity enters only through ∥∇f∥2≥2μ (f−f⋆)\norm{\grad f}^2 \ge 2\mu\,(f - f^\star). This observation becomes the PL condition’s definition and lets us remove convexity below.

The step need not be 1/L1/L. With any η∈(0,2/L)\eta \in (0, 2/L) the same calculation gives factor

1−ημ (2−Lη),1 - \eta\mu\,(2 - L\eta),

equal to 1−μ/L1 - \mu/L at η=1/L\eta = 1/L (its minimum, the best guarantee) and tending to 11 as η→0\eta \to 0 and η→2/L\eta \to 2/L. With η=2/(L+μ)\eta = 2/(L + \mu) on quadratics, distance contracts as (κ−1κ+1)k\big(\frac{\kappa - 1}{\kappa + 1}\big)^k, seen last lesson.

The proved bound is not exactly reality. On a quadratic, error in ff is multiplied each step by at most max⁡i(1−ηλi)2\max_i(1 - \eta\lambda_i)^2 (and asymptotically exactly that factor), the square of distance contraction. With η=1/L\eta = 1/L this is (1−μ/L)2(1 - \mu/L)^2, while the theorem bound is only 1−μ/L1 - \mu/L: conservative by factor 2 in the exponent. The figure lets you measure the difference and see what happens as η\eta approaches 2/L2/L.

InteractiveThe linear bound versus reality
  • actual f(xk)−f⋆f(x_k) - f^\star
  • proven bound
1.00
100
k axis
κ=L/μ\kappa = L/\mu100
proven per-step factor 1−ημ(2−Lη)1 - \eta\mu(2 - L\eta)0.99000
actual per-step factor (quadratic)0.98010
kk for f−f⋆≤10−6f(x0)f - f^\star \le 10^{-6}f(x_0), real371
kk guaranteed by the bound1375
With κ=100\kappa = 100 and η=1/L\eta = 1/L the bound requires on the order of κln⁡(106)≈1382\kappa\ln(10^6) \approx 1382 steps; actual GD arrives earlier because only part of the spectrum is close to μ\mu. For quadratics the actual contraction is the square of the proven factor, because the theorem bounds ff using the PL inequality and the quadratic contracts distance by 1−ημ1 - \eta\mu.
The quadratic spectrum is logarithmically spaced between μ=1/κ\mu = 1/\kappa and L=1L = 1. Blue is exact f(xk)−f⋆f(x_k) - f^\star and dashed red is bound (1−ημ(2−Lη))k(f(x0)−f⋆)(1 - \eta\mu(2 - L\eta))^k(f(x_0) - f^\star). Move κ\kappa: both semilog slopes change like log⁡(1−1/κ)\log(1 - 1/\kappa), and readings give actual and guaranteed steps for six digits. With η=1/L\eta = 1/L and κ=1000\kappa = 1000 the bound requires 1380913809 steps and GD reaches it in about 27002700: the bound covers worst case, and this spectrum is not it. Move ηL\eta L near 2: the guarantee vanishes. Change the kk axis to logarithmic and the bound's line curves: linear convergence is not a line on log-log.

Nonconvex functions: stationary points

Without convexity there is no minimizer to approach nor f(x)−f⋆≤∇f⊤(x−x⋆)f(\vb{x}) - f^\star \le \grad f\T(\vb{x} - \vb{x}^\star). Even so, the descent lemma and telescoping yield a real, more modest guarantee: the gradient becomes small.

Proof

The descent lemma with η=1/L\eta = 1/L gives for each ii, 12L∥∇f(xi)∥2≤f(xi)−f(xi+1)\frac{1}{2L}\norm{\grad f(\vb{x}_i)}^2 \le f(\vb{x}_i) - f(\vb{x}_{i+1}). Sum for i=0,…,k−1i = 0, \dots, k - 1: the right side telescopes and

12L∑i=0k−1∥∇f(xi)∥2≤f(x0)−f(xk)≤f(x0)−f⋆.\frac{1}{2L}\sum_{i=0}^{k-1}\norm{\grad f(\vb{x}_i)}^2 \le f(\vb{x}_0) - f(\vb{x}_k) \le f(\vb{x}_0) - f^\star.

The minimum of kk terms cannot exceed their mean: min⁡i<k∥∇f(xi)∥2≤1k∑i<k∥∇f(xi)∥2≤2L(f(x0)−f⋆)/k\min_{i<k}\norm{\grad f(\vb{x}_i)}^2 \le \frac{1}{k}\sum_{i<k}\norm{\grad f(\vb{x}_i)}^2 \le 2L(f(\vb{x}_0) - f^\star)/k. For the second claim require the bound ≤ε2\le \varepsilon^2. ■\blacksquare

∎

This is GD’s nonconvex stationarity result: an ε\varepsilon-stationary point (∥∇f∥≤ε\norm{\grad f} \le \varepsilon) in O(1/ε2)\bigO(1/\varepsilon^2) iterations. Compare the convex case, where f−f⋆≤εf - f^\star \le \varepsilon cost O(1/ε)\bigO(1/\varepsilon): here the gradient is measured, and ∥∇f∥\norm{\grad f} is the square root of what decreases as 1/k1/k, so norm decreases as 1/k1/\sqrt{k}. Dependence ε−2\varepsilon^{-2} cannot be improved for GD in this class (Cartis, Gould and Toint, 2010).

What the theorem does not say matters as much as what it does:

  • It concerns the best iterate, not the last. Without convexity, ∥∇f(xk)∥\norm{\grad f(\vb{x}_k)} may rise and fall. In practice this does not matter: stopping as soon as ∥∇f∥≤ε\norm{\grad f} \le \varepsilon finds the first satisfying iterate.
  • Stationary is not minimum. A point with ∇f=0\grad f = \vb{0} can be a local minimum, maximum or saddle. The theorem does not distinguish them, and f(xk)f(\vb{x}_k) can be far from f⋆f^\star.
  • Nor does it say where you go. A small ∇f\grad f need not put xk\vb{x}_k near anything in particular.

These are more than theoretical cautions: consider f(x,y)=sin⁡x sin⁡yf(x, y) = \sin x\,\sin y, which is 11-smooth, bounded (f⋆=−1f^\star = -1), has global minima at (±π2,∓π2)(\pm\frac{\pi}{2}, \mp\frac{\pi}{2}) and saddles at multiples of π\pi. Along diagonal x=yx = y it equals sin⁡2x\sin^2 x and GD, which by symmetry stays there, falls exactly onto saddle (0,0)(0, 0) with ∇f→0\grad f \to \vb{0} and f−f⋆→1f - f^\star \to 1.

InteractiveStationary is not minimum
  • ∥∇f(xk)∥2\|\nabla f(x_k)\|^2
  • minimum through kk
  • proven bound
1.00
k axis
f(xk)−f⋆f(x_k) - f^\star at the end1.000
∥∇f(xk)∥2\|\nabla f(x_k)\|^2 at the end0.0e0
min⁡i<k∥∇f(xi)∥2\min_{i<k}\|\nabla f(x_i)\|^20.0e0
bound at kk8.1e−3
the final iterate issaddle
The gradient is almost zero, but the function remains far from its minimum (f−f⋆≈1f - f^\star \approx 1): GD stopped at a saddle. Without convexity, ∥∇f∥→0\norm{\nabla f} \to 0 means only a stationary point, not a minimum.
Level curves of sin⁡x sin⁡y\sin x\,\sin y (blue: negative values; orange: positive). Filled circles are minima and hollow circles saddles. Drag x0x_0. Below are ∥∇f(xk)∥2\norm{\nabla f(x_k)}^2 (pale blue), its minimum through kk (green), and proved bound 2L(f(x0)−f⋆)/(k ηL(2−ηL))2L(f(x_0) - f^\star)/(k\,\eta L(2 - \eta L)) (dashed red); green always stays below. Start on the diagonal: the gradient nearly vanishes but f−f⋆≈1f - f^\star \approx 1 and the reading says “saddle”. Press “Diagonal + 0.001”: the small deviation grows as (1+η)k(1 + \eta)^k along the unstable direction and, with η=1/L\eta = 1/L, GD leaves the saddle for a minimum in about ten steps. Shorter steps take longer.

There is good news outside the theorem. Initial points falling exactly on a saddle’s stable manifold form a measure-zero set: with random initialization and η<1/L\eta < 1/L, GD almost surely does not converge to a “strict” saddle, one with a negative Hessian eigenvalue. If all saddles are strict and GD converges, it converges to a local minimum (Lee, Simchowitz, Jordan and Recht, 2016). This returns with the strict saddle property and escaping saddles.

The Polyak-Łojasiewicz condition: linear without convexity

The linear proof used one property: ∥∇f(x)∥2≥2μ (f(x)−f⋆)\norm{\grad f(\vb{x})}^2 \ge 2\mu\,(f(\vb{x}) - f^\star). Keep only that.

Read it as a ratio: 12∥∇f(x)∥2f(x)−f⋆≥μ\frac{\frac12\norm{\grad f(\vb{x})}^2}{f(\vb{x}) - f^\star} \ge \mu everywhere. The gradient never dies while error remains: there can be no plateaus or stationary points outside the minimizer set. An immediate consequence: every stationary point is a global minimum (if ∇f(x)=0\grad f(\vb{x}) = \vb{0}, then 0≥μ (f(x)−f⋆)0 \ge \mu\,(f(\vb{x}) - f^\star), so f(x)=f⋆f(\vb{x}) = f^\star).

Proof

This is literally the strongly convex proof. The descent lemma gives f(xk+1)−f⋆≤f(xk)−f⋆−12L∥∇f(xk)∥2f(\vb{x}_{k+1}) - f^\star \le f(\vb{x}_k) - f^\star - \frac{1}{2L}\norm{\grad f(\vb{x}_k)}^2 and PL gives ∥∇f(xk)∥2≥2μ (f(xk)−f⋆)\norm{\grad f(\vb{x}_k)}^2 \ge 2\mu\,(f(\vb{x}_k) - f^\star). Thus f(xk+1)−f⋆≤(1−μ/L) (f(xk)−f⋆)f(\vb{x}_{k+1}) - f^\star \le (1 - \mu/L)\,(f(\vb{x}_k) - f^\star). ■\blacksquare

∎

The relationship to the preceding result is a strict implication. Every μ\mu-strongly convex function is μ\mu-PL (inequality f−f⋆≤∥∇f∥2/(2μ)f - f^\star \le \norm{\grad f}^2/(2\mu) from lesson 3, reconstructed in exercise 3), but PL does not require convexity, a unique minimizer, or even a convex minimizer set. It does not need LL-smoothness to exist, only for the theorem to apply. It does imply (without proof here) quadratic growth relative to minimizer set X⋆X^\star, f(x)−f⋆≥μ2dist⁡(x,X⋆)2f(\vb{x}) - f^\star \ge \frac{\mu}{2}\operatorname{dist}(\vb{x}, X^\star)^2 (Karimi, Nutini and Schmidt, 2016, who also place PL in the hierarchy of “error bound” conditions).

Three families of examples show the condition is not arbitrary.

Two instructive counterexamples. f(x)=x4f(x) = x^4 is convex with a unique minimizer but not PL: 12f′(x)2/f(x)=8x2→0\frac12 f'(x)^2/f(x) = 8x^2 \to 0 near the minimum, so GD converges as 1/k21/k^2, not linearly (detective case 4). And the ring 14(x2+y2−1)2\frac14(x^2 + y^2 - 1)^2 has the unit circle as its minimizer set, but at the origin its gradient vanishes with f=14f = \frac14: the PL ratio is 00.

The figure brings together three landscapes. Click to launch GD from several points and observe in the center panel the PL ratio along each trajectory, always above μ\mu; below, the straight semilog line.

InteractiveNonconvex PL functions
x* = 0
PL ratio 12∥∇f(xk)∥2/(f(xk)−f⋆)\tfrac12\|\nabla f(x_k)\|^2 / (f(x_k) - f^\star) per iteration
μ
Error f(xk)−f⋆f(x_k) - f^\star (log scale) and bound (1−ημ(2−Lη))kf(x0)(1 - \eta\mu(2 - L\eta))^k f(x_0) of the last trajectory
  • GD trajectories (in start order)
  • PL bound
Landscape
0.60
μ\mu (min. of 12∥∇f∥2/(f−f⋆)\tfrac12\|\nabla f\|^2/(f - f^\star))0.1755
LL (sup. de ∥∇2f∥\|\nabla^2 f\|)8.00
proven per-step factor0.9816
observed per-step factor0.1603
minimum observed PL ratio0.1756
f(x)=x2+3sin⁡2xf(x) = x^2 + 3\sin^2 x is not convex (f′′=2+6cos⁡2xf'' = 2 + 6\cos 2x reaches −4-4) but satisfies 12f′(x)2≥μf(x)\tfrac12 f'(x)^2 \ge \mu f(x) con μ≈0.1755\mu \approx 0.1755 (minimum ratio on a grid, at x≈±2.20x \approx \pm 2.20). All trajectories, from any start, decrease linearly to the unique minimum.
Three landscapes: x2+3sin⁡2xx^2 + 3\sin^2 x; a curved valley 12(y−asin⁡x)2\frac12(y - a\sin x)^2 whose minimizer set is the green curve (with a>0a > 0 it is nonconvex and each start ends at a different point on it, but PL ratio is always 1+a2cos⁡2x≥11 + a^2\cos^2 x \ge 1); and the ring, which is not PL. Click the landscape to launch GD (up to five trajectories). The middle panel plots 12∥∇f(xk)∥2/(f(xk)−f⋆)\frac12\norm{\nabla f(x_k)}^2/(f(x_k) - f^\star) per iteration against μ\mu (numerically calculated), and the bottom panel plots semilog error against bound (1−ημ(2−Lη))k(1 - \eta\mu(2 - L\eta))^k. On the ring start GD near the origin: the ratio falls to zero, the trajectory takes time to escape and there is no linear bound.

Implementation from scratch: a rates lab

Build the full toolkit: GD, three problems, rate fitting and comparison with bounds. The problems are a quadratic with κ=100\kappa = 100, ℓ2\ell_2-regularized logistic regression (strongly convex), and unregularized logistic regression on separable data (convex, no minimizer). For regularized logistic use lesson 3’s constants, L=λ+∥X∥22/(4n)L = \lambda + \norm{\mat{X}}_2^2/(4n) and μ=λ\mu = \lambda, and calculate w⋆\vb{w}^\star with a few Newton steps solely for exact error measurement.

[ ]GD and three problemsBrowser
import numpy as np

def gd(grad, x0, eta, n):
    """n + 1 iterados de x <- x - eta * grad(x)."""
    xs = [np.array(x0, dtype=float)]
    for _ in range(n):
        xs.append(xs[-1] - eta * grad(xs[-1]))
    return np.array(xs)

rng = np.random.default_rng(0)

# 1) cuadrática con kappa = 100: f(x) = ½ xᵀAx, minimizador x* = 0
d = 20
lam = np.logspace(0, 2, d)
Q, _ = np.linalg.qr(rng.standard_normal((d, d)))
A = Q @ np.diag(lam) @ Q.T
quad = dict(f=lambda x: 0.5 * x @ A @ x, grad=lambda x: A @ x, L=lam.max(), mu=lam.min(),
            xstar=np.zeros(d), fstar=0.0, x0=rng.standard_normal(d))

# 2) regresión logística con etiquetas ruidosas (no separables) y regularización ℓ2
n, p = 200, 5
X = rng.standard_normal((n, p))
w_true = rng.standard_normal(p)
y = np.where(X @ w_true + 0.8 * rng.standard_normal(n) > 0, 1.0, -1.0)

def logistic(X, y, l2):
    n = len(y)
    f = lambda w: np.mean(np.logaddexp(0.0, -y * (X @ w))) + 0.5 * l2 * w @ w
    grad = lambda w: -(X.T @ (y / (1.0 + np.exp(y * (X @ w))))) / n + l2 * w
    L = l2 + np.linalg.norm(X, 2) ** 2 / (4 * n)          # constante de la lección 3
    return f, grad, L

l2 = 0.005
f_r, g_r, L_r = logistic(X, y, l2)
def hess_r(w):
    s = 1.0 / (1.0 + np.exp(-y * (X @ w)))
    return (X.T * (s * (1 - s))) @ X / n + l2 * np.eye(p)
w = np.zeros(p)
for _ in range(30):                                       # Newton: solo para obtener w* a precisión de máquina
    w = w - np.linalg.solve(hess_r(w), g_r(w))
logreg = dict(f=f_r, grad=g_r, L=L_r, mu=l2, xstar=w, fstar=f_r(w), x0=np.zeros(p))

# 3) datos separables con margen, sin ℓ2: no hay minimizador, inf f = 0
Xs = rng.standard_normal((800, p))
Xs = Xs[np.abs(Xs @ w_true) > 0.18 * np.linalg.norm(w_true)][:200]
ys = np.sign(Xs @ w_true)
f_s, g_s, L_s = logistic(Xs, ys, 0.0)
sep = dict(f=f_s, grad=g_s, L=L_s, x0=np.zeros(p), fstar=0.0)

print(f"cuadrática: L = {quad['L']:.0f}, mu = {quad['mu']:.0f}, kappa = {quad['L'] / quad['mu']:.0f}")
print(f"logística con l2: L = {L_r:.4f}, mu = {l2}, kappa = {L_r / l2:.1f}, f* = {logreg['fstar']:.6f}")
print(f"logística separable: L = {L_s:.4f}, mu = 0")

def errores(prob, n_iter):
    xs = gd(prob["grad"], prob["x0"], 1.0 / prob["L"], n_iter)      # paso eta = 1/L
    return np.array([prob["f"](x) - prob["fstar"] for x in xs]), xs

e_quad, xs_quad = errores(quad, 1500)
e_log, xs_log = errores(logreg, 3000)
e_sep, xs_sep = errores(sep, 8000)
print("error final:", f"{e_quad[-1]:.1e}", f"{e_log[-1]:.1e}", f"{e_sep[-1]:.1e}")

The three errors end very differently: the quadratic and regularized logistic reach machine precision (logistic error stays at rounding noise, so may be zero or negative), while separable remains at 6⋅10−46\cdot 10^{-4}. Now the detective in code. Fit the interactive’s two lines over the second half of each curve (past the transient), keeping the part where error remains above rounding noise:

[ ]Fitting rates: semilog versus log-logBrowser
def r2(y, yhat):
    return 1 - np.sum((y - yhat) ** 2) / np.sum((y - np.mean(y)) ** 2)

def tramo(e, piso=1e-12):
    """Longitud del prefijo en que el error está por encima del ruido de redondeo."""
    return np.flatnonzero(e > piso)[-1] + 1

def ajuste_semilog(e):
    """e_k ≈ C rho^k sobre la segunda mitad: devuelve (rho, R²)."""
    n = tramo(e); k = np.arange(n); a = n // 2
    s, b = np.polyfit(k[a:], np.log(e[a:n]), 1)
    return np.exp(s), r2(np.log(e[a:n]), s * k[a:] + b)

def ajuste_loglog(e):
    """e_k ≈ C k^(-p) sobre la segunda mitad: devuelve (p, R²)."""
    n = tramo(e); k = np.arange(n); a = n // 2
    s, b = np.polyfit(np.log(k[a:]), np.log(e[a:n]), 1)
    return -s, r2(np.log(e[a:n]), s * np.log(k[a:]) + b)

for nombre, e in [("cuadrática kappa=100", e_quad), ("logística con l2", e_log), ("logística separable", e_sep)]:
    rho, rs = ajuste_semilog(e)
    pp, rl = ajuste_loglog(e)
    print(f"{nombre:22s} semilog: rho = {rho:.5f}, R2 = {rs:.5f}   |   log-log: p = {pp:.3f}, R2 = {rl:.5f}")

print("(1 - mu/L)^2 en la cuadrática:", (1 - quad["mu"] / quad["L"]) ** 2)

Quadratic and regularized logistic are straight lines in semilog (R2≈1R^2 \approx 1), while separable is a line in log-log, with slope p^≈0.9\hat p \approx 0.9: it converges like 1/k1/k. For the quadratic, observed factor 0.97990.9799 matches theory’s value for ff, (1−μ/L)2=0.9801(1 - \mu/L)^2 = 0.9801, not the theorem’s guaranteed 1−μ/L=0.991 - \mu/L = 0.99. Most surprising is regularized logistic: proved bound is 1−μ/L=0.9841 - \mu/L = 0.984 and observed factor 0.790.79. The next cell compares bounds to data, checking with actual numbers that theorems are never violated:

[ ]Bounds versus realityBrowser
for nombre, prob, e, xs in [("cuadrática kappa=100", quad, e_quad, xs_quad), ("logística con l2", logreg, e_log, xs_log)]:
    R2 = np.sum((xs[0] - prob["xstar"]) ** 2)                 # ‖x₀ − x*‖²
    ks = np.arange(1, len(e))
    cota_conv = prob["L"] * R2 / (2 * ks)                     # teorema convexo
    cota_lin = (1 - prob["mu"] / prob["L"]) ** ks * e[0]      # teorema fuertemente convexo
    vivos = e[1:] > 1e-12                                     # por debajo, f − f* es ruido
    print(f"{nombre}: ¿e_k <= L R²/(2k) siempre? {np.all(e[1:] <= cota_conv)}   ¿e_k <= (1-mu/L)^k f0? {np.all(e[1:][vivos] <= cota_lin[vivos])}")
    for k in (10, 100, 1000):
        print(f"   k = {k:4d}   real {e[k]:9.2e}   L R²/(2k) {prob['L'] * R2 / (2 * k):9.2e}   (1-mu/L)^k f0 {(1 - prob['mu'] / prob['L']) ** k * e[0]:9.2e}")

# datos separables: no hay x*, pero la cota vale con cualquier comparador z = s·u (x₀ = 0)
u = w_true / np.linalg.norm(w_true)
ss = np.linspace(0, 60, 601)
f_z = np.array([f_s(s * u) for s in ss])
for k in (100, 1000, 5000):
    cota = np.min(f_z + L_s * ss ** 2 / (2 * k))              # min_z [ f(z) + L‖x₀ − z‖²/(2k) ]
    print(f"separable k = {k:5d}   real {e_sep[k]:.2e}   cota con comparador libre {cota:.2e}   k·real = {k * e_sep[k]:.2f}")

Both bounds always hold; neither approaches reality when the problem is easy. The last line shows sublinear rate is order 1/k1/k up to slow factors: product k⋅ekk\cdot e_k only increases from 2.62.6 to 4.94.9 when kk is multiplied by 5050 (hence p^≈0.92\hat p \approx 0.92, not exactly 1), and the much more pessimistic free-comparator bound still holds. Now turn to PL: nonconvex x2+3sin⁡2xx^2 + 3\sin^2 x and least squares with more unknowns than equations.

[ ]PL without convexityBrowser
g = lambda x: x ** 2 + 3 * np.sin(x) ** 2                  # g'' = 2 + 6 cos 2x llega a −4: no convexa
dg = lambda x: 2 * x + 3 * np.sin(2 * x)
xs_ = np.linspace(-20, 20, 400001)
xs_ = xs_[np.abs(xs_) > 1e-6]
mu_g = np.min(0.5 * dg(xs_) ** 2 / g(xs_))                 # constante PL en esa rejilla
L_g = 8.0
print(f"g: mu_PL = {mu_g:.4f}, L = {L_g}, kappa_PL = {L_g / mu_g:.1f}")
for c in (1.0, 0.5):
    eta = c / L_g
    xs = gd(dg, 3.9, eta, 400)
    eg = g(xs)
    factor = 1 - eta * mu_g * (2 - L_g * eta)
    k = np.arange(1, len(eg))
    vivos = eg[1:] > 1e-250
    print(f"eta = {c}/L: ¿g(x_k) <= factor^k g(x_0)? {np.all(eg[1:][vivos] <= factor ** k[vivos] * eg[0])}   (factor {factor:.4f})   g(x_400) = {eg[-1]:.1e}")

# mínimos cuadrados sobreparametrizados: 30 ecuaciones, 100 incógnitas
rng = np.random.default_rng(1)
m, dd = 30, 100
Xw = rng.standard_normal((m, dd))
yw = Xw @ rng.standard_normal(dd)
sv = np.linalg.svd(Xw, compute_uv=False)
mu_w, L_w = sv.min() ** 2, sv.max() ** 2                   # mu = sigma_min(X)², L = sigma_max(X)²
fw = lambda w: 0.5 * np.sum((Xw @ w - yw) ** 2)
ws = gd(lambda w: Xw.T @ (Xw @ w - yw), np.zeros(dd), 1 / L_w, 400)
fv = np.array([fw(w) for w in ws])
k = np.arange(1, 401)
print(f"mínimos cuadrados d > m: mu = {mu_w:.2f}, L = {L_w:.1f}, kappa = {L_w / mu_w:.1f}, rango de la hessiana = {np.linalg.matrix_rank(Xw.T @ Xw)} de {dd}")
print("¿f(w_k) <= (1 - mu/L)^k f(w_0)?", np.all(fv[1:] <= (1 - mu_w / L_w) ** k * fv[0] * (1 + 1e-9)), f"   f(w_400) = {fv[-1]:.1e}")

Observe the first result: with η=1/L\eta = 1/L and f′′(0)=2+6=8=Lf''(0) = 2 + 6 = 8 = L, the local quadratic matches the majorizer, the step’s linear term cancels and GD converges cubically near 00 (floating-point arithmetic reaches exact 00 in a few steps), making the linear bound extremely conservative. In least squares the Hessian has rank 30 of 100 (not strongly convex at all), yet error falls by factor ≤1−μ/L\le 1 - \mu/L per step, as the example claims. Finally the general nonconvex case checks stationarity and displays the saddle:

[ ]Stationarity in nonconvex functionsBrowser
f2 = lambda V: np.sin(V[..., 0]) * np.sin(V[..., 1])
g2 = lambda V: np.stack([np.cos(V[..., 0]) * np.sin(V[..., 1]), np.sin(V[..., 0]) * np.cos(V[..., 1])], axis=-1)

rng = np.random.default_rng(3)
V = rng.uniform(-3, 3, (500, 2))                         # 500 inicios a la vez; L = 1, f* = −1, eta = 1/L
f0 = f2(V) + 1
min_g2 = np.full(len(V), np.inf)
peor = 0.0
for k in range(1, 301):
    min_g2 = np.minimum(min_g2, np.sum(g2(V) ** 2, axis=1))   # min_{i<k} ‖∇f(x_i)‖²
    peor = max(peor, np.max(min_g2 / (2 * f0 / k)))
    V = V - g2(V)
print(f"max de (min ‖∇f‖²) / (2L(f0 - f*)/k) sobre 500 inicios y 300 pasos: {peor:.3f}   (el teorema dice <= 1)")
print(f"inicios que acaban en un mínimo (f < -0.99): {np.mean(f2(V) < -0.99):.3f}")

for nombre, v0 in [("sobre la diagonal", [0.9, 0.9]), ("diagonal + 0.001", [0.9, 0.901])]:
    v = np.array(v0)
    for _ in range(600):
        v = v - g2(v)
    print(f"{nombre:18s}: f = {f2(v):+.4f}   ‖∇f‖ = {np.linalg.norm(g2(v)):.1e}")

The theorem’s bound is never violated (ratio below 1), and all 500 random starts end at a minimum: landing on a saddle requires starting in a measure-zero set. But starting on the diagonal ends with ∥∇f∥=0\norm{\grad f} = 0 to machine precision and f=0f = 0: a perfect stationary point that is not a minimum (with η=1/L\eta = 1/L and curvature 1=L1 = L along the diagonal, GD reaches the saddle cubically). The same start displaced by a thousandth ends at f=−1f = -1. Finally, the synthesis plot with bounds:

[ ]Curves with boundsBrowser
import matplotlib.pyplot as plt

fig, axs = plt.subplots(1, 3, figsize=(11, 3.4))

# (a) fuertemente convexas: rectas en semilog
for nombre, prob, e, c in [("cuadrática kappa=100", quad, e_quad, "C0"), ("logística con l2", logreg, e_log, "C1")]:
    n_ = tramo(e); k = np.arange(n_)
    axs[0].semilogy(k, e[:n_], color=c, label=nombre)
    axs[0].semilogy(k, (1 - prob["mu"] / prob["L"]) ** k * e[0], "--", color=c, alpha=0.7)
axs[0].set_ylim(1e-12, 1e3); axs[0].set_title("lineal: real y cota (discontinua)", fontsize=10)
axs[0].set_xlabel("k"); axs[0].legend(fontsize=8)

# (b) separable: recta de pendiente −1 en log-log
k = np.arange(1, len(e_sep))
axs[1].loglog(k, e_sep[1:], label="logística separable")
axs[1].loglog(k, e_sep[-1] * (len(e_sep) - 1) / k, "--", label="C/k")
axs[1].set_title("sublineal: pendiente −1", fontsize=10); axs[1].set_xlabel("k"); axs[1].legend(fontsize=8)

# (c) PL no convexas
xs = gd(dg, 3.9, 0.5 / L_g, 400)
axs[2].semilogy(g(xs)[:60], label="x² + 3 sin² x")
axs[2].semilogy(fv[:200], label="mínimos cuadrados d > m")
axs[2].semilogy(np.arange(200), (1 - mu_w / L_w) ** np.arange(200) * fv[0], "--", color="C1", alpha=0.7)
axs[2].set_ylim(1e-25, 1e4); axs[2].set_title("PL: lineal sin convexidad", fontsize=10); axs[2].set_xlabel("k"); axs[2].legend(fontsize=8)
plt.tight_layout()
plt.show()

The professional version

In a real project you do not write fitting by hand: scipy provides regression with standard errors, nonlinear fitting and reference minimizers. The important lesson here is why regularized logistic’s observed rate (0.790.79) is far from the proved one (0.9840.984). The theorem uses global constants (μ=λ\mu = \lambda bounds curvature everywhere, but the Hessian approaches it only as ∥w∥→∞\norm{\vb{w}} \to \infty), while the curve’s tail is governed by local curvature at w⋆\vb{w}^\star.

[ ]Local constants and fits with scipyBrowser
from scipy import linalg, optimize, stats

# 1) curvatura local en w*: autovalores de la hessiana y factor asintótico esperado de f
ev = linalg.eigvalsh(hess_r(logreg["xstar"]))
eta = 1 / L_r
print(f"hessiana en w*: lambda_min = {ev[0]:.4f}, lambda_max = {ev[-1]:.4f}   (globales: mu = {l2}, L = {L_r:.4f})")
print(f"factor local esperado de f por paso, (1 - eta lambda_min)²: {(1 - eta * ev[0]) ** 2:.4f}   |   observado: {ajuste_semilog(e_log)[0]:.4f}")

# 2) comprobar f* con un optimizador de referencia
res = optimize.minimize(logreg["f"], np.zeros(p), jac=logreg["grad"], method="L-BFGS-B", tol=1e-14)
print(f"L-BFGS-B: f - f* = {res.fun - logreg['fstar']:.1e} en {res.nit} iteraciones (GD necesita ~100 para llegar a 1e-12)")

# 3) regresión lineal con errores típicos (semilog) y ajuste no lineal de una potencia (log-log)
n_ = tramo(e_quad); k = np.arange(n_)
lr = stats.linregress(k[n_ // 2:], np.log(e_quad[n_ // 2:n_]))
print(f"linregress en la cuadrática: rho = {np.exp(lr.slope):.5f}, R2 = {lr.rvalue ** 2:.6f}")
kk = np.arange(1, len(e_sep))
mitad = slice(len(kk) // 2, None)
(C, pot), cov = optimize.curve_fit(lambda k, C, p_: C * k ** (-p_), kk[mitad], e_sep[1:][mitad], p0=(1.0, 1.0))
print(f"curve_fit en la separable: error ≈ {C:.2f}·k^(-{pot:.3f})   (error típico del exponente {np.sqrt(cov[1, 1]):.1e})")

The first line is key: the Hessian-predicted factor at w⋆\vb{w}^\star matches observation to four digits, and smallest local eigenvalue (0.0350.035) is seven times μ=λ=0.005\mu = \lambda = 0.005, because data add curvature that the theorem deliberately does not count. Theorems give guarantees for the whole class; a particular problem’s rate is set by its local spectrum. That does not make them useless: the global bound alone holds without calculating w⋆\vb{w}^\star.

Common mistakes

Exercises

ProofThe quadratic upper bound
Prove: If ∇f\grad f is LL-Lipschitz, then f(y)≤f(x)+∇f(x)⊤(y−x)+L2∥y−x∥2f(\vb{y}) \le f(\vb{x}) + \grad f(\vb{x})\T(\vb{y} - \vb{x}) + \frac{L}{2}\norm{\vb{y} - \vb{x}}^2 for every x,y\vb{x}, \vb{y}.
0
Fix x\vb{x} and y\vb{y} and consider φ(t)=f(x+t(y−x))\varphi(t) = f(\vb{x} + t(\vb{y} - \vb{x})) for t∈[0,1]t \in [0, 1].

Step 1 of 3. How do you express f(y)−f(x)−∇f(x)⊤(y−x)f(\vb{y}) - f(\vb{x}) - \grad f(\vb{x})\T(\vb{y} - \vb{x}) as an integral?

ProofThe $1/k$ GD rate for convex functions
Prove: If ff is convex and LL-smooth and xi+1=xi−1L∇f(xi)\vb{x}_{i+1} = \vb{x}_i - \frac{1}{L}\grad f(\vb{x}_i), then f(xk)−f⋆≤L∥x0−x⋆∥22kf(\vb{x}_k) - f^\star \le \frac{L\norm{\vb{x}_0 - \vb{x}^\star}^2}{2k}.
0
Write gi=∇f(xi)\vb{g}_i = \grad f(\vb{x}_i) and ai=xi−x⋆\vb{a}_i = \vb{x}_i - \vb{x}^\star. You have the descent lemma and f(x)−f⋆≤∇f(x)⊤(x−x⋆)f(\vb{x}) - f^\star \le \grad f(\vb{x})\T(\vb{x} - \vb{x}^\star).

Step 1 of 4. Combine the inequalities to bound f(xi+1)−f⋆f(\vb{x}_{i+1}) - f^\star.

ProofStrong convexity implies PL
Prove: If ff is differentiable and μ\mu-strongly convex with minimizer x⋆\vb{x}^\star, then 12∥∇f(x)∥2≥μ (f(x)−f⋆)\frac12\norm{\grad f(\vb{x})}^2 \ge \mu\,(f(\vb{x}) - f^\star) for every x\vb{x}.
0
Start with lesson 3's quadratic lower bound.

Step 1 of 4. What inequality holds at any point x\vb{x}?

NumericSix digits with κ = 1000
A μ\mu-strongly convex LL-smooth function has κ=1000\kappa = 1000. With η=1/L\eta = 1/L, what is the smallest integer iteration count kk for which proved bound f(xk)−f⋆≤(1−1/κ)k (f(x0)−f⋆)f(\vb{x}_k) - f^\star \le (1 - 1/\kappa)^k\,(f(\vb{x}_0) - f^\star) guarantees reducing f−f⋆f - f^\star by factor 10610^{6}?
NumericThe factor for an arbitrary step
An LL-smooth μ\mu-PL function has L=10L = 10 and μ=1\mu = 1. Apply GD with η=0.15\eta = 0.15. What per-step factor 1−ημ(2−Lη)1 - \eta\mu(2 - L\eta) does the theorem guarantee for f(xk)−f⋆f(\vb{x}_k) - f^\star?
NumericA gradient of $10^{-3}$
A nonconvex LL-smooth function has L=4L = 4 and f(x0)−f⋆=2.5f(\vb{x}_0) - f^\star = 2.5. With η=1/L\eta = 1/L, how many iterations does the stationarity theorem guarantee to find an iterate with ∥∇f(xi)∥≤10−3\norm{\grad f(\vb{x}_i)} \le 10^{-3}?
QuizWhat does this curve say?
Plot training error f(xk)−f⋆f(\vb{x}_k) - f^\star. On semilog the curve falls and flattens increasingly (concave upward, not straight). On log-log it is a line of slope −2-2. What follows?
QuizWhich satisfy PL?
Select all functions ff that are PL (with some constant μ>0\mu > 0 and attained minimum f⋆f^\star):

More than one answer may be correct.

QuizA tiny gradient
GD with η=1/L\eta = 1/L on a nonconvex, LL-smooth, bounded-below function runs until ∥∇f(xk)∥=10−9\norm{\grad f(\vb{x}_k)} = 10^{-9}. What can you assert without further assumptions?
CodeA rate classifier
Implement estimate_rate(errors). It receives a positive error sequence decreasing to zero and returns a pair (tipo, valor), where tipo is one of sublineal (error ≈Ck−p\approx C k^{-p}, and valor =p= p), lineal (error ≈Cρk\approx C\rho^k, and valor =ρ= \rho) or superlineal (order exceeds 1, and valor is order qq of ek+1≈Cek qe_{k+1} \approx C e_k^{\,q}). Write the type exactly as shown, lowercase without accents or spaces. Work on the second half of the sequence to leave the transient behind. Design hint: order is the slope of log⁡ek+1\log e_{k+1} versus log⁡ek\log e_k; between linear and sublinear decide which fit, semilog or log-log, gives a better line.
import numpy as np

def estimate_rate(errors):
  # devuelve ("sublineal" | "lineal" | "superlineal", valor)
  pass
Shift+Enter to run

Summary

Key idea
A convergence rate is a prediction falsifiable by a plot: linear is a semilog line (slope log⁡ρ\log\rho, ρ≈1−1/κ\rho \approx 1 - 1/\kappa), sublinear a log-log line, and superlinear curves downward in semilog. Everything follows from the descent lemma f(x+)≤f(x)−12L∥∇f(x)∥2f(\vb{x}^+) \le f(\vb{x}) - \frac{1}{2L}\norm{\grad f(\vb{x})}^2: summing and telescoping gives 1/k1/k with convexity, (1−μ/L)k(1 - \mu/L)^k with strong convexity or PL, and min⁡∥∇f∥2≤2L(f0−f⋆)/k\min\norm{\grad f}^2 \le 2L(f_0 - f^\star)/k without convexity.
  • Orders. Sublinear (ek≈k−pe_k \approx k^{-p}), linear (ek+1≤ρeke_{k+1} \le \rho e_k), superlinear (ek+1/ek→0e_{k+1}/e_k \to 0), and order qq (ek+1≤Cekqe_{k+1} \le C e_k^q). Measure order from slope of log⁡ek+1\log e_{k+1} versus log⁡ek\log e_k. Linear cost is ln⁡(1/ε)/ln⁡(1/ρ)≈κln⁡(1/ε)\ln(1/\varepsilon)/\ln(1/\rho) \approx \kappa\ln(1/\varepsilon).
  • Descent lemma. For LL-smooth ff, f(x−η∇f(x))≤f(x)−η(1−Lη/2)∥∇f(x)∥2f(\vb{x} - \eta\grad f(\vb{x})) \le f(\vb{x}) - \eta(1 - L\eta/2)\norm{\grad f(\vb{x})}^2: descent is guaranteed iff η<2/L\eta < 2/L, optimal at η=1/L\eta = 1/L. GD minimizes the curvature-LL quadratic majorizer.
  • Convex LL-smooth. f(xk)−f⋆≤L∥x0−x⋆∥2/(2k)f(\vb{x}_k) - f^\star \le L\norm{\vb{x}_0 - \vb{x}^\star}^2/(2k) by telescoping and monotonicity; O(1/ε)\bigO(1/\varepsilon) iterations and iterates remain in a ball.
  • Strongly convex. f(xk)−f⋆≤(1−μ/L)k(f(x0)−f⋆)f(\vb{x}_k) - f^\star \le (1 - \mu/L)^k(f(\vb{x}_0) - f^\star) and O(κlog⁡(1/ε))\bigO(\kappa\log(1/\varepsilon)) iterations; with tiny μ\mu the sublinear bound dominates.
  • Nonconvex. min⁡i<k∥∇f(xi)∥2≤2L(f(x0)−f⋆)/k\min_{i<k}\norm{\grad f(\vb{x}_i)}^2 \le 2L(f(\vb{x}_0) - f^\star)/k: an ε\varepsilon-stationary point in O(1/ε2)\bigO(1/\varepsilon^2) steps. Stationary is not minimum.
  • PL condition. 12∥∇f∥2≥μ(f−f⋆)\frac12\norm{\grad f}^2 \ge \mu(f - f^\star) gives exactly the linear rate without convexity; includes strong convexity, overparameterized least squares and nonlinear residuals with full-rank Jacobian. It forbids saddles and plateaus with positive error.
  • Theory and practice. Bounds are global and pessimistic; the observed rate is set by local curvature at the optimum, and deviations are useful diagnostics.