← Module 05 / Calculus & optimization

Lesson 05.2 · §4.2

Which direction changes the value fastest?

Read the gradient as a column of partial derivatives and a local direction of steepest change.

In this lesson 6 ideas
  1. Compare equal-length steps
  2. Why the gradient points uphill
  3. Turn local information into steps
  4. Transfer
  5. Explore the relationship
  6. Check your reasoning

Source scope: §4.2, PDF pages 27. Numerical examples, experiments, added derivations, and practice are teaching supplements unless identified as source results.

Compare equal-length steps

For f(x,y)=x2+2y2f(x,y)=x^2+2y^2 at (1,1)(1,1), a small horizontal step changes the value at about 22 units per unit distance; a vertical step changes it at about 44. But the fastest direction combines both coordinates.

The gradient of f:Rd→Rf:\mathbb R^d\to\mathbb R is the d×1d\times1 column vector

∇f(x)=[∂f/∂x1⋮∂f/∂xd],[∇f(x)]i=∂f∂xi(x).\nabla f(x)=\begin{bmatrix}\partial f/\partial x_1\\\vdots\\\partial f/\partial x_d\end{bmatrix},\qquad [\nabla f(x)]_i=\frac{\partial f}{\partial x_i}(x).

The PDF uses nn in the displayed column after introducing dimension dd; we use dd consistently. In the running example ∇f=(2x,4y)T\nabla f=(2x,4y)^T, so ∇f(1,1)=(2,4)T\nabla f(1,1)=(2,4)^T.

Why the gradient points uphill

The source states that the gradient points in the direction of steepest ascent and its negative points in the direction of steepest descent. This means local first-order change measured among unit directions in Euclidean distance, assuming differentiability.

Teaching derivation. For a unit vector vv, the directional derivative is ∇f(x)Tv\nabla f(x)^Tv. Cauchy–Schwarz bounds it above by ∥∇f(x)∥2\|\nabla f(x)\|_2, attained when v=∇f/∥∇f∥2v=\nabla f/\|\nabla f\|_2 if the gradient is nonzero. The minimum is its negative, attained in the opposite direction. At (1,1)(1,1) the steepest unit direction is (1,2)T/5(1,2)^T/\sqrt5, with derivative 252\sqrt5. At a stationary point the gradient is zero and all first-order directional derivatives vanish; there is no distinguished steepest first-order direction.

Turn local information into steps

Gradient descent repeatedly takes

xt+1=xt−α∇f(xt),α>0.x_{t+1}=x_t-\alpha\nabla f(x_t),\qquad \alpha>0.

This update is a teaching supplement connecting the source’s gradient direction to iterative minimization. Small enough steps lower a differentiable function when the gradient is nonzero. A large step can increase it. For the example, the update is (x,y)↦((1−2α)x,(1−4α)y)(x,y)\mapsto((1-2\alpha)x,(1-4\alpha)y), which lets us check that claim without guessing from an animation. The experiment provides explicit steps and reset; its contours represent equal objective values, not height in the input plane.

Transfer

For g(x,y)=3x−yg(x,y)=3x-y, the gradient is (3,−1)T(3,-1)^T everywhere. The direction (1,0)(1,0) increases gg at rate 33; the normalized gradient increases it at rate 10\sqrt{10}. There is no unconstrained minimum because moving in the negative gradient direction keeps lowering the value.

Explore the relationship

Explore it yourself

Follow a slope, then take a step

Compare equal-length directions. Then predict whether a chosen descent step will overshoot.

Preparing interactive controls…

current pointtangent descent stepDrag v in the xy plane at its current z; coordinate sliders provide the same control.xyf / 40

Wireframes sample −1.5 ≤ x,y ≤ 1.5; the vertical axis is f / 4. Rotating the camera changes only the view. Drag the ground-plane handle to change the current input, or use the point sliders below.

xy0-3-2-11234Contours: 0.5, 1, 2, 4, 8 (inner → outer)

∇f = (2, 4); unit v = (0.7071, 0.7071); directional derivative = 4.2426; maximum = 4.4721.

f now = 3; next point = (0.7, 0.4); f next = 0.81. This step does not increase the objective.

The red segment shows the selected unit direction from the point; dashed segments record descent steps. Inputs may move beyond the plot after large steps; the readout remains exact to displayed precision. Steps beyond radius 20 are disabled to keep repeated divergent updates finite.

Check your reasoning

Make a prediction

Does a step opposite the gradient always lower the objective?