Gradient Descent

⚡ Key Takeaways

Gradient descent is an iterative first-order optimization algorithm that minimizes a differentiable function by repeatedly stepping in the direction of the negative gradient. Key result: for a step size small enough, each iteration xk+1=xk−α∇f(xk)x_{k+1} = x_k - \alpha \nabla f(x_k) decreases the function value, and for convex functions it converges to a global minimum. Where it applies: machine learning, deep neural networks, logistic/linear regression, numerical optimization, signal processing, and any large-scale problem where computing a Hessian is too expensive. Who/when: the method traces to Augustin-Louis Cauchy (1847), with modern stochastic and accelerated variants developed through the 20th and 21st centuries.

💡 The Core Insight

The gradient ∇f(x)\nabla f(x) is the direction of fastest increase of ff at xx. Therefore −∇f(x)-\nabla f(x) is the direction of fastest decrease. By taking small steps "downhill" along −∇f-\nabla f, we slide toward a minimum — just as a ball rolls down the steepest slope of a valley. The only tuning knob is how big a step to take: too small and we crawl; too large and we overshoot or diverge.

Formal Statement

DefinitionGradient Descent Iteration

Let f:Rn→Rf:\mathbb{R}^n \to \mathbb{R} be differentiable. Starting from an initial point x0∈Rnx_0 \in \mathbb{R}^n, gradient descent generates a sequence {xk}\{x_k\} by the update rule:

1
xk+1=xk−αk ∇f(xk)\quad x_{k+1} = x_k - \alpha_k \,\nabla f(x_k)

Derivation hint: subtract a multiple of the gradient because −∇f-\nabla f is the steepest-descent direction; αk>0\alpha_k > 0 scales how far to move. where:

  • xk∈Rnx_k \in \mathbb{R}^n is the iterate (current estimate of the minimizer) at step kk,
  • αk>0\alpha_k > 0 is the step size (learning rate); it may be constant (αk=α\alpha_k = \alpha) or vary with kk,
  • ∇f(xk)=(∂f∂x1,…,∂f∂xn)⊤\nabla f(x_k) = \left(\dfrac{\partial f}{\partial x_1}, \dots, \dfrac{\partial f}{\partial x_n}\right)^\top evaluated at xkx_k is the gradient vector.

The iteration stops when a convergence criterion is met, e.g. ∥∇f(xk)∥<ε\|\nabla f(x_k)\| < \varepsilon for a small tolerance ε\varepsilon.

The justification that −∇f-\nabla f is "best" comes from the directional derivative. For a unit vector uu, the rate of change of ff at xx in direction uu is:

2
Duf(x)=∇f(x)⋅u=∥∇f(x)∥ cos⁡θ\quad D_u f(x) = \nabla f(x) \cdot u = \|\nabla f(x)\|\,\cos\theta

Derivation hint: the directional derivative is the dot product of the gradient with the direction; expand the dot product using the angle θ\theta between them. This is minimized (most negative) when cos⁡θ=−1\cos\theta = -1, i.e. when u=−∇f(x)/∥∇f(x)∥u = -\nabla f(x)/\|\nabla f(x)\|.

TheoremDescent Lemma and Convergence (L-smooth case)

Suppose ff is LL-smooth, meaning its gradient is Lipschitz continuous:

3
∥∇f(x)−∇f(y)∥≤L ∥x−y∥for all x,y.\quad \|\nabla f(x) - \nabla f(y)\| \le L\,\|x - y\| \quad \text{for all } x,y.

Derivation hint: this is the definition of an LL-Lipschitz gradient; it bounds how fast the gradient can change. Then for the constant step size α=1/L\alpha = 1/L, the iterates satisfy the sufficient decrease property:

4
f(xk+1)≤f(xk)−12L ∥∇f(xk)∥2.\quad f(x_{k+1}) \le f(x_k) - \frac{1}{2L}\,\|\nabla f(x_k)\|^2.

Derivation hint: apply the quadratic upper bound (descent lemma) at xk+1=xk−α∇f(xk)x_{k+1}=x_k-\alpha\nabla f(x_k) and minimize the right side over α\alpha. Consequently f(xk)f(x_k) is monotonically non-increasing, and the gradients vanish: min⁡k≤K∥∇f(xk)∥2→0\min_{k \le K} \|\nabla f(x_k)\|^2 \to 0 at rate O(1/K)O(1/K). If, in addition, ff is convex, then f(xk)−f⋆=O(1/k)f(x_k) - f^\star = O(1/k); if ff is μ\mu-strongly convex, convergence is linear (geometric):

5
f(xk)−f⋆≤(1−μL)k(f(x0)−f⋆).\quad f(x_k) - f^\star \le \left(1 - \tfrac{\mu}{L}\right)^k \big(f(x_0) - f^\star\big).

Derivation hint: combine strong convexity (a lower quadratic bound) with the descent lemma to get a contraction factor 1−μ/L1-\mu/L per step.

Why It Holds / Derivation

ProofDescent Lemma → Sufficient Decrease

Step 1 — Quadratic upper bound. If ff is LL-smooth, then for any x,yx, y:

6
f(y)≤f(x)+∇f(x)⋅(y−x)+L2∥y−x∥2.\quad f(y) \le f(x) + \nabla f(x)\cdot(y-x) + \frac{L}{2}\|y - x\|^2.

Derivation hint: integrate ∇f\nabla f along the segment from xx to yy, then bound the gradient difference using the Lipschitz condition [3][3].

Step 2 — Substitute the update. Put x=xkx = x_k and y=xk+1=xk−α∇f(xk)y = x_{k+1} = x_k - \alpha\nabla f(x_k). Then y−x=−α∇f(xk)y - x = -\alpha\nabla f(x_k), and:

7
f(xk+1)≤f(xk)−α∥∇f(xk)∥2+Lα22∥∇f(xk)∥2.\quad f(x_{k+1}) \le f(x_k) - \alpha\|\nabla f(x_k)\|^2 + \frac{L\alpha^2}{2}\|\nabla f(x_k)\|^2.

Derivation hint: plug y−x=−α∇f(xk)y-x=-\alpha\nabla f(x_k) into [6][6]; the dot product ∇f(xk)⋅(−α∇f(xk))=−α∥∇f(xk)∥2\nabla f(x_k)\cdot(-\alpha\nabla f(x_k))=-\alpha\|\nabla f(x_k)\|^2.

Step 3 — Choose the step size. Collect the gradient-norm terms:

8
f(xk+1)≤f(xk)−α(1−Lα2)∥∇f(xk)∥2.\quad f(x_{k+1}) \le f(x_k) - \alpha\left(1 - \frac{L\alpha}{2}\right)\|\nabla f(x_k)\|^2.

Derivation hint: factor ∥∇f(xk)∥2\|\nabla f(x_k)\|^2 out of the last two terms of [7][7]. The coefficient α(1−Lα/2)\alpha(1 - L\alpha/2) is positive for 0<α<2/L0 < \alpha < 2/L and is maximized at α=1/L\alpha = 1/L, giving the factor 12L\tfrac{1}{2L} and recovering [4][4]. Whenever ∇f(xk)≠0\nabla f(x_k) \ne 0, the function strictly decreases. ■\blacksquare

Step 4 — Telescoping for the rate. Sum [4][4] over k=0,…,K−1k = 0,\dots,K-1:

9
∑k=0K−1∥∇f(xk)∥2≤2L(f(x0)−f⋆),\quad \sum_{k=0}^{K-1} \|\nabla f(x_k)\|^2 \le 2L\big(f(x_0) - f^\star\big),

Derivation hint: rearrange [4][4] to ∥∇f(xk)∥2≤2L(f(xk)−f(xk+1))\|\nabla f(x_k)\|^2 \le 2L(f(x_k)-f(x_{k+1})), then sum; the right side telescopes. so the smallest gradient norm satisfies min⁡k∥∇f(xk)∥2≤2L(f(x0)−f⋆)K\min_k \|\nabla f(x_k)\|^2 \le \frac{2L(f(x_0)-f^\star)}{K}, the O(1/K)O(1/K) rate.

∎
AC
Augustin-Louis Cauchy
1789–1857

The French mathematician Cauchy introduced the method of steepest descent in an 1847 note to the Académie des Sciences, "Méthode générale pour la résolution des systèmes d'équations simultanées." His motivation was astronomical: solving large systems of equations arising in orbit computations, where direct elimination was impractical. Cauchy proposed minimizing a sum of squares by repeatedly moving along the direction of greatest decrease — precisely [1][1]. He worked without the modern vocabulary of vector calculus, but the geometric idea (follow the steepest slope) was fully present. The method lay relatively dormant until the rise of numerical computing in the mid-20th century revived it as the foundation of large-scale optimization.

Building Intuition

🧠 Intuition

Imagine you are standing on a foggy mountainside and want to reach the valley bottom, but you can only see the ground directly at your feet. The sensible strategy: feel which way the slope goes down most steeply, take a step that way, and repeat. The gradient is your "feel for the slope," and the step size is your stride length. Two things can go wrong. If your stride is tiny, you'll reach the valley eventually but it takes forever. If your stride is huge, you might leap clear across the valley and end up higher on the opposite slope, then leap back even higher — oscillating and diverging. The "just right" stride depends on how curved the terrain is (encoded by LL, the smoothness constant). In a long, narrow valley (an ill-conditioned problem where the function is much steeper in one direction than another), gradient descent zig-zags inefficiently across the valley walls instead of running straight down its length. This is why conditioning — the ratio L/μL/\mu — controls convergence speed in [5][5].

Figure
Gradient descent zig-zagging down an elliptical bowl toward the minimum
minimum x* x0 Concentric ellipses = level sets of f. Steps cross perpendicular to contours, zig-zagging in the narrow valley.

Worked Examples

ExampleMinimizing a 1-D quadratic by hand

Given: f(x)=x2f(x) = x^2, so f′(x)=2xf'(x) = 2x. Use step size α=0.1\alpha = 0.1, start at x0=5x_0 = 5.

Update rule: xk+1=xk−αf′(xk)=xk−0.1(2xk)=0.8 xkx_{k+1} = x_k - \alpha f'(x_k) = x_k - 0.1(2x_k) = 0.8\,x_k.

Steps:

  • x0=5x_0 = 5
  • x1=0.8×5=4.0x_1 = 0.8 \times 5 = 4.0
  • x2=0.8×4.0=3.2x_2 = 0.8 \times 4.0 = 3.2
  • x3=0.8×3.2=2.56x_3 = 0.8 \times 3.2 = 2.56
  • x4=0.8×2.56=2.048x_4 = 0.8 \times 2.56 = 2.048
  • ⋮\vdots
  • xk=5×(0.8)kx_k = 5 \times (0.8)^k

Since ∣0.8∣<1|0.8| < 1, the sequence converges geometrically to the true minimizer.

xk→x⋆=0,f(x⋆)=0 (dimensionless)\boxed{x_k \to x^\star = 0,\quad f(x^\star) = 0 \ \text{(dimensionless)}}

Check the limit on α\alpha: here L=f′′=2L = f'' = 2, so we need α<2/L=1\alpha < 2/L = 1. With α=0.1\alpha = 0.1 we are safely inside, and the contraction factor is ∣1−αL∣=∣1−0.2∣=0.8|1 - \alpha L| = |1 - 0.2| = 0.8, matching the computation.

ExampleLinear regression via gradient descent — one step with numbers

Given: Fit y=wxy = wx to two data points (x,y)=(1,2)(x,y) = (1, 2) and (2,5)(2, 5). Mean-squared loss:

J(w)=12∑i(wxi−yi)2=12[(w⋅1−2)2+(w⋅2−5)2].J(w) = \tfrac{1}{2}\sum_{i}(wx_i - y_i)^2 = \tfrac12\big[(w\cdot1 - 2)^2 + (w\cdot2 - 5)^2\big].

Gradient:

J′(w)=(w−2)(1)+(2w−5)(2)=w−2+4w−10=5w−12.J'(w) = (w-2)(1) + (2w-5)(2) = w - 2 + 4w - 10 = 5w - 12.

Start w0=0w_0 = 0, step size α=0.1\alpha = 0.1.

Step 1: J′(0)=5(0)−12=−12J'(0) = 5(0) - 12 = -12.

w1=w0−αJ′(w0)=0−0.1(−12)=1.2.w_1 = w_0 - \alpha J'(w_0) = 0 - 0.1(-12) = 1.2.

Step 2: J′(1.2)=5(1.2)−12=−6J'(1.2) = 5(1.2) - 12 = -6.

w2=1.2−0.1(−6)=1.8.w_2 = 1.2 - 0.1(-6) = 1.8.

Step 3: J′(1.8)=5(1.8)−12=−3J'(1.8) = 5(1.8) - 12 = -3.

w3=1.8−0.1(−3)=2.1.w_3 = 1.8 - 0.1(-3) = 2.1.

Setting J′(w)=0J'(w) = 0 gives the exact least-squares solution w⋆=12/5=2.4w^\star = 12/5 = 2.4. The iterates 0,1.2,1.8,2.1,2.25,…0, 1.2, 1.8, 2.1, 2.25, \dots climb steadily toward it.

w⋆=2.4 (slope, dimensionless);w3=2.1 after 3 steps\boxed{w^\star = 2.4 \ \text{(slope, dimensionless)};\quad w_3 = 2.1 \text{ after 3 steps}}

Note: L=J′′=5L = J'' = 5, so the stable range is α<2/5=0.4\alpha < 2/5 = 0.4; our α=0.1\alpha = 0.1 converges.

Common Misconceptions

⚠️ Larger step size is NOT always faster

A bigger learning rate can speed early progress, but past the stability threshold α<2/L\alpha < 2/L the iteration diverges. In Example 1, taking α=1.5\alpha = 1.5 gives contraction factor ∣1−αL∣=∣1−3∣=2|1 - \alpha L| = |1 - 3| = 2, so ∣xk∣=5⋅2k|x_k| = 5\cdot 2^k blows up. Choosing α\alpha is a genuine trade-off, not "the bigger the better." Practical schemes use line search, adaptive rates (Adam, AdaGrad), or learning-rate decay.

⚠️ Gradient descent finds local, not global, minima

For a non-convex ff, gradient descent converges only to a stationary point (∇f=0\nabla f = 0), which may be a local minimum, a saddle point, or a plateau — not necessarily the global minimum. Convexity is what upgrades the guarantee from "local" to "global." Where the algorithm ends up depends on the starting point x0x_0.

CounterexampleA non-convex function trapping gradient descent

Consider f(x)=x4−4x2+xf(x) = x^4 - 4x^2 + x (a double-well shape). Its derivative f′(x)=4x3−8x+1f'(x) = 4x^3 - 8x + 1 has three roots; two are local minima of differing depth and one is a local maximum. Starting at x0=1.8x_0 = 1.8, gradient descent slides into the right well (the shallower local minimum near x≈1.36x \approx 1.36), never discovering the deeper left well near x≈−1.45x \approx -1.45 that is the true global minimum. No amount of tuning α\alpha escapes this — only a different initialization (or a global method) reaches the global optimum. This illustrates why initialization and restarts matter in non-convex optimization.

Connections

connection

Gradient descent is one node in a dense web of optimization ideas. It is the first-order cousin of Newton's Method, which additionally uses the Hessian Matrix to capture curvature and converges quadratically near the optimum (at the cost of inverting an n×nn\times n matrix each step). The directional-derivative justification in [2][2] rests on the Gradient and Directional Derivative from multivariable calculus. The convergence guarantees rely on Convex Functions and the notion of Lipschitz Continuity. When the full gradient is too expensive, one replaces it with a noisy estimate to obtain Stochastic Gradient Descent, the engine of deep learning. Acceleration techniques connect it to Momentum Methods and Nesterov Acceleration, which improve the convex rate from O(1/k)O(1/k) to O(1/k2)O(1/k^2). The continuous-time limit of gradient descent is the Gradient Flow ordinary differential equation x˙=−∇f(x)\dot{x} = -\nabla f(x).

Real-World Applications

🔬 Where this appears

Historical Development

⏳ History
- 1847 — Augustin-Louis Cauchy publishes the method of steepest descent for solving systems of equations arising in astronomy.
- 1907 — Jacques Hadamard independently studies the steepest-descent approach in the context of integral approximation.
- 1944 — Haskell Curry analyzes the method of steepest descent for nonlinear minimization, providing convergence conditions.
- 1951 — Herbert Robbins and Sutton Monro introduce the stochastic approximation method, the theoretical seed of stochastic gradient descent.
- 1952 — Magnus Hestenes and Eduard Stiefel publish conjugate gradients, an acceleration over plain steepest descent for quadratic problems.
- 1964 — Boris Polyak introduces the heavy-ball (momentum) method, accelerating gradient descent.
- 1983 — Yurii Nesterov publishes his accelerated gradient method, achieving the optimal O(1/k2)O(1/k^2) rate for smooth convex functions.
- 1986 — Rumelhart, Hinton, and Williams popularize backpropagation, making gradient descent practical for multilayer neural networks.
- 2011–2015 — Adaptive learning-rate methods (AdaGrad 2011, RMSProp 2012, Adam 2014/15) become the de-facto optimizers for deep learning.

Subtleties & Limits

open-problem

Several deep questions remain active research:

  • Why does SGD generalize? In over-parameterized deep networks the loss surface has infinitely many global minima of zero training error, yet SGD tends to find ones that generalize well to unseen data. The precise mechanism (implicit regularization, flat-minima preference) is not fully understood.
  • Saddle points vs. minima. High-dimensional non-convex landscapes are dominated by saddle points rather than poor local minima. How quickly (and reliably) does gradient descent — possibly with noise — escape saddles? Sharp characterizations are still being developed.
  • Optimal step-size schedules. The theoretically optimal learning-rate schedule for non-convex problems is unknown; practitioners rely on heuristics (warmup, cosine decay).
  • Lower bounds and acceleration limits. Nesterov's O(1/k2)O(1/k^2) is optimal for first-order methods on smooth convex functions, but the landscape of optimal rates under different assumptions (non-smooth, stochastic, distributed) is incompletely mapped.

See Also

Gradient · Newton's Method · Stochastic Gradient Descent · Convex Functions · Lipschitz Continuity · Momentum Methods · Nesterov Acceleration · Gradient Flow · Backpropagation · Hessian Matrix · Directional Derivative · Conjugate Gradient Method