Why gradient descent zigzags
A whiteboard-sized note on conditioning, with a toy you can poke at.
Gradient descent on a quadratic is the “hello world” of optimization, and it already contains the most important idea in the subject:
The setup
Take a quadratic with symmetric positive definite, and call its smallest and largest eigenvalues and . The gradient is , so a step of gradient descent with step size is
Now write in the eigenbasis of .This is the whole trick. In the eigenbasis the problem splits into independent one-dimensional problems, one per eigenvalue, and each one is trivial. Each coordinate evolves on its own, shrinking by a fixed factor at every step:
So we converge only if for every eigenvalue, which means .Push past in the toy below and watch the red path leave the board. The slowest coordinate sets the pace, and the best we can do is to balance the two extremes with , giving the rate
The condition number
Play with it
The toy below runs both methods on a quadratic with . Click anywhere on the board to restart from that point.
Momentum
Polyak’s heavy-ball method adds a fraction of the previous step:think: a ball rolling in the bowl, not a hiker taking careful steps
With and tuned to the curvature, the rate improves from to .Polyak’s tuning: and , where is that new rate. That square root is not a small detail. With :
| method | rate per step | steps to shrink the error |
|---|---|---|
| gradient descent | ||
| heavy ball |
A tenfold speed-up for one extra vector of memory. The whole thing is a few lines:
import numpy as np
def heavy_ball(A, x0, lr, beta, steps):
x, prev = x0, x0
for _ in range(steps):
x, prev = x - lr * (A @ x) + beta * (x - prev), x
return x
The takeaway
Much of what makes modern optimizers work, including momentum, preconditioning and Adam’s per-coordinate step sizes, can be read as an attempt to
Cite this post
@misc{prakash2026gradient,
author = {Arya Prakash},
title = {Why gradient descent zigzags},
year = {2026},
month = {oct},
url = {https://jirachi.ai/posts/why-gradient-descent-zigzags/},
}