Loading
Gradient descent walks downhill: . It is how machine-learning models are trained. Watch each step and see what the learning rate α does.
Minimise from with step size .
The height fell from 7 to 3.04: we moved downhill.
Each step multiplies x by and y by , so y settles much faster than x.
| k | (x, y) | ∇f | f |
|---|---|---|---|
| 0 | (2, 1) | (4, 6) | 7 |
| 1 | (1.6, 0.4) | (3.2, 2.4) | 3.04 |
| 2 | (1.28, 0.16) | (2.56, 0.96) | 1.7152 |
| 3 | (1.024, 0.064) | (2.048, 0.384) | 1.060864 |
| 4 | (0.8192, 0.0256) | (1.6384, 0.1536) | 0.673055 |
| 5 | (0.65536, 0.01024) | (1.31072, 0.06144) | 0.429811 |
| … | |||
| 20 | (0.023058, 0.00000001) | (0.046117, 0) | 0.000532 |
The true minimum is at (0, 0), where ∇f = 0. The calculator below opens on this example.
Adding the gradient instead of subtracting it.
Choosing α too large.
Wrong partial derivatives.
Using the new x when working out the gradient for y.
Stopping when f is small.
Writing only the final answer.
Each step moves against the gradient: x ← x − α∇f.
Add this calculator to a new note, next to your own working. It stays live: change the numbers there any time.