Directional Derivative: Formula, Meaning and Solved Examples
By Dr. Muhammad Amjad Khadim (PhD Mathematics) · Updated November 2026
Ordinary partial derivatives tell you how a function changes as you move along the x-axis or the y-axis. But in real life you rarely walk only east or only north. A hiker crossing a hillside, a heat-seeking sensor, or a machine-learning algorithm stepping through a cost surface all move in some arbitrary direction. The directional derivative tells you the rate of change in any direction you choose, and it turns out to be one of the most useful ideas in multivariable calculus.
In this guide I explain the formula, show where it comes from, and work through solved examples in two and three dimensions, including questions on the direction of steepest ascent that appear on almost every Calc 3 paper. You can check your gradients and answers with the directional derivative calculator on our calculators page.
1. The definition and formula
2. Why the formula works
3. Step-by-step method
4. Worked examples
5. Maximum and minimum rate of change
6. A real-world example: temperature
7. Common mistakes, FAQs and practice
1. The Definition and Formula
Let f be a differentiable function and let u be a unit vector. The directional derivative of f at a point P in the direction of u is
where ∇f = (∂f/∂x, ∂f/∂y, ∂f/∂z) is the gradient. In words: work out the gradient at the point, then take its dot product with the unit direction vector.
The formal definition is a limit, just like an ordinary derivative:
Duf(P) = limh→0 [ f(P + hu) − f(P) ] / h
Notice that the partial derivatives are special cases: Dif = ∂f/∂x and Djf = ∂f/∂y.
2. Why the Formula Works
Move from P a small distance h in the direction u = (u1, u2). The x-coordinate changes by hu1 and the y-coordinate by hu2. To first order, the change in f is
Δf ≈ (∂f/∂x)(hu1) + (∂f/∂y)(hu2) = h (∇f · u)
Dividing by h and letting h shrink to zero gives exactly ∇f · u. It is the multivariable chain rule in disguise.
Writing the dot product as |∇f||u| cos θ = |∇f| cos θ (since |u| = 1) gives a very useful geometric form, where θ is the angle between the gradient and the direction of travel. If you need a reminder about angles between vectors, see how to find the angle between two vectors.
3. Step-by-Step Method
- Find the gradient ∇f by computing each partial derivative.
- Evaluate the gradient at the given point.
- Turn the direction into a unit vector. If the direction is given as a vector v, use u = v/|v|. If it is given as an angle θ in 2D, use u = (cos θ, sin θ). If it is "towards the point Q", use v = Q − P. Our guide to the unit vector formula explains normalising in detail.
- Take the dot product ∇f(P) · u.
4. Worked Examples
Example 1: A 2D function in the direction of a vector
Find the directional derivative of f(x, y) = x²y + 3y at (1, 2) in the direction of v = 3i + 4j.
Gradient: ∇f = (2xy, x² + 3). At (1, 2): ∇f = (4, 4).
Unit vector: |v| = √(9 + 16) = 5, so u = (3/5, 4/5).
Dot product: Duf = 4(3/5) + 4(4/5) = 12/5 + 16/5 = 28/5 = 5.6.
So moving from (1, 2) in the direction of (3, 4), f increases at a rate of 5.6 units per unit distance.
Example 2: A 3D function
Find the directional derivative of f(x, y, z) = xyz at (1, 2, 3) in the direction of v = i − j + k.
Gradient: ∇f = (yz, xz, xy). At (1, 2, 3): ∇f = (6, 3, 2).
Unit vector: |v| = √3, so u = (1, −1, 1)/√3.
Dot product: Duf = (6 − 3 + 2)/√3 = 5/√3 ≈ 2.887.
Example 3: Direction given by an angle
Find the directional derivative of f(x, y) = ex sin y at (0, π/4) in the direction making an angle of π/3 with the positive x-axis.
Gradient: ∇f = (ex sin y, ex cos y). At (0, π/4): ∇f = (√2/2, √2/2).
Unit vector: u = (cos π/3, sin π/3) = (1/2, √3/2).
Dot product: Duf = (√2/2)(1/2) + (√2/2)(√3/2) = √2(1 + √3)/4 ≈ 0.966.
Example 4: Towards another point
Find the rate of change of f(x, y) = x² + xy at P(1, 1) in the direction towards Q(4, 5).
∇f = (2x + y, x), so ∇f(1, 1) = (3, 1). The direction is v = Q − P = (3, 4), with |v| = 5 and u = (3/5, 4/5). Then Duf = 9/5 + 4/5 = 13/5 = 2.6.
5. Maximum and Minimum Rate of Change
Since Duf = |∇f| cos θ and cos θ ranges from −1 to 1:
| Direction of u | θ | Duf | Meaning |
|---|---|---|---|
| Same as ∇f | 0° | |∇f| (maximum) | Steepest ascent |
| Opposite to ∇f | 180° | −|∇f| (minimum) | Steepest descent |
| Perpendicular to ∇f | 90° | 0 | Along a level curve |
This is the reason the gradient is so important: it points in the direction of fastest increase, and its length is that fastest rate. It also explains why the gradient is always perpendicular to level curves and level surfaces: along a level curve f does not change, so the directional derivative there is zero. Our post on slope and direction vectors shows the same idea for straight lines.
Example 5: Steepest ascent
For f(x, y) = x² + y² at (3, 4), find the direction of fastest increase and the maximum rate.
∇f = (2x, 2y) = (6, 8) at (3, 4). The direction of fastest increase is u = (6, 8)/10 = (3/5, 4/5), pointing straight away from the origin, and the maximum rate is |∇f| = 10. This makes sense: f measures squared distance from the origin, which grows fastest if you head directly outward.
6. A Real-World Example: Temperature
The temperature on a metal plate is T(x, y) = 100 − x² − 2y² degrees Celsius, with x and y in centimetres. An ant is at (2, 1).
(a) In which direction should the ant move to warm up as quickly as possible? ∇T = (−2x, −4y) = (−4, −4) at (2, 1). The fastest warming direction is u = (−1, −1)/√2, heading back towards the hot centre of the plate.
(b) How fast does the temperature rise in that direction? |∇T| = √(16 + 16) = 4√2 ≈ 5.66 °C per cm.
(c) In which directions does the temperature stay the same? Perpendicular to ∇T: u = ±(1, −1)/√2. Moving that way, the ant follows an isotherm (a curve of constant temperature).
The same reasoning is how "gradient descent" works in machine learning: to reduce a cost function as quickly as possible, step in the direction of −∇f.
7. Common Mistakes
- Not normalising the direction. This is the number one error. If you use v = (3, 4) instead of (3/5, 4/5), your answer is five times too big.
- Evaluating the gradient at the wrong point, or forgetting to evaluate it at all.
- Confusing the direction of steepest ascent with the maximum rate. The direction is a unit vector; the rate is a number, |∇f|.
- Mixing degrees and radians when the direction is given as an angle.
Frequently Asked Questions
Can a directional derivative be negative?
Yes. A negative value means f decreases as you move in that direction.
Is the directional derivative a vector or a scalar?
A scalar. It is a single rate of change. The gradient is the vector.
Why must u be a unit vector?
Because the directional derivative is meant to measure change per unit distance. If you used a vector of length 2, every step you take would cover twice the distance, and the answer would be doubled even though the hill is no steeper. Normalising the direction removes this effect, so the result depends only on the direction and not on how long the arrow happens to be. Some textbooks define a "derivative along v" without normalising, but then they always say so explicitly. Unless your course states otherwise, assume a unit vector is required.
What is the difference between the gradient and the directional derivative?
The gradient is a vector that packages all the partial derivatives. The directional derivative is the component of the gradient in a particular direction, in the same way that a scalar projection picks out the component of one vector along another.
Practice Problems
- f = 3x − 4y, any point, direction i. (Answer: 3)
- f = x² + y² + z² at (1, 1, 1), direction (1, 0, 0). (Answer: 2)
- f = xy at (2, 3): find the maximum rate of change. (Answer: √13, in direction (3, 2)/√13)
For further reading, see Paul's Online Notes on directional derivatives and the MathWorld entry. Test yourself with our vector and tensor analysis MCQs, and if you need to switch between centimetres, metres or temperature scales in applied problems, the converters at PakMath make it quick.
Comments
Post a Comment