Gradient Descent Playground
f(x) = ½ xTAx − bTx, gradient ∇f(x) = Ax − b, update xk+1 = xk − α∇f(xk).
Each challenge checks itself. Work on this keeps it in view above the controls.
Minimize a quadratic bowl f(x) = 1/2 x^T A x - b^T x from a starting point; change the learning rate and watch convergence, zig-zag, or divergence; stopping criteria shown live.
How to use
- The picture is a map of the bowl f: each closed curve (a contour) joins points with the same value of f. The minimum x* = A−1b is marked with a cross.
- Choose a learning rate α and press Step for one update or Run to repeat until a stopping criterion is met. The path is drawn with numbered dots; the table lists every iterate.
- For this bowl, gradient descent converges exactly when 0 < α < 2/λmax, where λmax is the largest eigenvalue of A. The Theory panel shows these numbers live. If a run diverges, the app explains why.
- Change A, b or the start point to make new bowls (A must be symmetric positive definite for a bowl with a minimum).
- Runs are animated unless your system asks for reduced motion; then the whole path appears at once. Pause stops an animated run.
- Keyboard: every control is a standard form field; the status box is read aloud by screen readers.
Accessibility: every control is a standard form control you can reach with Tab and change with the arrow keys; the status box is announced by screen readers; the picture has a text description (press Describe) that updates as you work; animations are skipped when your system asks for reduced motion.
Picture
Theory for this A and α
Iterates
| k | xₖ | f(xₖ) | ‖∇f(xₖ)‖ | step size |
|---|