The Gradient:
Steepest Ascent & Descent
Discover how \(\nabla f\) points in the direction of maximum increase and how \(-\nabla f\) drives optimization algorithms like gradient descent.
What Is the Gradient?
For a scalar function \(f(x, y)\), the gradient is a vector of all first partial derivatives:
For a function of \(n\) variables \(f(x_1, x_2, \ldots, x_n)\), the gradient generalizes to:
The Gradient as a Vector Field
At every point in the domain, \(\nabla f\) assigns a vector that encodes both direction and magnitude of the steepest rate of change.
Why Does \(\nabla f\) Matter?
The Steepest Ascent Theorem
Proof sketch: By definition, \(D_{\mathbf{u}} f = \nabla f \cdot \mathbf{u} = \|\nabla f\|\;\|\mathbf{u}\|\cos\theta = \|\nabla f\|\cos\theta\). This is maximized when \(\theta = 0\), i.e., \(\mathbf{u}\) is parallel to \(\nabla f\).
Visualizing Directional Derivatives
Gradient vs. Directional Derivative
| Gradient \(\nabla f\) | Directional Derivative \(D_{\mathbf{u}}f\) | |
|---|---|---|
| Type | Vector | Scalar |
| What it gives | Direction & rate of steepest increase | Rate of change in direction \(\mathbf{u}\) |
| Formula | \(\langle f_x, f_y \rangle\) | \(\nabla f \cdot \mathbf{u}\) |
| Depends on direction? | No: intrinsic to \(f\) | Yes: depends on \(\mathbf{u}\) |
| Relationship | \(D_{\mathbf{u}} f = \nabla f \cdot \mathbf{u}\); maximum when \(\mathbf{u} \parallel \nabla f\) | |
Steepest Descent Algorithm
To minimize \(f\), we iteratively step in the direction of \(-\nabla f\):
Here, \(\alpha\) is the learning rate (step size). Too large: overshoot. Too small: slow convergence.
How to Find the Steepest Direction
Example 1: Simple Polynomial
Let \(f(x, y) = x^2 + 3y^2\). Find the gradient at \((1, 2)\) and the steepest ascent direction.
Example 2: Transcendental Function
Let \(f(x,y) = e^{-x}\sin y\). Find the direction of steepest descent at \((0, \pi/2)\).
Example 3: Three Variables
Let \(f(x,y,z) = x^2 y + yz^3\). Find the steepest ascent direction and the maximum rate of change at \((1, -1, 2)\).
When Is \(D_{\mathbf{u}} f\) Zero?
Recall \(D_{\mathbf{u}} f = \|\nabla f\| \cos\theta\). The directional derivative is zero when \(\theta = \pi/2\), meaning \(\mathbf{u}\) is perpendicular to \(\nabla f\).
Common Mistakes
Summary at a Glance
| Quantity | Formula | Meaning |
|---|---|---|
| Gradient | \(\nabla f = \langle f_x, f_y \rangle\) | Vector: direction of steepest ascent |
| Steepest ascent direction | \(\dfrac{\nabla f}{\|\nabla f\|}\) | Unit vector: fastest increase |
| Steepest descent direction | \(-\dfrac{\nabla f}{\|\nabla f\|}\) | Unit vector: fastest decrease |
| Max rate of change | \(\|\nabla f\|\) | Scalar: how fast \(f\) grows |
| Directional derivative | \(D_{\mathbf{u}} f = \nabla f \cdot \mathbf{u}\) | Rate of change in direction \(\mathbf{u}\) |
| Zero change | \(\mathbf{u} \perp \nabla f\) | Along level curves |
Question 1 of 5
If \(f(x,y) = x^2 + y^2\), what is \(\nabla f\) at the point \((3, 4)\)?
Question 2 of 5
The gradient \(\nabla f\) at a point is perpendicular to which of the following?
Question 3 of 5
For \(f(x,y) = 3x^2 - y^2\), what is the maximum rate of change at \((1, 2)\)?
Question 4 of 5
In the gradient descent update rule \(\mathbf{x}_{n+1} = \mathbf{x}_n - \alpha\,\nabla f(\mathbf{x}_n)\), what does the negative sign ensure?
Question 5 of 5
If \(\nabla f(2,1) = \langle 3, -4 \rangle\) and \(\mathbf{u} = \langle 0, 1 \rangle\), what is the directional derivative \(D_{\mathbf{u}} f(2,1)\)?