Optimization · CMNA Laboratory

Follow the slope downhill.

Define an objective, its gradient, and a starting point in real R. Then watch the descent path move across the surface your function creates.

The update is simple. The landscape is not.

Gradient descent repeats x_next = x - h * grad f(x). The laboratory keeps that rule visible while letting the objective be arbitrary R. Step size is where things get interesting: too small crawls; too large can overshoot or explode.

Bring your own landscape

Write f(x), ∇f(x), and x₀ in R.

Then play every descent step across a surface sampled by the same R objective.

RuntimePreparing R…
RDefine f, fp, and x0

nx₁x₂f(x)||∇f||
Book§6.2.2 and §6.3.1 · Gradient Descent · pp. 178–184Book details
CMNA packagegdgdlsgraddsc
TeachingInstructor notes and chapter contextOpen teaching material
Numerical ZooWorked problems