The Gradient: The Compass of Steepest Ascent
Collect a function's partial derivatives into a single vector, and it points straight uphill — toward the fastest increase — everywhere at once.
Which way is uphill?
Stand on a hillside described by a height function f(x, y). You can measure the slope if you walk due east (that is ∂f/∂x) or due north (∂f/∂y). But those are just two of infinitely many directions. Which way is the steepest, and how steep is it?
The gradient answers both at once. It packages the two partial derivatives into a single vector that acts like a compass needle for “uphill.”
The directional derivative
To find the slope in any direction — described by a unit vector û — take the dot product of the gradient with that direction. This is the directional derivative: it projects the gradient onto the way you want to walk.
Because a dot product is largest when the two vectors are parallel, the slope is greatest exactly when you walk in the direction of ∇f itself — confirming that the gradient points the steepest way up. Walk perpendicular to it and the slope is zero: you are contouring around the hill at constant height.
- Partial with respect to x: \( \partial f/\partial x = 2x \). Partial with respect to y: \( \partial f/\partial y = 2y \).
- So \( \nabla f=(2x,\,2y) \).
- Evaluate at (1, 2): \( (2\cdot 1,\ 2\cdot 2)=(2,4) \).
- Gradient: \( \nabla f=(2xy,\ x^{2}) \); at (1, 1) this is \( (2,1) \).
- Make the direction a unit vector: \( \lVert(3,4)\rVert=5 \), so \( \hat u=(3/5,\,4/5) \).
- Directional derivative: \( \nabla f\cdot \hat u=2\cdot\tfrac{3}{5}+1\cdot\tfrac{4}{5}=\tfrac{6+4}{5}=\tfrac{10}{5} \).
Check your understanding
- The gradient ∇f = (∂f/∂x, ∂f/∂y) is a vector built from the partial derivatives.
- It points in the direction of steepest ascent, and its magnitude ‖∇f‖ is the steepest slope.
- The directional derivative in a unit direction û is the dot product ∇f · û.
- ∇f is always perpendicular to the level curves of f, so the steepest path cuts across the contours.
- Always normalise the direction to a unit vector before taking the dot product, or the slope is wrong.