Gradient Descent
Explore gradient descent optimisation interactively on a real quadratic loss landscape — adjust the starting point, learning rate and step count and watch the descent path converge or diverge live.
How it works
Gradient descent finds the lowest point of a loss curve by repeatedly stepping downhill. The step size is the slope multiplied by the learning rate: too small and progress is slow, too large and every step overshoots.
What you will learn
After using this simulation you should be able to:
- Explain how gradient descent uses the slope of a curve to step towards its lowest point.
- Predict whether a learning rate will make the steps settle, bounce or run away on the curve L(x) = x².
- Relate the learning rate to how fast, and how safely, a machine-learning model learns.
Equations
- L(x) = x²
- The loss being minimised; its lowest point is at x = 0.
- L′(x) = 2x
- The gradient (slope) of the loss.
- xₙ₊₁ = xₙ − η·L′(xₙ) = xₙ·(1 − 2η)
- One gradient descent step with learning rate η.
- 0 < η < 1
- Learning rates for which this run converges (the step shrinks every time).
What the model assumes
- The loss is the simple bowl L(x) = x² with a single minimum, so the exact behaviour can be worked out by hand.
- There is one parameter, x, and the true gradient is used at every step (no noise, no mini-batches).
- The learning rate stays the same for the whole run.
Where it stops being right
- Real machine-learning losses have millions of parameters, many valleys and flat regions; the safe learning rate there cannot be calculated this easily.
- Optimisers used in practice, such as momentum and Adam, change the step rule; this is plain gradient descent.
- A diverging run is stopped once the loss is too large for the computer to represent, and the step where that happened is reported.
Sources
This interactive simulation is part of ScienceVerse Plus.
Everything you need to understand the idea is on this page. Plus and Family plans add the hands-on explorer, along with higher tutor limits, full guided learning paths and progress exports.
Sign in or create a free account to subscribe · Compare plans
Using this simulation
How to use it
- Start with a preset to see a real example, then change one control at a time and watch which results change.
- Drag a slider to explore, or type an exact number in the box next to it.
- The results under the picture update straight away. Open “Show the data as a table” to see them laid out side by side.
- When you find something interesting, use “Copy shareable link” to send exactly those settings to someone else.
Things to try
- Set the learning rate to 0.5. One step lands exactly on the lowest point, x = 0.
- Try 0.1 and then 0.8. Both settle at the lowest point, but with 0.8 every step jumps past it to the other side.
- Set the learning rate to 1.0. The steps bounce between the starting point and its opposite for ever.
- Go above 1.0. Every step overshoots further than the last, so the loss grows instead of shrinking: the run diverges.
The controls
- Starting point x₀
- Where on the curve the descent starts.
- Learning rate η
- How big each step is compared with the slope (η is the Greek letter eta).
- Number of steps
- How many steps to take.
- Pause animation
- Stops and restarts the replay of the steps.
- Preset
- Loads a ready-made, real-world example. The sentence under it says what the example shows.
- Reset to default
- Puts every control back to the first preset.
- Exact value boxes
- Each slider has a box for typing a precise number. A value outside the allowed range is refused with a message, never quietly changed.
- Show the data as a table
- Opens the same results as a table.
- Copy shareable link
- Copies a link that opens the simulation with exactly these settings. The link holds only the settings, nothing about you.
The readings
- Final x
- Where the last step ended.
- Final loss
- The value of L(x) = x² there; 0 is the lowest possible.
- Behaviour
- Whether the run settles (converges), bounces for ever or runs away (diverges).
- Stopped early
- Shown when the loss grew too large for the computer to store, and at which step.
Accessibility
- The chart is a picture of the curve and the path; the final values and the behaviour are given as text, and the table lists the steps.
- Every slider works with the keyboard: arrow keys for small steps, Page Up and Page Down for big ones, Home and End for the limits.
- Every result is written out as text and announced by screen readers as it changes, and the data table holds the same numbers.
- If your device asks for reduced motion, a still diagram is shown instead of the animation; otherwise the animation can be paused at any time.