Multivariable Calculus · Lesson 3 of 3 · ~6 min

The gradient

Predict

A level curve keeps height constant. Which way does the gradient $\nabla f = (f_x, f_y)$ point?

Press Walk uphill and watch how the path crosses the circles.
Try
Try itPress Walk uphill and watch the path. Then press saddle x²−y², set start angle to $90$, and walk again.
Notice

On the bowl the walker runs straight out, crossing each circle at a right angle. Field arrows grow where circles crowd. On the saddle the walker stalls at the center: $\nabla f = (0, 0)$.

Explain

The gradient packs both partials into one vector, $\nabla f = (f_x, f_y)$. It points the steepest way uphill, and its length $|\nabla f| = \sqrt{f_x^2 + f_y^2}$ is that slope: $\sqrt{4 + 4} = 2.83$ on the bowl at $(1, 1)$.

Why a right angle? Along a level curve the height does not change, so any along-curve part of a step gains nothing. The fastest climb keeps none of it and points straight across.

The bowl's $\nabla f = (2x, 2y)$ points straight out, so the walk is a straight line. On the $y$-axis, the saddle's $\nabla f = (2x, -2y)$ becomes $(0, -2y)$ and points at the center, where it vanishes.

About this model

What it represents: gradient ascent — the walker takes many small steps proportional to $\nabla f$, an Euler approximation of the steepest-ascent flow $\dot{p} = \nabla f(p)$, the mirror image of the gradient descent that trains machine-learning models.

What it leaves out: everything that makes real gradient methods hard — choosing a step size, overshooting and zigzagging in narrow valleys, and dimension: practical descent runs on functions of millions of variables, not two. The clean stall at the saddle is also fragile: only walkers starting exactly on the $y$-axis reach it, and any sideways nudge escapes.

Source: S. Boyd and L. Vandenberghe, Convex Optimization, Ch. 9 (Cambridge University Press, free online) — the full treatment of gradient methods, step-size rules included.

Apply
Checkpoint — prove it to yourself

Why does the gradient arrow always cross the level curve through its base at a right angle?

On the bowl, what is $|\nabla f|$ at the point $(0.5,\ 0)$?

Transfer: a hiker on a real contour map wants the fastest way down. Relative to the level curves, which way is that?

Key idea

The gradient $(f_x, f_y)$ points straight across the level curves, uphill. Its length is the steepest slope. It vanishes at flat points, saddles included.

← All lessons