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:
x = 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.