Enrichment · STEM Explorations · Gradient descent on a bowl you set

Too small is slow.
Too big blows up.

Gradient descent walks downhill by repeating one step: move against the slope by a fraction of its size. On the bowl f(x) = a(x − m)² + c, each step shrinks the distance to the bottom by a fixed factor 1 − 2a × step. Give the bowl, the start, the step size and the number of steps. The page shows where you land, the factor, the step size that finds the bottom fastest and how many steps get within a tolerance.

The nonlinear optimization sandbox

The worked example is f(x) = 2(x − 3)² + 1 starting at 10 with step size 0.2, five steps, tolerance 0.001. Nothing you type leaves this browser.

Loading the calculator. If nothing appears, turn on JavaScript.

What you get

Enrichment · STEM ExplorationsOpen to everyone · no sign-in

What you finish with
Where gradient descent lands after a number of steps on a bowl you set, whether it converges, the best step size, the steps needed for a tolerance and a table by step size.
Who it is for
Students in calculus, machine learning and operations research, and the teachers and hobbyists who want to see why the step size matters.
Format
Browser calculator for a phone, tablet or computer, by touch or keyboard. Prints a summary; downloads a spreadsheet (.csv); export and import a file.
Access
Open to everyone with the link: no account, no sign-in, nothing to buy and nothing to install. Everything you type stays in this browser; nothing is sent to Caveat.
Where it lives
The STEM Explorations space in Caveat Enrichment.
Support
Questions, a correction or a request: team@caveatacademic.com.

How to use it

  1. Name the run.
  2. Type the steepness a, the bottom m and its height c.
  3. Type the starting point, the step size and the number of steps.
  4. Type a tolerance.
  5. Read where you land and the steps you need, and scan the table of other step sizes.

Take the steps

How the figures are worked out

One factor rules every step.

The worked example: five steps of 0.2 on 2(x − 3)² + 1Start107 from the bottomFactor0.201 − 2 × 2 × 0.2After 53.002243 + 7 × 0.2^5Within 0.0016stepsThe worked example: five steps of 0.2 on 2(x − 3)² + 1Start107 from the bottomFactor0.201 − 2 × 2 × 0.2After 53.002243 + 7 × 0.2^5Within 0.0016steps
Each step multiplies the distance to the bottom by 0.2, so after five steps 7 has become 0.00224.

Why a fixed factor

On a perfect bowl the slope is proportional to the distance from the bottom, so every step removes the same fraction of that distance. That fraction is 1 minus twice the steepness times the step size. When it lies between −1 and 1 the walk converges, and when it is 0 the walk lands at once.

What it teaches

The same trade-off shows up in training machine learning models, where a learning rate that is too small is slow and one that is too large makes the loss grow. Real functions are not bowls, so this sandbox is the starting picture, not the whole story.

Sources

  1. Boyd, S., & Vandenberghe, L. (2004). Convex Optimization. Cambridge University Press, section 9.3: gradient descent method. web.stanford.edu/~boyd/cvxbook.
  2. Nocedal, J., & Wright, S. J. (2006). Numerical Optimization (2nd ed.). Springer, chapter 3: line search methods.
  3. Goodfellow, I., Bengio, Y., & Courville, A. (2016). Deep Learning. MIT Press, chapter 4.3: gradient-based optimization. deeplearningbook.org.
  4. Stewart, J. Calculus (8th ed.). Cengage, section 4.7: optimization problems and minimum values.

Figures worked from your own numbers. Nothing you type is sent to Caveat. The worked example is made up. Your entries stay in this browser. Support: team@caveatacademic.com.

Written with AI, then checked before it is published. How we checkFound a mistake? Report it and we fix it, or refund you.Cancel anytime.