Calculus › Section N · Functions of several variables › Topic N.6
Directional derivatives and the gradient
Partial derivatives only cover east and north. The gradient packages them into a single vector that answers every direction question at once: which way is steepest, how steep, and where does nothing change.
Slopes in every direction
Partial derivatives answer two questions only: how fast \(f\) changes heading due east (the \(x\)-direction) and due north (the \(y\)-direction). A hiker, a drone or a heat-seeking insect can move in any of infinitely many directions, and each direction deserves its own slope. Fix a direction as a unit vector \(\mathbf{u} = \langle\cos\theta, \sin\theta\rangle\), where \(\theta\) is the angle from the positive x-axis; the unit length is what makes the answer a per-unit-distance rate rather than a rate scaled by how fast you travel. The directional derivative \(D_{\mathbf{u}}f\) measures how fast \(f\) changes at a point when moving in the direction \(\mathbf{u}\) — and it turns out to be built entirely from the two partial derivatives.
The gradient vector
The gradient packages the partial derivatives into a single vector:
read 'del \(f\)' or 'grad \(f\)'. In three variables, \(\nabla f = \langle f_x, f_y, f_z\rangle\). As an example, \(f(x, y) = x^2y^3\) has \(f_x = 2xy^3\) and \(f_y = 3x^2y^2\), so \(\nabla f = \langle 2xy^3, 3x^2y^2\rangle\); at the point \((-1, 2)\) this becomes \(\langle -16, 12\rangle\). The gradient is a vector field: every point of the domain owns its own gradient, exactly as every point owns its own partial derivatives.
The directional derivative
The rate of change of \(f\) in the direction \(\mathbf{u} = \langle\cos\theta, \sin\theta\rangle\) is
the dot product doing quiet, useful work. The formal definition as a limit matches the ordinary derivative: \(D_{\mathbf{u}}f(x_0, y_0) = \lim_{t \to 0} \frac{f(x_0 + t\cos\theta, y_0 + t\sin\theta) - f(x_0, y_0)}{t}\). Three rules of use: \(\mathbf{u}\) must be a unit vector, so divide any non-unit direction by its length first; the gradient is evaluated at the same point as the rate; and the sign carries meaning — positive means \(f\) increases along \(\mathbf{u}\), negative means it falls.
Worked example: one point, two rates
For \(f(x, y) = x^2y^3\), find the steepest possible rate of change at \((-1, 2)\), and the rate of change in the direction of the vector \(\langle 5, 12\rangle\). The gradient there is \(\nabla f = \langle -16, 12\rangle\), so the steepest rate is \(|\nabla f| = \sqrt{256 + 144} = 20\), uphill in the direction \(\langle -16, 12\rangle\). For the second question, \(\langle 5, 12\rangle\) has length 13, so \(\mathbf{u} = \langle\tfrac{5}{13}, \tfrac{12}{13}\rangle\) and \(D_{\mathbf{u}}f = \tfrac{-80 + 144}{13} = \tfrac{64}{13} \approx 4.9\). Check by angle: the cosine of the angle between \(\langle 5, 12\rangle\) and \(\nabla f\) is \(\tfrac{64}{13 \cdot 20} = \tfrac{16}{65}\), and \(D_{\mathbf{u}}f = |\nabla f|\cos\theta = 20 \cdot \tfrac{16}{65} = \tfrac{64}{13}\). Both routes agree.
Steepest ascent and descent
Because \(D_{\mathbf{u}}f = \nabla f \cdot \mathbf{u} = |\nabla f|\cos\theta\), the rate depends only on the angle \(\theta\) between \(\mathbf{u}\) and the gradient. When \(\theta = 0\) the rate peaks at \(|\nabla f|\): the gradient points in the direction of steepest increase, and its magnitude is that steepest rate. When \(\theta = \pi\) the rate bottoms out at \(-|\nabla f|\): the negative gradient \(-\nabla f\) is the direction of steepest decrease. Machine learning's gradient descent exploits this — it repeatedly steps along \(-\nabla f\), scaled by a chosen step size and assuming each step is small enough that the local downhill direction stays a useful guide, to slide a loss function toward its minimum.
Worked example: a temperature plate
A flat metal plate holds steady temperature \(T(x, y) = 50 + x^2 + 2y^2\) degrees, coolest at the origin — a simplified model, but serviceable. At the point \((2, 1)\), \(\nabla T = \langle 2x, 4y\rangle = \langle 4, 4\rangle\). Temperature climbs fastest in the direction \(\langle 4, 4\rangle\), at \(|\nabla T| = 4\sqrt{2} \approx 5.7\) degrees per metre; it drops fastest heading \(\langle -4, -4\rangle\), back toward the cool spot. And walking in the direction \(\langle 4, -4\rangle\), which satisfies \(\langle 4, -4\rangle \cdot \langle 4, 4\rangle = 0\), keeps the temperature constant — that path runs along the level curve \(x^2 + 2y^2 = 6\) through the point. One gradient, three answers: uphill, downhill, and around the hill.
The gradient is perpendicular to level curves
Along a level curve \(f(x, y) = c\), the value of \(f\) never changes, so the directional derivative in the curve's own direction is \(0\). But \(D_{\mathbf{u}}f = \nabla f \cdot \mathbf{u} = 0\) says exactly that \(\mathbf{u}\) is perpendicular to \(\nabla f\). Conclusion: the gradient is perpendicular to every level curve through its point. On a contour map this is the classic picture — the steepest uphill path crosses contour lines at right angles, never sliding along them. In three variables the same argument shows \(\nabla F\) is normal to the level surface \(F = k\), which is where the tangent-planes topic gets its normal vectors.
Common mistakes to avoid
First, feeding a non-unit vector into \(\nabla f \cdot \mathbf{u}\): a direction of length 13 scales the true rate by 13 — always normalise. Second, confusing the gradient (a vector) with the maximum rate (its magnitude, a number): the direction of steepest climb is \(\nabla f\), the rate is \(|\nabla f|\). Third, forgetting to evaluate at the point of interest: \(\nabla f = \langle 2xy^3, 3x^2y^2\rangle\) is a field, and only the point \((-1, 2)\) turns it into \(\langle -16, 12\rangle\). Fourth, thinking the gradient lies along a level curve — it is perpendicular to it, which is the whole reason contour crossings measure steepness. Fifth, mixing up the roles: \(\mathbf{u}\) sets the direction of travel, while \(\nabla f\) is a property of the landscape, not of the walker.
Key takeaways
The gradient \(\nabla f = \langle f_x, f_y\rangle\) — plus \(f_z\) in three variables — collects the partial derivatives into a vector. The directional derivative \(D_{\mathbf{u}}f = \nabla f \cdot \mathbf{u}\) gives the rate of change along any unit vector \(\mathbf{u} = \langle\cos\theta, \sin\theta\rangle\), with non-unit directions normalised first. Since \(D_{\mathbf{u}}f = |\nabla f|\cos\theta\), the gradient points in the direction of steepest increase with rate \(|\nabla f|\), while \(-\nabla f\) is the direction of steepest decrease — the engine of gradient descent. And because the rate along a level curve is \(0\), the gradient is perpendicular to level curves and, in three variables, normal to level surfaces.
Flashcards
Flashcard
∇f = ⟨f_x, f_y⟩
Test your understanding
Question 1 of 5
For f(x, y) = x³y, what is the gradient at the point (2, 1)?
Question 2 of 5
At a point where ∇f = ⟨3, −4⟩, what is the maximum rate of increase of f?
Question 3 of 5
A plate has temperature T(x, y) = 50 + x² + 2y². At the point (1, 1), in which direction does the temperature decrease fastest?
Question 4 of 5
At a point, ∇f = ⟨5, 5⟩. What is the directional derivative in the direction of the vector ⟨6, 8⟩?
Question 5 of 5
A hiker walks along a path on which f keeps a constant value. What is true of ∇f at her position?
Standards: Beyond AP
