Gradient Descent Lab

Explore how gradient descent finds the minimum of a function. Click on the curve to set a starting point, adjust the learning rate, and watch the optimizer descend.

Loss Surface
Learning Rate (α) 0.1
Function
Optimization Metrics
Current x
Current Loss
Gradient
Steps
0
f(x) = x²
How gradient descent works: At each step, compute the derivative (slope) of the loss function at the current point, then move in the opposite direction of the gradient: x ← x − α · f′(x). The learning rate α controls step size. Click on the surface to set a new starting position.
What's happening here? Imagine you're blindfolded on a mountain and need to find the lowest valley. You feel the ground with your foot — that's the gradient (the slope). If the ground slopes down to the right, you take a step to the right. If it slopes up, you step back. The learning rate is how big your steps are: too small and you'll never get there, too big and you might stumble past the valley and miss it entirely. The red arrow shows which way is "downhill" at each point. The green dots trace your path. Try different functions (some have multiple valleys — those are "local minima" traps) and see how the starting point changes where you end up. Click anywhere on the curve to drop the blindfolded hiker at a new spot.