Directional Derivatives

Project the gradient onto your direction.

The slope depends on the direction

Take the dome f(x, y) = 16(1 − x² − y²) and stand at the point (0.5, 0.36), at height 9.93. The gradient there is ∇f = (−32x, −32y) = (−16, −11.52). It points toward the summit at the origin, and its length, √(16² + 11.52²) ≈ 19.72, is the steepest slope available from that point.

Set off due south instead, along u = (0, −1). The summit lies partly south of you, so you still climb, but the slope that way is only 11.52. The slope of a surface in a chosen direction u is the directional derivative of f in that direction.

4812∇fu11.52

The dome f = 16(1 − x² − y²) seen from above, cut at heights 4, 8 and 12. At (0.5, 0.36) the gold arrow is ∇f, of length 19.72, and the plain arrow u points due south. The dashed line drops the tip of ∇f square onto u, and the gold bar along u is the part of ∇f in that direction: the slope due south, 11.52.

One part in each direction

Walk a distance t along the unit vector u = (a, b). Then x = x₀ + a t and y = y₀ + b t, so x changes at the rate a and y at the rate b. By the chain rule for partial derivatives, the height changes at the rate ∂f/∂x · a + ∂f/∂y · b: each part of the step is multiplied by its own partial derivative, and the two add.

That sum is the dot product of (∂f/∂x, ∂f/∂y) with (a, b). So the slope in the direction u is ∇f · u. At the point on the dome, due south is a = 0 and b = −1, and the slope is (−16) × 0 + (−11.52) × (−1) = 11.52.

A unit vector first

The variable t above is the distance walked only because u has length 1. A direction is often given as a displacement instead, so divide it by its length first.

For f(x, y) = x²y at (1, 2), ∂f/∂x = 2xy = 4 and ∂f/∂y = x² = 1, so ∇f = (4, 1). Head toward the point (4, 6): the displacement is (3, 4), its length is 5, and the unit vector is u = (0.6, 0.8). The slope is 4 × 0.6 + 1 × 0.8 = 3.2. Using the displacement itself gives ∇f · (3, 4) = 4 × 3 + 1 × 4 = 16, five times too big, because (3, 4) is five units long.

A difference quotient agrees: f(1 + 0.6h, 2 + 0.8h) − f(1, 2), divided by h, comes to 3.2 for small h.

Steepest, gentlest, level

For a unit vector u, ∇f · u = |∇f| cos θ, where θ is the angle between ∇f and u. The slope is greatest, |∇f|, when θ = 0, along the gradient; it is least, −|∇f|, when θ = 180°, straight downhill; and it is 0 when θ = 90°.

For x²y at (1, 2), |∇f| = √17 ≈ 4.12. Toward (4, 6) the slope 3.2 is cos θ = 3.2 / 4.12 ≈ 0.78 of that, with θ ≈ 39°. Along (−1, 4) ÷ √17, at right angles to (4, 1), the slope is (−4 + 4) ÷ √17 = 0.

On the dome, due south makes an angle of 54.25° with ∇f, and 19.72 × cos 54.25° = 11.52. Turning to 125.75°, measured from east, puts u at right angles to ∇f, and the slope is 0.

4812∇fu0

The same point with u turned to 125.75°, at right angles to ∇f. The tip of ∇f drops onto u at the starting point itself, and a square corner marks the right angle: the part of ∇f along u is 0, and u is tangent to the contour through the point.

Why contours are level

A contour is a curve along which the height does not change, so the slope along it is 0. Where ∇f is not zero, the slope is 0 only in the two opposite directions at right angles to ∇f. So the contour through a point runs at right angles to ∇f there, and the gradient crosses every contour square on.

∇fDu f = 2|∇f| = 2.83P = (1, 2), ∇f = (2, 2), φ = 45°

Du f = ∇f · u = |∇f| cos φ = 2.83 × 0.71 = 2: the slope in the direction u is the gradient's length scaled by the cosine of the angle between them

Turn u along the contour until Du f = 0

Contours of f = x² + y²/2, with P at (1, 2), where ∇f = (2x, y) = (2, 2), of length 2.83. The unit vector u points straight up, at 45° to ∇f, and the meter reads the slope ∇f · u = 2. Turn u to 45° and it reads 2.83, the length of ∇f; turn it to 135°, along the dashed tangent to the contour, and it reads 0.

The usual mistakes

Leaving the direction unnormalized. For x²y at (1, 2) toward (4, 6), (3, 4) gives 16; the unit vector (0.6, 0.8) gives the slope, 3.2.

Adding the partial derivatives whole. With ∇f = (15, 20) and u = (0.6, 0.8), the slope is 15 × 0.6 + 20 × 0.8 = 25, not 35: each partial counts only for its own share of the step.

Swapping the shares. The 0.6 goes with ∂f/∂x, because 0.6 of the step lies along x: 15 × 0.8 + 20 × 0.6 = 24 is the slope in a different direction.

Calling the gradient the fall line. ∇f points uphill; straight downhill is −∇f, where the slope is −|∇f|.

A skier

In the application below, the height of a ski slope is a function of position. The gradient at the skier, dotted with the unit vector toward a lift, gives her rate of descent as she sets off, and setting |∇h| cos θ equal to a gentler rate gives the angle of a traverse.

Worked example: A Skier Heading for the Lift Across a Gully: Her Rate of Descent as She Sets Off, and a Gentler Traverse

Question On a ski slope, the height of the snow at the point x meters east and y meters north of a marker is h(x, y) = 1800 + 0.0004x2 − 0.32y meters above sea level, for −500 ≤ x ≤ 500 and −1000 ≤ y ≤ 2000: a broad gully that runs downhill to the north. A skier stands at (300, 0). (a) She sets off toward a lift station 800 meters west and 600 meters north of her. Find the rate at which her height changes, in meters per meter, as she sets off, and compare it with the steepest rate of descent at that point. (b) She would rather traverse, descending at 0.2 meters per meter. Find the angle between such a traverse and the fall line, the direction of steepest descent, and the two directions, as unit vectors, in which she could set off.

  1. 1.(a) The partial derivatives are ∂ h∂ x = 0.0008x and ∂ h∂ y = −0.32, so at (300, 0) the gradient is ∇ h = (0.24, −0.32). Its length is √0.0576 + 0.1024 = √0.16 = 0.4.

    liftskier(a) gradient (0.24, −0.32), length 0.4
    liftskier(a) gradient (0.24, −0.32), length 0.4
    (a) The curves are contours 50 meters apart, and the ground falls toward the north, which is up the page. At the skier the gradient is ∇ h = (0.24, −0.32), of length 0.4.
  2. 2.The lift station is √8002 + 6002 = 1000 meters away, so the unit vector toward it is u = (−0.8, 0.6). The directional derivative is ∇ h · u = 0.24 × (−0.8) + (−0.32) × 0.6 = −0.192 − 0.192 = −0.384: she sets off descending 0.384 meters for each meter she travels.

    liftskier(a) gradient (0.24, −0.32), length 0.4u = (−0.8, 0.6): rate −0.384 m per m
    liftskier(a) gradient (0.24, −0.32), length 0.4u = (−0.8, 0.6): rate −0.384 m per m
    Toward the lift the unit vector is u = (−0.8, 0.6), and her height changes at ∇ h · u = −0.384 meters per meter.
  3. 3.The steepest descent is along the fall line, −∇ h0.4 = (−0.6, 0.8), at the length of the gradient, 0.4 meters per meter. Her direction is close to the fall line: the angle θ between them has cosθ = 0.3840.4 = 0.96, so θ ≈ 16°.

    liftfall lineskier(a) gradient (0.24, −0.32), length 0.4u = (−0.8, 0.6): rate −0.384 m per msteepest: 0.4 m per m along (−0.6, 0.8)
    liftfall lineskier(a) gradient (0.24, −0.32), length 0.4u = (−0.8, 0.6): rate −0.384 m per msteepest: 0.4 m per m along (−0.6, 0.8)
    The fall line, (−0.6, 0.8), is the direction of steepest descent, 0.4 meters per meter; the way to the lift is about 16° off it.
  4. 4.(b) Along a unit vector at an angle θ to the fall line, the height falls at 0.4cosθ meters per meter. Setting 0.4cosθ = 0.2 gives cosθ = 0.5, so θ = 60°, on either side of the fall line.

    liftfall lineskier(a) gradient (0.24, −0.32), length 0.4u = (−0.8, 0.6): rate −0.384 m per msteepest: 0.4 m per m along (−0.6, 0.8)(b) 0.4 cos θ = 0.2, so θ = 60 deg
    liftfall lineskier(a) gradient (0.24, −0.32), length 0.4u = (−0.8, 0.6): rate −0.384 m per msteepest: 0.4 m per m along (−0.6, 0.8)(b) 0.4 cos θ = 0.2, so θ = 60 deg
    (b) A descent of 0.2 meters per meter is half the steepest, so cosθ = 0.5 and each traverse makes 60° with the fall line.
  5. 5.Turning (−0.6, 0.8) through 60° each way, with cos 60° = 0.5 and sin 60° = √32, gives (−0.3 − 0.4√3, 0.4 − 0.3√3) ≈ (−0.99, −0.12) and (−0.3 + 0.4√3, 0.4 + 0.3√3) ≈ (0.39, 0.92). Check the second: 0.24 × 0.39 − 0.32 × 0.92 = 0.0936 − 0.2944 ≈ −0.2.

    liftfall lineskier(a) gradient (0.24, −0.32), length 0.4u = (−0.8, 0.6): rate −0.384 m per msteepest: 0.4 m per m along (−0.6, 0.8)(b) 0.4 cos θ = 0.2, so θ = 60 degalong (−0.99, −0.12) or (0.39, 0.92)
    liftfall lineskier(a) gradient (0.24, −0.32), length 0.4u = (−0.8, 0.6): rate −0.384 m per msteepest: 0.4 m per m along (−0.6, 0.8)(b) 0.4 cos θ = 0.2, so θ = 60 degalong (−0.99, −0.12) or (0.39, 0.92)
    The two traverses set off along about (−0.99, −0.12), toward the floor of the gully, and (0.39, 0.92), a little east of north.

Answer: (a) she descends 0.384 meters per meter, just under the steepest descent at that point, 0.4 meters per meter; (b) 60° from the fall line, setting off along about (−0.99, −0.12) or (0.39, 0.92)

Common mistakes

  • Using the displacement (−800, 600) in place of a unit vector and getting a rate of −384. A directional derivative needs a unit vector; dividing the displacement by the distance, 1000 meters, gives the rate per meter.
  • Taking the fall line to be the direction of the gradient, (0.6, −0.8). The gradient points the way the height rises fastest, which is uphill; the fall line is the opposite direction.

More partial derivatives problems, worked step by step →

Practice Directional Derivatives in the app