Foundations to Frontier
Tests
A. Mathematical Foundations › A6 Optimization › Foundations

Gradient Descent: Derivation, Step Size and Convergence

Gradient descent is the workhorse of optimization and machine learning: repeatedly step a little way downhill along the negative gradient. You will derive it three ways (steepest descent, a local quadratic model, and a continuous-time flow), learn why the step size must stay below 2/L, prove the descent lemma and the linear rate (1 − μ/L) on strongly convex problems, see how the condition number makes GD zig-zag, and fix a badly conditioned gyro-bias calibration by standardizing features.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Take a small step downhill, then repeat

Standing on a hillside, you can feel which direction is steepest downhill. Gradient descent says: take a step that way, look again, take another step. Big steps are fast but might overshoot the bottom and land higher up the other side. Tiny steps are safe but slow.

In a long, narrow valley, “steepest downhill” points mostly across the valley, not along it. So you zig-zag from wall to wall, creeping slowly toward the bottom.

Gradient descent: step size and conditioning
η = 0.100 (2/L = 0.200) · contraction per step max|1 − ηλ| = 0.900 · steps to ‖x‖ < 10⁻³: 69
The gradient points across the narrow valley, not along it, so GD zig-zags. The steep direction (curvature L) limits the step to η < 2/L, while progress along the flat direction (curvature μ) is only ημ per step, so the number of steps grows like κ. With κ = 1 the contours are circles and η = 1/L reaches the minimum in one step. Rotation doesn't change the rate (GD is rotation-invariant), but rescaling the axes does: that's why feature standardization and preconditioning help.
Why engineers care

Training every neural network, fitting calibration models, tuning controllers and solving large least-squares problems in navigation all use gradient descent or its descendants. Choosing the step size and fixing poor scaling are everyday engineering skills.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Gradient descent steps in the direction of…
  2. 2. A step size that's too large can…
  3. 3. In a narrow valley, gradient descent tends to…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

The update

xk+1=xk−η ∇f(xk)x_{k+1} = x_k - \eta\,\nabla f(x_k)

η>0\eta > 0 is the step size (learning rate).

Why the negative gradient? The directional derivative in a unit direction dd is ∇f⊤d\nabla f^\top d. By Cauchy–Schwarz it’s smallest, equal to −∥∇f∥-\|\nabla f\|, when d=−∇f/∥∇f∥d = -\nabla f/\|\nabla f\|. That’s the direction of steepest descent.

Example: a 1-D quadratic

f(x)=a2x2f(x) = \frac a2x^2, so xk+1=(1−ηa)xkx_{k+1} = (1 - \eta a)x_k.

  • 0<η<2/a0 < \eta < 2/a: converges, because ∣1−ηa∣<1|1 - \eta a| < 1.
  • η=1/a\eta = 1/a: reaches the minimum in one step.
  • 1/a<η<2/a1/a < \eta < 2/a: converges while overshooting back and forth.
  • η>2/a\eta > 2/a: diverges.
📝 Quick check (Level 1)
0/3 answered
  1. 1. For f = (a/2)x², GD converges iff…
  2. 2. The steepest-descent direction is…
  3. 3. For f = 2x² (a = 4), the one-step step size is…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 45 minUndergraduate students and practising engineers.

Three derivations

  1. Steepest descent, as in Level 1.
  2. Minimize a local quadratic model: f(x)≈f(xk)+∇f(xk)⊤(x−xk)+12η∥x−xk∥2f(x)\approx f(x_k) + \nabla f(x_k)^\top(x - x_k) + \frac1{2\eta}\|x - x_k\|^2. Its minimizer is the GD step. Replacing 1ηI\frac1\eta I by the true Hessian gives Newton’s method (A6.1-4).
  3. Gradient flow: x˙=−∇f(x)\dot x = -\nabla f(x), discretized by forward Euler with time step η\eta.

Step size, L-smoothness and conditioning

If ∇f\nabla f is LL-Lipschitz (A3.5-3), then η≤1/L\eta\le1/L guarantees descent, and η<2/L\eta < 2/L is the stability limit on quadratics. On a quadratic with Hessian eigenvalues in [μ,L][\mu, L], each step contracts the error by

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

η=1/L\eta = 1/L gives 1−1/κ1 - 1/\kappa, where κ=L/μ\kappa = L/\mu is the condition number. The best fixed step η=2/(L+μ)\eta = 2/(L + \mu) gives (κ−1)/(κ+1)(\kappa - 1)/(\kappa + 1). You need about κln⁡(1/ε)\kappa\ln(1/\varepsilon) steps. With κ=1000\kappa = 1000 that’s thousands.

Practical rules

  • Standardize features and choose sensible units. Rescaling changes κ\kappa.
  • Check your gradient with finite differences before trusting an optimizer.
  • Monitor the loss and ∥∇f∥\|\nabla f\|. Stop on a small gradient or a small relative change.
  • If the loss explodes, lower η\eta. If progress is glacial, use a line search (A6.1-5), momentum (A6.3-3) or preconditioning.
🐍 Exercise 1: gradient descent on a quadratic
Implement GD and the contraction factor. Verify monotone convergence with η = 1/L, the faster optimal step 2/(L + μ), divergence above 2/L, and the observed rate 1 − μ/L.
📝 Quick check (Level 2)
0/3 answered
  1. 1. With η = 1/L on a quadratic, the error contracts per step by…
  2. 2. The best fixed step on a quadratic is…
  3. 3. Standardizing features mainly reduces…

Level 3: Advanced

★★★★☆ Advanced⏱ 45 minGraduate level, with full derivations and proofs.

The descent lemma

If ∇f\nabla f is LL-Lipschitz, then f(y)≤f(x)+∇f(x)⊤(y−x)+L2∥y−x∥2f(y)\le f(x) + \nabla f(x)^\top(y - x) + \frac L2\|y - x\|^2. Put in y=x−η∇f(x)y = x - \eta\nabla f(x):

f(xk+1)≤f(xk)−η(1−Lη2)∥∇f(xk)∥2f(x_{k+1})\le f(x_k) - \eta\big(1 - \tfrac{L\eta}2\big)\|\nabla f(x_k)\|^2

For 0<η<2/L0 < \eta < 2/L the objective strictly decreases unless ∇f=0\nabla f = 0. With η=1/L\eta = 1/L, the decrease is at least 12L∥∇f∥2\frac1{2L}\|\nabla f\|^2. ∎

Rates

  • Non-convex, L-smooth: summing the descent lemma gives min⁡k<K∥∇f(xk)∥2≤2L(f(x0)−f⋆)K\min_{k < K}\|\nabla f(x_k)\|^2\le\frac{2L(f(x_0) - f^\star)}K. That’s convergence to a stationary point at rate O(1/K)O(1/K).
  • Convex: f(xK)−f⋆≤L∥x0−x⋆∥22Kf(x_K) - f^\star\le\frac{L\|x_0 - x^\star\|^2}{2K}.
  • μ-strongly convex: f(xK)−f⋆≤(1−μ/L)K(f(x0)−f⋆)f(x_K) - f^\star\le(1 - \mu/L)^K(f(x_0) - f^\star), a linear (geometric) rate. Proved in A6.3-2 using the Polyak–Łojasiewicz inequality ∥∇f∥2≥2μ(f−f⋆)\|\nabla f\|^2\ge2\mu(f - f^\star).

Quadratic analysis

For f=12x⊤Hx−b⊤xf = \frac12x^\top Hx - b^\top x, the error ek=xk−x⋆e_k = x_k - x^\star obeys ek+1=(I−ηH)eke_{k+1} = (I - \eta H)e_k. In the eigenbasis each component scales by 1−ηλi1 - \eta\lambda_i, which gives ρ(η)\rho(\eta). Minimizing max⁡i∣1−ηλi∣\max_i|1 - \eta\lambda_i| balances 1−ημ=ηL−11 - \eta\mu = \eta L - 1, so η=2/(L+μ)\eta = 2/(L + \mu). ∎

Exercise 3.1: How many steps for κ = 100, ε = 10⁻⁶, η = 1/L?

k=⌈ln⁡10−6/ln⁡0.99⌉=1375k = \lceil\ln10^{-6}/\ln0.99\rceil = 1375. With the optimal step: ⌈ln⁡10−6/ln⁡(99/101)⌉=691\lceil\ln10^{-6}/\ln(99/101)\rceil = 691.

📝 Quick check (Level 3)
0/3 answered
  1. 1. With η = 1/L, the descent lemma guarantees a decrease of at least…
  2. 2. On non-convex smooth f, GD guarantees…
  3. 3. On strongly convex f, GD converges…

Level 4: Expert

★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.

Calibrating a gyro bias

A gyro’s bias depends on temperature (≈ 300 K) and supply voltage (≈ 5 V): b=c0+c1T+c2Vb = c_0 + c_1T + c_2V. With raw features, A⊤AA^\top A has condition number about 10810^8, because the columns are large and nearly collinear with the intercept. GD with the safe step 1/L1/L makes essentially no progress in 20,000 steps. After standardizing each feature (zero mean, unit variance), κ≈1.1\kappa\approx1.1 and GD converges in a handful of steps. The model is the same; only the coordinates changed.

🐍 Exercise 2 (research): conditioning a calibration fit
Fit a gyro-bias model by GD. Compare iterations to 0.1% error with raw vs standardized features, and relate them to the condition number.

Gradient descent in AI, robotics and aerospace

  • Deep learning: SGD and its variants train essentially all neural networks (A6.3). The full-batch GD analysis here is the foundation (Bottou, Curtis and Nocedal, 2018).
  • Iterative least squares in navigation and calibration, where preconditioning and scaling decide convergence.
  • Trajectory optimization: CHOMP is covariant (preconditioned) gradient descent on trajectories (Ratliff et al., 2009).
  • Gradient flow connects optimization to dynamical systems and control, including Lyapunov-style convergence proofs (Wilson, Recht and Jordan, 2021).

References

  1. A. Cauchy (1847). “Méthode générale pour la résolution des systèmes d’équations simultanées.” Comptes Rendus, 25.
  2. Y. Nesterov (2018). Lectures on Convex Optimization, 2nd ed. Springer. Ch. 1–2.
  3. J. Nocedal, S. Wright (2006). Numerical Optimization, 2nd ed. Springer. Ch. 3.
  4. S. Boyd, L. Vandenberghe (2004). Convex Optimization. Cambridge University Press. §9.3.
  5. S. Bubeck (2015). “Convex optimization: algorithms and complexity.” Foundations and Trends in Machine Learning, 8(3–4).
  6. L. Bottou, F. Curtis, J. Nocedal (2018). “Optimization methods for large-scale machine learning.” SIAM Review, 60(2).
  7. H. Karimi, J. Nutini, M. Schmidt (2016). “Linear convergence of gradient and proximal-gradient methods under the Polyak–Łojasiewicz condition.” ECML-PKDD.
  8. N. Ratliff, M. Zucker, J. A. Bagnell, S. Srinivasa (2009). “CHOMP: gradient optimization techniques for efficient motion planning.” ICRA.
  9. A. Wilson, B. Recht, M. Jordan (2021). “A Lyapunov analysis of accelerated methods in optimization.” JMLR, 22.
  10. B. Polyak (1987). Introduction to Optimization. Optimization Software.