Gradient Descent

An iterative optimisation algorithm that repeatedly moves in the direction of the negative gradient to find a local minimum of a loss function.

Gradient descent — following the negative gradient downhill
x=2.000, f=5.000steps: 0-2-1012
α=0.050
Definition

Gradient descent is an algorithm for finding the minimum of a function by repeatedly stepping in the direction of steepest decrease.

Starting at a point x0x_0, the update rule is:

xt+1=xt−α∇f(xt)x_{t+1} = x_t - \alpha \nabla f(x_t)

where α>0\alpha > 0 is the learning rate (step size). We subtract the gradient because the gradient points uphill — we want to go downhill.

The algorithm terminates when ∄∇f∄\|\nabla f\| is near zero (a stationary point), or after a fixed number of steps.

Key properties
  • Each step moves in the direction that locally decreases ff the fastest, but only locally — it has no view of the global landscape
  • A fixed point of the update (∇f(x)=0\nabla f(x) = 0) is a critical point, not necessarily a minimum
  • Convergence speed and stability both depend heavily on the learning rate α\alpha
  • For convex functions, gradient descent (with a suitable step size) is guaranteed to converge to the global minimum
Common mistakes
  • Setting the learning rate too high: the algorithm can overshoot and diverge instead of converging
  • Assuming convergence means reaching a global minimum: on non-convex functions, gradient descent only guarantees reaching a stationary point — which could be a local minimum or, in high dimensions, a saddle point
Minimizing a parabola

f(x)=x2f(x) = x^2, so fâ€Č(x)=2xf'(x) = 2x. Starting at x0=3x_0 = 3, α=0.1\alpha = 0.1:

x1=3−0.1×6=2.4x_1 = 3 - 0.1 \times 6 = 2.4

x2=2.4−0.1×4.8=1.92x_2 = 2.4 - 0.1 \times 4.8 = 1.92

Each step is 80% of the previous value — the algorithm converges geometrically to 0.

Try it

For f(x)=(x−5)2f(x) = (x-5)^2, find the update rule and verify that the minimum is reached in one step if α=0.5\alpha = 0.5.

Solution

fâ€Č(x)=2(x−5)f'(x) = 2(x-5). Starting at x0x_0:

x1=x0−0.5×2(x0−5)=x0−(x0−5)=5x_1 = x_0 - 0.5 \times 2(x_0 - 5) = x_0 - (x_0 - 5) = 5.

With α=0.5\alpha = 0.5 on a perfect quadratic, gradient descent reaches the exact minimum in one step. This is a special property of quadratics; it doesn't hold for other functions.

Related concepts