Skip to main content
© 2026 ePowerAI. All rights reserved.
CoursesContact
eAI
CoursesContact
Week 3: Gradient Descent Theory
Optimization
01Week 1: Optimization for Learning
02Week 2: Convex Sets and Functions
03Week 3: Gradient Descent Theory
04Week 4: Least Squares and Conditioning
05Week 5: Classification Losses
06Week 6: Stochastic Gradient Descent
07Week 7: Momentum and Acceleration
08Week 8: Adaptive First-Order Methods
09Week 9: Practical Training Dynamics
10Week 10: Nonsmooth and Composite Objectives
11Week 11: Constraints: Projections and Penalties
12Week 12: Duality for Practitioners
13Week 13: Nonconvex Deep Learning
14Week 14: Capstone — Theory Meets Training
Week 03· Optimization· Foundations24 min read

Week 3: Gradient Descent Theory

✦Learning Outcomes
  • Define LLL-smoothness (Lipschitz gradients) and derive the quadratic upper bound
  • State the optimal constant step size η=1/L\eta = 1/Lη=1/L for convex LLL-smooth functions
  • Define strong convexity (μ>0\mu > 0μ>0) and explain the improvement in convergence rate
  • Write the big-O\mathcal{O}O convergence rates for smooth convex and smooth strongly-convex GD
◆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).

Smoothness (L-Lipschitz Gradient)#

A differentiable function fff is LLL-smooth if its gradient is LLL-Lipschitz continuous:

∥∇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

In plain terms: the gradient cannot change too fast. If you move a small distance, the gradient changes by at most LLL times that distance.

This implies a powerful quadratic upper bound (sometimes called the descent lemma):

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​

The convex first-order condition says f(y)≥linearf(y) \geq \text{linear}f(y)≥linear. Smoothness adds the reverse: f(y)≤linear+L2∥y−x∥2f(y) \leq \text{linear} + \frac{L}{2}\|y-x\|^2f(y)≤linear+2L​∥y−x∥2. Together, LLL-smooth convex functions are sandwiched between two quadratics of curvature LLL.

Worked example: Is f(x)=12xTQxf(x) = \frac{1}{2}x^T Q xf(x)=21​xTQx with Q⪰0Q \succeq 0Q⪰0 smooth?

The gradient is ∇f(x)=Qx\nabla f(x) = Qx∇f(x)=Qx, and ∥∇f(x)−∇f(y)∥=∥Q(x−y)∥≤∥Q∥op∥x−y∥\|\nabla f(x) - \nabla f(y)\| = \|Q(x-y)\| \leq \|Q\|_{\text{op}} \|x-y\|∥∇f(x)−∇f(y)∥=∥Q(x−y)∥≤∥Q∥op​∥x−y∥. So fff is LLL-smooth with L=∥Q∥op=λmax⁡(Q)L = \|Q\|_{\text{op}} = \lambda_{\max}(Q)L=∥Q∥op​=λmax​(Q), the largest eigenvalue of QQQ.

For the 2D quadratic from Week 1, Q=(1002)Q = \begin{pmatrix}1 & 0\\ 0 & 2\end{pmatrix}Q=(10​02​), so L=2L = 2L=2.

Descent Lemma#

Plugging the GD update y=x−η∇f(x)y = x - \eta \nabla f(x)y=x−η∇f(x) into the quadratic upper bound:

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

For the decrease term to be meaningful (negative), we need 1−Lη2>01 - \frac{L\eta}{2} > 01−2Lη​>0, i.e. η<2/L\eta < 2/Lη<2/L. The optimal choice minimises the coefficient: η=1/L\eta = 1/Lη=1/L 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: with step size η≤1/L\eta \leq 1/Lη≤1/L, GD guarantees a decrease of at least 12L∥∇f∥2\frac{1}{2L}\|\nabla f\|^22L1​∥∇f∥2 per iteration. As long as the gradient is nonzero, we make progress.

Convergence for Convex Smooth Functions#

Starting from x0x_0x0​ with distance R=∥x0−x∗∥R = \|x_0 - x^*\|R=∥x0​−x∗∥ to an optimum x∗x^*x∗, after KKK iterations of GD with η=1/L\eta = 1/Lη=1/L on a convex LLL-smooth function:

f(xK)−f(x∗)≤2L∥x0−x∗∥2Kf(x_K) - f(x^*) \leq \frac{2L\|x_0 - x^*\|^2}{K}f(xK​)−f(x∗)≤K2L∥x0​−x∗∥2​

This is the O(1/K)\mathcal{O}(1/K)O(1/K) sublinear rate. To halve the optimality gap, you need about twice as many iterations. To reach accuracy ε\varepsilonε, you need K∝LR2εK \propto \frac{L R^2}{\varepsilon}K∝εLR2​ iterations.

What this means in practice: GD on a convex problem is reliable but not fast. Early iterations reduce the loss quickly; later iterations are slow. If you need high accuracy (small ε\varepsilonε), GD alone is expensive.

Strong Convexity#

A function fff is μ\muμ-strongly convex if there exists μ>0\mu > 0μ>0 such that:

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​

This is the convex first-order condition plus a quadratic lower bound. The function must curve upward at rate at least μ\muμ everywhere.

For quadratics f(x)=12xTQxf(x) = \frac{1}{2}x^T Q xf(x)=21​xTQx, strong convexity means Q⪰μIQ \succeq \mu IQ⪰μI, i.e. λmin⁡(Q)≥μ>0\lambda_{\min}(Q) \geq \mu > 0λmin​(Q)≥μ>0. The 2D quadratic from Week 1 has Q=(1002)Q = \begin{pmatrix}1 & 0\\ 0 & 2\end{pmatrix}Q=(10​02​), so μ=1\mu = 1μ=1.

Adding ℓ2\ell_2ℓ2​ regularisation λ2∥x∥2\frac{\lambda}{2}\|x\|^22λ​∥x∥2 to any convex objective makes it λ\lambdaλ-strongly convex. This is why ridge regression (Week 4) has better convergence than plain least squares.

With μ\muμ-strong convexity, GD with η=2/(L+μ)\eta = 2/(L + \mu)η=2/(L+μ) achieves linear convergence:

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

where κ=L/μ\kappa = L/\muκ=L/μ is the condition number. The gap shrinks by a constant factor every iteration, giving O(log⁡(1/ε))\mathcal{O}(\log(1/\varepsilon))O(log(1/ε)) complexity.

Condition Number#

The condition number κ=L/μ\kappa = L/\muκ=L/μ governs how fast GD converges:

  • κ\kappaκ small (well-conditioned): GD converges quickly. The loss surface is roughly spherical.
  • κ\kappaκ large (ill-conditioned): GD converges slowly. The loss surface has elongated valleys where GD zigzags.
  • κ=1\kappa = 1κ=1: The function is perfectly spherical; GD converges in one step with the right η\etaη.

GD's O(κlog⁡(1/ε))\mathcal{O}(\kappa \log(1/\varepsilon))O(κlog(1/ε)) complexity for strongly convex functions is why we later introduce momentum (Week 7 — reduces to O(κ)\mathcal{O}(\sqrt{\kappa})O(κ​)) and adaptive methods (Week 8).

Worked example: For the 2D quadratic f(x)=12(x12+2x22)f(x) = \frac{1}{2}(x_1^2 + 2x_2^2)f(x)=21​(x12​+2x22​):

  • L=2L = 2L=2 (largest eigenvalue)
  • μ=1\mu = 1μ=1 (smallest eigenvalue)
  • κ=2\kappa = 2κ=2 — well-conditioned, GD converges quickly
  • A less friendly case: f(x)=12(x12+100x22)f(x) = \frac{1}{2}(x_1^2 + 100x_2^2)f(x)=21​(x12​+100x22​) with κ=100\kappa = 100κ=100, where GD will creep along the narrow valley
Exercise · Fill in the blank

If $L = 10$, the descent lemma guarantees a loss decrease when the step size $\\eta \\leq$ ___.

Question 1 of 4

An L-smooth function satisfies which bound?

f(y) ≤ f(x) + ∇f(x)^T(y−x) + (L/2)‖y−x‖²
f(y) ≥ f(x) + ∇f(x)^T(y−x) + (L/2)‖y−x‖²
‖∇f(x)‖ ≤ L
f(x) ≤ L‖x‖²

Browser lab#

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 (safe, optimal) 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 (safe)", "η=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)

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()
← Previous
Week 2: Convex Sets and Functions
Next →
Week 4: Least Squares and Conditioning
On this page
  • Smoothness (L-Lipschitz Gradient)
  • Descent Lemma
  • Convergence for Convex Smooth Functions
  • Strong Convexity
  • Condition Number
  • Browser lab