Directional Derivatives and the Gradient
What You’ll Learn
Section titled “What You’ll Learn”In this lesson you’ll learn how to compute the rate of change of a function in any direction you choose, not just along the x or y axes. The directional derivative generalizes partial derivatives, and the gradient vector turns out to be the key to all of it.
The Concept
Section titled “The Concept”Partial Derivatives Only Go Two Ways
Section titled “Partial Derivatives Only Go Two Ways”Partial derivatives tell you the rate of change along the x-axis (holding y constant) and along the y-axis (holding x constant). But what if you want to know the rate of change in some other direction, like diagonally?
That’s what the directional derivative does.
The Directional Derivative
Section titled “The Directional Derivative”The directional derivative of f at a point P in the direction of a unit vector u is
That’s it. Take the gradient, dot it with the direction you care about. The result is a number telling you how fast f changes as you move in that direction.
The unit vector part is important. The direction vector u must have length 1. If someone gives you a direction like ⟨3, 4⟩, you need to normalize it first by dividing by its magnitude: u = ⟨3/5, 4/5⟩.
What the Gradient Tells You
Section titled “What the Gradient Tells You”The gradient ∇f is more than just a collection of partial derivatives. It has deep geometric meaning:
- It points in the direction of steepest ascent (where f increases fastest)
- Its magnitude is the maximum rate of increase
- The directional derivative is maximized when u points in the same direction as ∇f
- The directional derivative is zero when u is perpendicular to ∇f (along a level curve)
- The directional derivative is most negative when u points opposite to ∇f (steepest descent)
Worked Examples
Section titled “Worked Examples”Example 1: Computing a directional derivative
Let f(x, y) = x² + y² at the point (3, 4). Find the directional derivative in the direction of u = ⟨1, 0⟩ (pure x-direction).
The gradient is
The directional derivative is
This makes sense: moving in the pure x-direction, the rate of change is just the partial derivative with respect to x, which is 2x = 6 at x = 3.
Example 2: Maximum rate of change
At the same point (3, 4), the maximum rate of increase is the magnitude of the gradient
This maximum occurs in the direction of the gradient itself. The unit vector in that direction is
So the function increases fastest at a rate of 10 when you move in the direction ⟨0.6, 0.8⟩ (which points away from the origin, as expected for this bowl-shaped function).
The orange arrow is the gradient ∇f = ⟨6, 8⟩, pointing in the direction of steepest ascent (D = 10). The green arrow is the direction u = ⟨1, 0⟩ from Example 1 (D = 6). The purple arrow is v = ⟨0, 1⟩ (D = 8). The gradient always gives the largest directional derivative.
Example 3: Zero directional derivative
What direction gives a directional derivative of zero? Any direction perpendicular to the gradient. At (3, 4), the gradient is ⟨6, 8⟩. A perpendicular vector is ⟨-8, 6⟩ (swap and negate one component). Normalizing: u = ⟨-8/10, 6/10⟩ = ⟨-0.8, 0.6⟩.
Zero. Moving perpendicular to the gradient means moving along the level curve, where f doesn’t change. This is why the gradient is always perpendicular to level curves.
Real-World Application
Section titled “Real-World Application”Directional derivatives and the gradient show up constantly:
- Machine learning uses gradient descent, which follows the negative gradient to minimize a loss function. The gradient tells you the steepest direction, and you step opposite to it.
- Game engines use the gradient of a heightmap to determine slope direction for character movement, water flow, and AI pathfinding. The directional derivative tells you the slope in any specific direction.
- Physics uses gradients to describe force fields: the electric field is the negative gradient of electric potential.
- Weather modeling uses temperature gradients to predict wind direction (air flows from high to low pressure, perpendicular to isobars).
Retrying will remove your ✅ checkmark until you pass again.