Every optimiser in machine learning is a variation on one loop: look at the slope, step downhill, repeat. On a 1D parabola you can watch the whole thing happen.
For f(x) = a·x² + b·x + c, the slope is f'(x) = 2a·x + b. Gradient descent repeats:
1x = x - learning_rate * f'(x)
Task: write gradient_descent(a, b, start, learning_rate, steps) that runs exactly steps updates from start and returns the final x, rounded to 4 decimal places.
c never appears — shifting a function up or down doesn't change where its minimum sits.steps = 0 returns start unchanged.Try picturing what happens if
learning_rategets too big. Each step overshoots the bottom by more than it started from, andxspirals outward instead of settling — the same divergence you'd see in a real training run, just visible in one variable.
The slope tells you which way is uphill, so you subtract it to head downhill. Near the edge the ground is steep and the steps are long. As the ground flattens the slope shrinks, so the steps shrink with it, and the walk eases into the bottom instead of shooting past it.
Once your code passes every test, a reference solution shows up here so you can compare it with yours.