Skip to main content
© 2026 ePowerAI — free, open courseware. No login required.
CoursesContact
ePOWERAI
CoursesContact
Week 3: Gradient Descent Theory
Optimization

Foundations

  1. 01Week 1: Optimization for Learning
  2. 02Week 2: Convex Sets and Functions
  3. 03Week 3: Gradient Descent Theory

Model problems

  1. 04Week 4: Least Squares and Conditioning
  2. 05Week 5: Classification Losses

First-order stack

  1. 06Week 6: Stochastic Gradient Descent
  2. 07Week 7: Momentum and Acceleration
  3. 08Week 8: Adaptive First-Order Methods
  4. 09Week 9: Practical Training Dynamics

Structure

  1. 10Week 10: Nonsmooth and Composite Objectives
  2. 11Week 11: Constraints: Projections and Penalties
  3. 12Week 12: Duality for Practitioners

Nonconvex practice

  1. 13Week 13: Nonconvex Deep Learning
  2. 14Week 14: Capstone — Theory Meets Training
Week 03· Optimization· Foundations7 min read

Week 3: Gradient Descent Theory

Learning Outcomes
  • Define LLL-smoothness (Lipschitz gradients) and derive the quadratic upper bound
  • Explain why η<2/L\eta < 2/Lη<2/L is the step-size limit and why η=1/L\eta = 1/Lη=1/L gives the largest guaranteed decrease per step
  • Define strong convexity (μ>0\mu > 0μ>0) and explain the improvement in convergence rate
  • Write the convergence rates for smooth convex and strongly convex GD, and explain why the step 2/(L+μ)2/(L + \mu)2/(L+μ) beats 1/L1/L1/L when κ>1\kappa > 1κ>1
Prerequisites

Background: Week 1 (GD algorithm, gradient mechanics) and Week 2 (convexity, PSD quadratics, local = global theorem). The convexity definitions from Week 2 are used directly in the convergence proofs.

Later weeks: These convergence rates explain why SGD, momentum, and Adam behave the way they do (Weeks 6–9).

Your training loss falls for three steps, then climbs, then prints nan. You halve the learning rate and the same run settles. One number separates those two runs, and this week finds it. The bowl below is the loss f(x,y)=12(x2+4y2)f(x, y) = \frac{1}{2}(x^2 + 4y^2)f(x,y)=21​(x2+4y2), and the amber path is gradient descent from (2.6,1.4)(2.6, 1.4)(2.6,1.4).

A bowl-shaped loss surface f(x, y) = (x² + 4y²) / 2 with its minimum at the origin. Gradient descent starts at (2.6, 1.4) with step size η = 0.375. It takes 16 steps and overshoots in y and zigzags in.

With L = 4 and η = 0.375, each step multiplies x by 0.63 and y by −0.50. Gradient descent overshoots in y and zigzags in.

Drag the step size and watch the path. Below 1/L1/L1/L it slides down without overshoot. Between 1/L1/L1/L and 2/L2/L2/L it zigzags across the narrow direction and still lands. At 2/L2/L2/L it bounces forever, and past it it climbs the wall and leaves the bowl.

Why the line sits at 2/L#

The gradient of the bowl is (x,4y)(x, 4y)(x,4y), so one step of size η\etaη maps x↦(1−η)xx \mapsto (1 - \eta)xx↦(1−η)x and y↦(1−4η)yy \mapsto (1 - 4\eta)yy↦(1−4η)y. The caption prints both factors. A coordinate shrinks only when its factor has magnitude below 1. For yyy that needs ∣1−4η∣<1|1 - 4\eta| < 1∣1−4η∣<1, so 0<η<2/40 < \eta < 2/40<η<2/4. The steepest curvature, 4, sets the limit.

Smoothness: a curvature limit for any function#

A general loss has no single curvature. Smoothness puts a ceiling on it. A differentiable fff is LLL-smooth if its gradient is LLL-Lipschitz:

∥∇f(x)−∇f(y)∥2≤L∥x−y∥2for all x,y\|\nabla f(x) - \nabla f(y)\|_2 \leq L \|x - y\|_2 \quad \text{for all } x, y∥∇f(x)−∇f(y)∥2​≤L∥x−y∥2​for all x,y

For f(x)=12xTQxf(x) = \frac{1}{2}x^T Q xf(x)=21​xTQx with Q⪰0Q \succeq 0Q⪰0, the gradient is QxQxQx, and ∥Q(x−y)∥≤λmax⁡(Q)∥x−y∥\|Q(x - y)\| \leq \lambda_{\max}(Q)\|x - y\|∥Q(x−y)∥≤λmax​(Q)∥x−y∥. So L=λmax⁡(Q)L = \lambda_{\max}(Q)L=λmax​(Q). The bowl has Q=diag(1,4)Q = \mathrm{diag}(1, 4)Q=diag(1,4) and L=4L = 4L=4, the curvature of its narrow direction.

Smoothness gives a quadratic upper bound:

f(y)≤f(x)+∇f(x)T(y−x)+L2∥y−x∥22f(y) \leq f(x) + \nabla f(x)^T (y - x) + \frac{L}{2}\|y - x\|_2^2f(y)≤f(x)+∇f(x)T(y−x)+2L​∥y−x∥22​

With the linear lower bound of convexity (Week 2), a convex LLL-smooth function lies between a plane and a bowl of curvature LLL.

The descent lemma#

Put the step y=x−η∇f(x)y = x - \eta \nabla f(x)y=x−η∇f(x) into the upper bound:

f(x−η∇f(x))≤f(x)−η(1−Lη2)∥∇f(x)∥2f(x - \eta \nabla f(x)) \leq f(x) - \eta\left(1 - \frac{L\eta}{2}\right)\|\nabla f(x)\|^2f(x−η∇f(x))≤f(x)−η(1−2Lη​)∥∇f(x)∥2

The bracket is positive when η<2/L\eta < 2/Lη<2/L. That is the line you crossed in the bowl, now for every LLL-smooth function. Past 2/L2/L2/L the bound promises nothing, and the bowl diverges. The term η(1−Lη/2)\eta(1 - L\eta/2)η(1−Lη/2) is largest at η=1/L\eta = 1/Lη=1/L, which gives

f(xk+1)≤f(xk)−12L∥∇f(xk)∥2f(x_{k+1}) \leq f(x_k) - \frac{1}{2L}\|\nabla f(x_k)\|^2f(xk+1​)≤f(xk​)−2L1​∥∇f(xk​)∥2

This is the descent lemma. Each step removes at least 12L∥∇f∥2\frac{1}{2L}\|\nabla f\|^22L1​∥∇f∥2 of loss while the gradient is nonzero.

Convergence for convex smooth functions#

Start at x0x_0x0​ with distance R=∥x0−x∗∥R = \|x_0 - x^*\|R=∥x0​−x∗∥ to an optimum x∗x^*x∗. After KKK steps of size η=1/L\eta = 1/Lη=1/L on a convex LLL-smooth function:

f(xK)−f(x∗)≤2LR2Kf(x_K) - f(x^*) \leq \frac{2L R^2}{K}f(xK​)−f(x∗)≤K2LR2​

This is the O(1/K)\mathcal{O}(1/K)O(1/K) sublinear rate. To halve the gap, you double the iterations. To reach accuracy ε\varepsilonε, you need K∝LR2/εK \propto L R^2 / \varepsilonK∝LR2/ε iterations.

Strong convexity and the condition number#

A function fff is μ\muμ-strongly convex if, for some μ>0\mu > 0μ>0,

f(y)≥f(x)+∇f(x)T(y−x)+μ2∥y−x∥22f(y) \geq f(x) + \nabla f(x)^T (y - x) + \frac{\mu}{2}\|y - x\|_2^2f(y)≥f(x)+∇f(x)T(y−x)+2μ​∥y−x∥22​

For a quadratic, μ=λmin⁡(Q)\mu = \lambda_{\min}(Q)μ=λmin​(Q). The bowl has μ=1\mu = 1μ=1, so its condition number is κ=L/μ=4\kappa = L/\mu = 4κ=L/μ=4. The level sets are ellipses with axis ratio κ=2\sqrt{\kappa} = 2κ​=2.

With step η=2/(L+μ)\eta = 2/(L + \mu)η=2/(L+μ), GD converges linearly (Nesterov 2004, Theorem 2.1.15):

∥xK−x∗∥≤(κ−1κ+1)K∥x0−x∗∥\|x_K - x^*\| \leq \left(\frac{\kappa - 1}{\kappa + 1}\right)^K \|x_0 - x^*\|∥xK​−x∗∥≤(κ+1κ−1​)K∥x0​−x∗∥

The error shrinks by a fixed factor every step, so accuracy ε\varepsilonε costs O(κlog⁡(1/ε))\mathcal{O}(\kappa \log(1/\varepsilon))O(κlog(1/ε)) iterations.

Worked example. For the bowl, 2/(L+μ)=2/5=0.42/(L + \mu) = 2/5 = 0.42/(L+μ)=2/5=0.4, which is 1.6/L1.6/L1.6/L on the slider. The factors are 1−0.4=0.61 - 0.4 = 0.61−0.4=0.6 for xxx and 1−1.6=−0.61 - 1.6 = -0.61−1.6=−0.6 for yyy. Both have magnitude (κ−1)/(κ+1)=3/5(\kappa - 1)/(\kappa + 1) = 3/5(κ−1)/(κ+1)=3/5. Now compare η=1/L=0.25\eta = 1/L = 0.25η=1/L=0.25. It sends yyy to 0 in one step but leaves xxx at factor 0.750.750.75. After 10 steps, xxx keeps 0.7510≈0.0560.75^{10} \approx 0.0560.7510≈0.056 of its start, against 0.610≈0.0060.6^{10} \approx 0.0060.610≈0.006. The fastest step balances the flat direction against the steep one, and it is not 1/L1/L1/L.

Large κ\kappaκ is the hard case. For f(x)=12(x12+100x22)f(x) = \frac{1}{2}(x_1^2 + 100x_2^2)f(x)=21​(x12​+100x22​), κ=100\kappa = 100κ=100 and the best factor is 99/101≈0.98099/101 \approx 0.98099/101≈0.980. GD then needs about 115 steps to cut the error by a factor of 10. Adding λ2∥x∥2\frac{\lambda}{2}\|x\|^22λ​∥x∥2 to a convex objective makes it λ\lambdaλ-strongly convex, which raises μ\muμ, lowers κ\kappaκ, and is why ridge regression (Week 4) converges faster than plain least squares. Momentum (Week 7) cuts the cost to O(κlog⁡(1/ε))\mathcal{O}(\sqrt{\kappa} \log(1/\varepsilon))O(κ​log(1/ε)). Advanced Optimization goes further.

Knowledge Check#

Exercise · Fill in the blank

If L = 10, the descent lemma guarantees a loss decrease for every step size η below ___.

Question 1 of 3

In the bowl, set the step size to 2.1/L. Which coordinate leaves the bowl, and why?

y, because its factor 1 − 2.1 = −1.1 has magnitude above 1
x, because x starts farther from the minimum
Both, because every factor passes 1 beyond 2/L
Neither, because the bowl is convex

Browser lab: step sizes and the 2/L boundary#

Run GD on 1D quadratic f(x)=ax2f(x) = a x^2f(x)=ax2 with L=2aL = 2aL=2a. Compare η=1/L\eta = 1/Lη=1/L (largest guaranteed decrease) vs η=1.8/L\eta = 1.8/Lη=1.8/L (near-divergence) vs η=2.1/L\eta = 2.1/Lη=2.1/L (divergence).

python · runs in browser
import numpy as np
import matplotlib.pyplot as plt

a = 5.0
L = 2 * a
x0 = 4.0
K = 20

def run_gd(eta, x0, K):
    x = x0
    vals = [a * x**2]
    xs = [x]
    for _ in range(K):
        g = 2 * a * x
        x = x - eta * g
        xs.append(x)
        vals.append(a * x**2)
    return np.array(xs), np.array(vals)

etas = [0.5/L, 1/L, 1.8/L, 2.1/L]
labels = ["η=0.5/L", "η=1/L", "η=1.8/L (osc)", "η=2.1/L (diverge)"]

fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 4.5))
ks = np.arange(K + 1)

for eta, lbl in zip(etas, labels):
    xs, vals = run_gd(eta, x0, K)
    ax1.plot(ks, vals, "o-", markersize=3, label=lbl)
    ax2.plot(ks, np.abs(xs), "o-", markersize=3, label=lbl)
    print(f"{lbl:18s} final |x| = {abs(xs[-1]):.3e}  final loss = {vals[-1]:.3e}")

ax1.set_xlabel("Iteration k"); ax1.set_ylabel("f(x_k)")
ax1.set_title(f"Loss vs iteration (L={L})")
ax1.set_yscale("log"); ax1.legend()
ax2.set_xlabel("Iteration k"); ax2.set_ylabel("|x_k|")
ax2.set_title("Distance to optimum")
ax2.set_yscale("log"); ax2.legend()
plt.tight_layout()
plt.show()

print("Notice: η ≤ 2/L decreases the loss at every step; past 2/L the iterates oscillate and eventually diverge.")

Key takeaways#

  • The step size limit comes from the steepest direction. In the bowl, yyy has factor 1−4η1 - 4\eta1−4η and leaves once η>2/4\eta > 2/4η>2/4.
  • LLL-smoothness bounds curvature. The descent lemma follows: every step with η<2/L\eta < 2/Lη<2/L decreases the loss.
  • Convex and LLL-smooth gives the sublinear rate O(1/K)\mathcal{O}(1/K)O(1/K). Strong convexity upgrades it to a linear rate with factor (κ−1)/(κ+1)(\kappa - 1)/(\kappa + 1)(κ−1)/(κ+1).
  • The fastest constant step, 2/(L+μ)2/(L + \mu)2/(L+μ), balances the flat and the steep direction. It is not 1/L1/L1/L.

Further reading#

  • Yurii Nesterov, Introductory Lectures on Convex Optimization (Springer, 2004). Chapter 2 defines smoothness and strong convexity and derives the basic gradient-method rates.
  • Sébastien Bubeck, Convex Optimization: Algorithms and Complexity (2015). Sections 3.1–3.2 prove the O(1/K)\mathcal{O}(1/K)O(1/K) and linear rates for smooth (strongly) convex GD. Freely available at arXiv:1405.4980.
  • Jorge Nocedal & Stephen Wright, Numerical Optimization (2nd ed., Springer, 2006). Chapter 3 collects the step-size and convergence theory used here.

Reading is free. PDF and ePub unlock with the newsletter. Join once and every lesson opens in this browser.

← Previous
Week 2: Convex Sets and Functions
Next →
Week 4: Least Squares and Conditioning
On this page
  • Why the line sits at 2/L
  • Smoothness: a curvature limit for any function
  • The descent lemma
  • Convergence for convex smooth functions
  • Strong convexity and the condition number
  • Knowledge Check
  • Browser lab: step sizes and the 2/L boundary
  • Key takeaways
  • Further reading