CG (indigo) reaches exact minimum in 2 steps for 2D. GD (amber) zigzags - worse with high κ. CG uses conjugate search directions: each step is A-orthogonal to all previous.
Try κ=50: GD spirals forever. CG still takes exactly 2 steps. This is why CG is used to solve large sparse linear systems in ML (e.g. second-order optimizers).
Conjugate Gradient - Interactive Visualization
Conjugate gradient solves Ax=b (or equivalently minimizes a quadratic) in at most n steps for an n-dimensional problem. The key insight: CG search directions are conjugate (A-orthogonal) - each step corrects only what previous steps left uncorrected, without undoing prior progress. This is why CG needs only 2 steps for 2D, while steepest descent zigzags indefinitely.
Watch CG reach minimum in exactly 2 steps on a 2D quadratic
Watch steepest descent zigzag along the same problem
Adjust condition number κ to see how CG convergence degrades
See both paths animated simultaneously on elliptical contours
Foundation for solving large sparse linear systems in scientific computing and ML
Part of the EngineersOfAI Interactive 3D - free interactive visualizations covering every major concept in machine learning and AI engineering. Hover any element for a plain-English explanation. No code required.