NLA Visualizations

Conjugate Gradient

vs Gradient Descent on SPD matrix

Solving Ax=bAx = b where AA is SPD is equivalent to minimizing the quadratic form:

f(x)=12xTAxbTxf(x) = \frac{1}{2}x^T A x - b^T x
Iteration 0

Use Left/Right arrow keys to navigate steps

Gradient Descent (Blue)

Moves strictly in the direction of the local negative gradient. Because the "bowl" is skewed (ill-conditioned AA), the path zig-zags back and forth, taking many steps to reach the bottom.

Conjugate Gradient (Red)

Chooses search directions that are AA-orthogonal (conjugate) to all previous directions. For an n×nn \times n matrix, it perfectly reaches the minimum in exactly nn steps. Here (n=2n=2), it reaches the center in exactly 2 steps!

Gradient Descent (Zig-Zag)
Conjugate Gradient (A-orthogonal)