You are on page 1of 12

13.

5: Directional Derivatives and Gradient Vectors


Learning Objectives
Determine the directional derivative in a given direction for a function of two variables.
Determine the gradient vector of a given real-valued function.
Explain the significance of the gradient vector with regard to direction of change along a surface.
Use the gradient to find the tangent to a level curve of a given function.
Calculate directional derivatives and gradients in three dimensions.

A function z = f (x, y) has two partial derivatives: ∂z/∂x and ∂z/∂y . These derivatives correspond to each of the independent variables
and can be interpreted as instantaneous rates of change (that is, as slopes of a tangent line). For example, ∂z/∂x represents the slope of a
tangent line passing through a given point on the surface defined by z = f (x, y), assuming the tangent line is parallel to the x-axis.
Similarly, ∂z/∂y represents the slope of the tangent line parallel to the y -axis. Now we consider the possibility of a tangent line parallel
to neither axis.

Directional Derivatives
We start with the graph of a surface defined by the equation z = f (x, y) . Given a point (a, b) in the domain of f , we choose a direction to
travel from that point. We measure the direction using an angle θ , which is measured counterclockwise in the xy-plane, starting at zero
from the positive x-axis (Figure 13.5.1). The distance we travel is h and the direction we travel is given by the unit vector
u = (cos θ) i + (sin θ) j . Therefore, the z -coordinate of the second point on the graph is given by z = f (a + h cos θ, b + h sin θ).
⇀ ^ ^

Figure 13.5.1 : Finding the directional derivative at a point on the graph of z . The slope of the blue arrow on the graph indicates
= f (x, y)

the value of the directional derivative at that point.


We can calculate the slope of the secant line by dividing the difference in z -values by the length of the line segment connecting the two
points in the domain. The length of the line segment is h . Therefore, the slope of the secant line is
f (a + h cos θ, b + h sin θ) − f (a, b)
msec = (13.5.1)
h

To find the slope of the tangent line in the same direction, we take the limit as h approaches zero.

Definition: Directional Derivatives


Suppose z = f (x, y) is a function of two variables with a domain of D . Let (a, b) ∈ D and define ⇀ ^ ^
u = (cos θ) i + (sin θ) j . Then
the directional derivative of f in the direction of u is given by

f (a + h cos θ, b + h sin θ) − f (a, b)


D⇀ f (a, b) = lim (13.5.2)
u
h→0 h

provided the limit exists.

12/31/2020 13.5.1 CC-BY-NC-SA https://math.libretexts.org/@go/page/8260


Equation 13.5.2 provides a formal definition of the directional derivative that can be used in many cases to calculate a directional
derivative.
Note that since the point (a, b) is chosen randomly from the domain D of the function f , we can use this definition to find the directional
derivative as a function of x and y .
That is,
f (x + h cos θ, y + h sin θ) − f (x, y)
D⇀ f (x, y) = lim (13.5.3)
u
h→0 h

Example 13.5.1 : Finding a Directional Derivative from the Definition


Let θ = arccos(3/5). Find the directional derivative D⇀ f (x, y)
u
of f (x, y) = x
2
− xy + 3 y
2
in the direction of
⇀ ^ ^
u = (cos θ) i + (sin θ) j .
Then determine D ⇀ f (−1,
u
2).
Solution
First of all, since cos θ = 3/5 and θ is acute, this implies
−−−−−−−−
2 −−

3 16 4
sin θ = √ 1 − ( ) =√ = .
5 25 5

Using f (x, y) = x 2
− xy + 3 y ,
2
we first calculate f (x + h cos θ, y + h sin θ) :
2 2
f (x + h cos θ, y + h sin θ) = (x + h cos θ) − (x + h cos θ)(y + h sin θ) + 3(y + h sin θ)

2 2 2 2 2 2 2
=x + 2xh cos θ + h cos θ − xy − xh sin θ − yh cos θ − h sin θ cos θ + 3 y + 6yh sin θ + 3 h sin θ
2 2
3 9h 4xh 3yh 12h 4 16
2 2 2
=x + 2xh( )+ − xy − − − + 3y + 6yh( ) + 3h ( )
5 25 5 5 25 5 25
2
2 2
2xh 9h 21yh
=x − xy + 3 y + + + .
5 5 5

We substitute this expression into Equation 13.5.2 with a = x and b = y :


f (x + h cos θ, y + h sin θ) − f (x, y)
D⇀ f (x, y) = lim
u
h→0 h
2
2xh 9h 21yh
2 2 2 2
(x − xy + 3 y + + + ) − (x − xy + 3 y )
5 5 5
= lim
h→0 h
2
2xh 9h 21yh
+ +
5 5 5
= lim
h→0 h

2x 9h 21y
= lim + +
h→0 5 5 5

2x + 21y
= .
5

To calculate D ⇀ f (−1,
u
2), we substitute x = −1 and y = 2 into this answer (Figure 13.5.2):
2(−1) + 21(2) −2 + 42
D⇀ f (−1, 2) = = = 8.
u
5 5

12/31/2020 13.5.2 CC-BY-NC-SA https://math.libretexts.org/@go/page/8260


Figure 13.5.2 : Finding the directional derivative in a given direction at a given point on a surface. The plane is tangent to the

u

surface at the given point (−1, 2, 15).

An easier approach to calculating directional derivatives that involves partial derivatives is outlined in the following theorem.

Directional Derivative of a Function of Two Variables


Let z = f (x, y) be a function of two variables x and y , and assume that f and f exist. Then the directional derivative of
x y f in the
direction of u = (cos θ) ^i + (sin θ) ^j is given by

D⇀ f (x, y) = fx (x, y) cos θ + fy (x, y) sin θ. (13.5.4)


u

Proof
Applying the definition of a directional derivative stated above in Equation 13.5.2, the directional derivative of f in the direction of
u = (cos θ) i + (sin θ) j at a point (x , y ) in the domain of f can be written
⇀ ^ ^
0 0

f (x0 + t cos θ, y0 + t sin θ) − f (x0 , y0 )


D⇀ f ((x0 , y0 )) = lim . (13.5.5)
u
t→0 t

Let x = x + t cos θ and y = y + t sin θ, and define


0 0 g(t) = f (x, y) . Since fx and fy both exist, we can use the chain rule for
functions of two variables to calculate g'(t) :
∂f dx ∂f dy
g'(t) = + = fx (x, y) cos θ + fy (x, y) sin θ. (13.5.6)
∂x dt ∂y dt

If t = 0, then x = x and y = y 0 0, so
g'(0) = fx (x0 , y0 ) cos θ + fy (x0 , y0 ) sin θ (13.5.7)

By the definition of g'(t), it is also true that


g(t) − g(0) f (x0 + t cos θ, y0 + t sin θ) − f (x0 , y0 )
g'(0) = lim = lim . (13.5.8)
t→0 t t→0 t

Therefore, D ⇀ f (x0 ,
u
y0 ) = fx (x0 , y0 ) cos θ + fy (x0 , y0 ) sin θ .
Since the point (x , y ) is an arbitrary point from the domain of f , this result holds for all points in the domain of
0 0 f for which the
partials f and f exist.
x y

Therefore,

D⇀ f (x, y) = fx (x, y) cos θ + fy (x, y) sin θ. (13.5.9)


u

Example 13.5.2 : Finding a Directional Derivative: Alternative Method

12/31/2020 13.5.3 CC-BY-NC-SA https://math.libretexts.org/@go/page/8260


Let θ = arccos(3/5). Find the directional derivative D⇀ f (x, y)
u
of f (x, y) = x
2
− xy + 3 y
2
in the direction of
⇀ ^ ^
u = (cos θ) i + (sin θ) j .
Then determine D ⇀ f (−1,
u
2) .
Solution
First, we must calculate the partial derivatives of f :
fx (x, y) = 2x − y

fy (x, y) = −x + 6y,

Then we use Equation 13.5.4 with θ = arccos(3/5):


D⇀ f (x, y) = fx (x, y) cos θ + fy (x, y) sin θ
u

3 4
= (2x − y) + (−x + 6y)
5 5
6x 3y 4x 24y
= − − +
5 5 5 5
2x + 21y
= .
5

To calculate D ⇀ f (−1,
u
2), let x = −1 and y = 2 :
2(−1) + 21(2) −2 + 42
D⇀ f (−1, 2) = = = 8.
u
5 5

This is the same answer obtained in Example 13.5.1.

Exercise 13.5.1 :
π π
Find the directional derivative D⇀ f (x, y)
u
of f (x, y) = 3 x y − 4x y
2 3
+ 3y
2
− 4x in the direction of ⇀
u = (cos
^
) i + (sin
^
) j
3 3
using Equation 13.5.4.
What is D ⇀ f (3,
u
?
4)

Hint
Calculate the partial derivatives and determine the value of θ .
Answer
3 2 2

(6xy − 4 y − 4)(1) (3 x − 12x y + 6y)√3
D⇀ f (x, y) = +
u
2 2
– –
72 − 256 − 4 (27 − 576 + 24)√3 525 √3
D⇀ f (3, 4) = + = −94 −
u
2 2 2

If the vector that is given for the direction of the derivative is not a unit vector, then it is only necessary to divide by the norm of the
vector. For example, if we wished to find the directional derivative of the function in Example 13.5.2 in the direction of the vector
⟨−5, 12⟩, we would first divide by its magnitude to get u . This gives us u = ⟨− ⟩.
⇀ ⇀ 5 12
,
13 13

Then

D⇀ f (x, y) = fx (x, y) cos θ + fy (x, y) sin θ


u

5 12
=− (2x − y) + (−x + 6y)
13 13
22 17
=− x+ y
13 13

Gradient
The right-hand side of Equation 13.5.4 is equal to f (x, y) cos θ + f (x, y) sin θ , which can be written as the dot product of two vectors.
x y

Define the first vector as ∇f (x, y) = f (x, y) ^i + f (x, y) ^j and the second vector as u = (cos θ) ^i + (sin θ) ^j . Then the right-hand
x y

side of the equation can be written as the dot product of these two vectors:


D⇀ f (x, y) = ∇f (x, y) ⋅ u . (13.5.10)
u

12/31/2020 13.5.4 CC-BY-NC-SA https://math.libretexts.org/@go/page/8260



The first vector in Equation 13.5.10 has a special name: the gradient of the function f . The symbol ∇ is called nabla and the vector ∇f
is read “del f .”

Definition: The Gradient



Let z = f (x, y) be a function of x and y such that f and f exist. The vector ∇f (x, y) is called the gradient of f and is defined as
x y


^ ^
∇f (x, y) = fx (x, y) i + fy (x, y) j . (13.5.11)


The vector ∇f (x, y) is also written as “grad f .”

Example 13.5.3 : Finding Gradients



Find the gradient ∇f (x, y) of each of the following functions:
a. f (x, y) = x − xy + 3y
2 2

b. f (x, y) = sin 3x cos 3y


Solution
For both parts a. and b., we first calculate the partial derivatives f and f , then use Equation 13.5.11. x y

a. fx (x, y) = 2x − y and f y (x, y) = −x + 6y , so



^ ^
∇f (x, y) = fx (x, y) i + fy (x, y) j

^ ^
= (2x − y) i + (−x + 6y) j .

b. f x (x, y) = 3 cos 3x cos 3y and f y (x, y) = −3 sin 3x sin 3y , so



^ ^
∇f (x, y) = fx (x, y) i + fy (x, y) j

^ ^
= (3 cos 3x cos 3y) i − (3 sin 3x sin 3y) j .

Exercise 13.5.2
2 2
⇀ x − 3y
Find the gradient ∇f (x, y) of f (x, y) = .
2x + y

Hint
Calculate the partial derivatives, then use Equation 13.5.11.
Answer
2 2 2 2
⇀ 2x + 2xy + 6 y x + 12xy + 3 y
^ ^
∇f (x, y) = i − j
2 2
(2x + y) (2x + y)

The gradient has some important properties. We have already seen one formula that uses the gradient: the formula for the directional
⇀ ⇀ ⇀
derivative. Recall from The Dot Product that if the angle between two vectors a and b is φ , then a ⋅ b = ∥ a ∥∥ b ∥ cos φ. Therefore, if
⇀ ⇀ ⇀


the angle between ∇f (x , y ) and u = (cosθ) ^i + (sinθ) ^j is φ , we have
0 0

⇀ ⇀ ⇀
⇀ ⇀
D⇀ f (x0 , y0 ) = ∇f (x0 , y0 ) ⋅ u = ∥ ∇f (x0 , y0 )∥∥ u ∥ cos φ = ∥ ∇f (x0 , y0 )∥ cos φ. (13.5.12)
u

The ∥ u ∥ disappears because u is a unit vector. Therefore, the directional derivative is equal to the magnitude of the gradient evaluated at
⇀ ⇀

(x , y ) multiplied by cos φ. Recall that cos φ ranges from −1 to 1 .


0 0


If φ = 0, then cos φ = 1 and ∇f (x 0, y0 ) and u both point in the same direction.


If φ = π , then cos φ = −1 and ∇f (x 0, y0 ) and u point in opposite directions.

In the first case, the value of D ⇀ f (x0 ,


u
y0 ) is maximized; in the second case, the value of D ⇀ f (x0 ,
u
y0 ) is minimized.
⇀ ⇀
We can also see that if ∇f (x 0, y0 ) = 0 , then


D⇀ f (x0 , y0 ) = ∇f (x0 , y0 ) ⋅ u = 0 (13.5.13)
u

12/31/2020 13.5.5 CC-BY-NC-SA https://math.libretexts.org/@go/page/8260


for any vector u . These three cases are outlined in the following theorem.

Properties of the Gradient


Suppose the function z = f (x, y) is differentiable at (x 0, y0 ) (Figure 13.5.3).
⇀ ⇀
i. If ∇f (x 0, y0 ) = 0 , then D ⇀ f (x0 ,
u
y0 ) = 0 for any unit vector u . ⇀

⇀ ⇀ ⇀
ii. If ∇f (x 0, y0 ) ≠ 0 , then D ⇀ f (x0 ,
u
y0 ) is maximized when u points in the same direction as

∇f (x0 , y0 ) . The maximum value

of D f (x , y ) is ∥∇f (x , y )∥.

u 0 0 0 0
⇀ ⇀ ⇀
iii. If ∇f (x , y ) ≠ 0 , then D f (x , y ) is minimized when
0 0 ⇀
u 0 0

u points in the opposite direction from ∇f (x0 , y0 ) . The minimum

value of D f (x , y ) is −∥∇f (x , y )∥.

u
0 0 0 0

Figure 13.5.3 : The gradient indicates the maximum and minimum values of the directional derivative at a point.

Example 13.5.4 : Finding a Maximum Directional Derivative


Find the direction for which the directional derivative of f (x, y) = 3 x
2
− 4xy + 2 y
2
at (−2, 3) is a maximum. What is the
maximum value?
Solution

The maximum value of the directional derivative occurs when ∇f and the unit vector point in the same direction. Therefore, we start

by calculating ∇f (x, y):

fx (x, y) = 6x − 4y and fy (x, y) = −4x + 4y

so

^ ^ ^ ^
∇f (x, y) = fx (x, y) i + fy (x, y) j = (6x − 4y) i + (−4x + 4y) j .

Next, we evaluate the gradient at (−2, 3):



^ ^ ^ ^
∇f (−2, 3) = (6(−2) − 4(3)) i + (−4(−2) + 4(3)) j = −24 i + 20 j .

⇀ ⇀
We need to find a unit vector that points in the same direction as ∇f (−2, 3), so the next step is to divide ∇f (−2, 3) by its
−−−−−−−−−−− − −−− −−
magnitude, which is √(−24) + (20) = √976 = 4√61 . Therefore,
2 2

⇀ −− −−
∇f (−2, 3) −24 20 6 √61 5 √61
^ ^
= i+ j=− i + j.
⇀ −− −−
4 √61 4 √61 61 61
∥ ∇f (−2, 3)∥

12/31/2020 13.5.6 CC-BY-NC-SA https://math.libretexts.org/@go/page/8260



This is the unit vector that points in the same direction as ∇f (−2, 3). To find the angle corresponding to this unit vector, we solve
the equations
−− −−
−6 √61 5 √61
cos θ = and sin θ =
61 61

for θ . Since cosine is negative and sine is positive, the angle must be in the second quadrant. Therefore,
−−
θ = π − arcsin((5 √61)/61) ≈ 2.45 rad.
⇀ −−
The maximum value of the directional derivative at (−2, 3) is ∥∇f (−2, 3)∥ = 4√61 (Figure 13.5.4).

Figure 13.5.4 : The maximum value of the directional derivative at (−2, 3) is in the direction of the gradient.

Exercise 13.5.3
Find the direction for which the directional derivative of g(x, y) = 4x − xy + 2y 2
at (−2, 3) is a maximum. What is the maximum
value?

Hint
Evaluate the gradient of g at point (−2, 3).
Answer
⇀ ⇀
The gradient of g at (−2, 3) is ∇g(−2, 3) = ^ ^
i + 14 j . The unit vector that points in the same direction as ∇g(−2, 3) is

−−− −−−
∇g(−2, 3) 1 14 √197 14 √197
^ ^ ^ ^
= i + j = i + j,
⇀ −−− −−−
√197 √197 197 197
∥ ∇g(−2, 3)∥

−−−
which gives an angle of θ = arcsin((14√197)/197) ≈ 1.499 rad.
⇀ −−−
The maximum value of the directional derivative is ∥∇g(−2, 3)∥ = √197.

Figure 13.5.5 shows a portion of the graph of the function f (x, y) = 3 + sin x sin y . Given a point (a, b) in the domain of f , the

maximum value of the directional derivative at that point is given by ∥∇f (a, b)∥. This would equal the rate of greatest ascent if the
surface represented a topographical map. If we went in the opposite direction, it would be the rate of greatest descent.

12/31/2020 13.5.7 CC-BY-NC-SA https://math.libretexts.org/@go/page/8260


Figure 13.5.5 : A typical surface in R . Given a point on the surface, the directional derivative can be calculated using the gradient.
3

When using a topographical map, the steepest slope is always in the direction where the contour lines are closest together (Figure 13.5.6).
This is analogous to the contour map of a function, assuming the level curves are obtained for equally spaced values throughout the range
of that function.

Figure 13.5.6 : Contour map for the function f (x, y) = x 2


−y
2
using level values between −5 and 5.

Gradients and Level Curves


Recall that if a curve is defined parametrically by the function pair (x(t), y(t)), then the vector x'(t) ^i + y'(t) ^j is tangent to the curve
for every value of t in the domain. Now let’s assume z = f (x, y) is a differentiable function of x and y , and (x , y ) is in its domain.
0 0

Let’s suppose further that x = x(t ) and y = y(t ) for some value of t , and consider the level curve f (x, y) = k . Define
0 0 0 0

g(t) = f (x(t), y(t)) and calculate g'(t) on the level curve. By the chain Rule,

g'(t) = fx (x(t), y(t))x'(t) + fy (x(t), y(t))y'(t). (13.5.14)

But g'(t) = 0 because g(t) = k for all t . Therefore, on the one hand,
fx (x(t), y(t))x'(t) + fy (x(t), y(t))y'(t) = 0; (13.5.15)

on the other hand,



fx (x(t), y(t))x'(t) + fy (x(t), y(t))y'(t) = ∇f (x, y) ⋅ ⟨x'(t), y'(t)⟩. (13.5.16)

Therefore,

∇f (x, y) ⋅ ⟨x'(t), y'(t)⟩ = 0. (13.5.17)

12/31/2020 13.5.8 CC-BY-NC-SA https://math.libretexts.org/@go/page/8260


Thus, the dot product of these vectors is equal to zero, which implies they are orthogonal. However, the second vector is tangent to the
level curve, which implies the gradient must be normal to the level curve, which gives rise to the following theorem.

Gradient Is Normal to the Level Curve


Suppose the function z = f (x, y) has continuous first-order partial derivatives in an open disk centered at a point (x0 , y0 ) . If
⇀ ⇀
∇f (x0 , y0 ) ≠ 0 , then ∇f (x 0 , y0 ) is normal to the level curve of f at (x 0 , y0 ).

We can use this theorem to find tangent and normal vectors to level curves of a function.

Example 13.5.5 : Finding Tangents to Level Curves


For the function f (x, y) = 2x − 3xy + 8y + 2x − 4y + 4, find a tangent vector to the level curve at point
2 2
. Graph the
(−2, 1)

level curve corresponding to f (x, y) = 18 and draw in ∇f (−2, 1) and a tangent vector.
Solution

First, we must calculate ∇f (x, y) :

^ ^
fx (x, y) = 4x − 3y + 2 and fy = −3x + 16y − 4 so ∇f (x, y) = (4x − 3y + 2) i + (−3x + 16y − 4) j .


Next, we evaluate ∇f (x, y) at (−2, 1) :

^ ^ ^ ^
∇f (−2, 1) = (4(−2) − 3(1) + 2) i + (−3(−2) + 16(1) − 4) j = −9 i + 18 j .

This vector is orthogonal to the curve at point (−2, 1). We can obtain a tangent vector by reversing the components and multiplying
either one by −1. Thus, for example, −18 ^i − 9 ^j is a tangent vector (Figure 13.5.7).

Figure 13.5.7 : Tangent and normal vectors to 2x 2


− 3xy + 8y
2
+ 2x − 4y + 4 = 18 at point (−2, 1).

Exercise 13.5.4
For the function f (x, y) = x − 2xy + 5y + 3x − 2y + 3 , find the tangent to the level curve at point (1, 1). Draw the graph of the
2 2


level curve corresponding to f (x, y) = 8 and draw ∇f (1, 1) and a tangent vector.

Hint
Calculate the gradient at point (1, 1).
Answer

^ ^
∇f (x, y) = (2x − 2y + 3) i + (−2x + 10y − 2) j

^ ^
∇f (1, 1) = 3 i + 6 j

Tangent vector: 6 ^i − 3 ^j or −6 ^i + 3 ^j

12/31/2020 13.5.9 CC-BY-NC-SA https://math.libretexts.org/@go/page/8260


Three-Dimensional Gradients and Directional Derivatives
The definition of a gradient can be extended to functions of more than two variables.

Definition: Gradients in 3D

Let w = f (x, y, z) be a function of three variables such that f x, fy , and f exist. The vector
z ∇f (x, y, z) is called the gradient of f

and is defined as

^ ^ ^
∇f (x, y, z) = fx (x, y, z) i + fy (x, y, z) j + fz (x, y, z) k. (13.5.18)


∇f (x, y, z) can also be written as grad f (x, y, z).

Calculating the gradient of a function in three variables is very similar to calculating the gradient of a function in two variables. First, we
calculate the partial derivatives f , f , and f , and then we use Equation 13.5.18.
x y z

Example 13.5.6 : Finding Gradients in Three Dimensions



Find the gradient ∇f (x, y, z) of each of the following functions:
a. f (x, y, z) = 5x 2
− 2xy + y
2
− 4yz + z
2
+ 3xz

b. f (x, y, z) = e −2z
sin 2x cos 2y

Solution
For both parts a. and b., we first calculate the partial derivatives f x, fy , and f , then use Equation 13.5.18.
z

a. fx (x, y, z) = 10x − 2y + 3z ,fy (x, y, z) = −2x + 2y − 4z , and f z (x, y, z) = 3x − 4y + 2z , so



^ ^ ^
∇f (x, y, z) = fx (x, y, z) i + fy (x, y, z) j + fz (x, y, z) k

^ ^ ^
= (10x − 2y + 3z) i + (−2x + 2y − 4z) j + (3x − 4y + 2z) k.

b. f x (x, y, z) = 2 e
−2z
,
cos 2x cos 2y fy (x, y, z) = −2 e
−2z
sin 2x sin 2y , and f z (x, y, z) = −2 e
−2z
sin 2x cos 2y , so

^ ^ ^
∇f (x, y, z) = fx (x, y, z) i + fy (x, y, z) j + fz (x, y, z) k

−2z ^ −2z ^ −2z ^


= (2 e cos 2x cos 2y) i + (−2 e sin 2x sin 2y) j + (−2 e sin 2x cos 2y) k

−2z ^ ^ ^
= 2e (cos 2x cos 2y i − sin 2x sin 2y j − sin 2x cos 2y k).

Exercise 13.5.5 :
2 2 2
⇀ x − 3y +z
Find the gradient ∇f (x, y, z) of f (x, y, z) =
2x + y − 4z.

Answer
2 2 2 2 2 2 2 2 2
⇀ 2x + 2xy + 6 y − 8xz − 2 z x + 12xy + 3 y − 24yz + z 4x − 12 y − 4z + 4xz + 2yz
^ ^ ^
∇f (x, y, z) = i − j + k
2 2 2
(2x + y − 4z) (2x + y − 4z) (2x + y − 4z)

12/31/2020 13.5.10 CC-BY-NC-SA https://math.libretexts.org/@go/page/8260


The directional derivative can also be generalized to functions of three variables. To determine a direction in three dimensions, a vector
with three components is needed. This vector is a unit vector, and the components of the unit vector are called directional cosines. Given a
three-dimensional unit vector u in standard form (i.e., the initial point is at the origin), this vector forms three different angles with the

positive x-, y -, and z -axes. Let’s call these angles α, β, and γ. Then the directional cosines are given by cos α, cos β, and cos γ. These are
the components of the unit vector u ; since u is a unit vector, it is true that cos α + cos β + cos γ = 1.
⇀ ⇀ 2 2 2

Definition: Directional Derivative of a Function of Three variables


Suppose w = f (x, y, z) is a function of three variables with a domain of D. Let (x , y , z ) ∈ D 0 0 0 and let
⇀ ^ ^ ^
u = cos α i + cos β j + cos γ k be a unit vector. Then, the directional derivative of f in the direction of u is given by
f (x0 + t cos α, y0 + t cos β, z0 + t cos γ) − f (x0 , y0 , z0 )
D⇀ f (x0 , y0 , z0 ) = lim (13.5.19)
u
t→0 t

provided the limit exists.

We can calculate the directional derivative of a function of three variables by using the gradient, leading to a formula that is analogous to
Equation 13.5.4.

Directional Derivative of a Function of Three Variables


Let f (x, y, z) be a differentiable function of three variables and let ⇀ ^ ^ ^
u = cos α i + cos β j + cos γ k be a unit vector. Then, the
directional derivative of f in the direction of u is given by ⇀



D⇀ f (x, y, z) = ∇f (x, y, z) ⋅ u = fx (x, y, z) cos α + fy (x, y, z) cos β + fz (x, y, z) cos γ. (13.5.20)
u

The three angles α, β, and γ determine the unit vector ⇀


u . In practice, we can use an arbitrary (nonunit) vector, then divide by its
magnitude to obtain a unit vector in the desired direction.

Example 13.5.7 : Finding a Directional Derivative in Three Dimensions


Calculate D ⇀ f (1,
v
−2, 3) in the direction of ⇀ ^ ^ ^
v = − i +2 j +2 k for the function
2 2 2
f (x, y, z) = 5 x − 2xy + y − 4yz + z + 3xz.

Solution:
First, we find the magnitude of v :
−−−−−−−−−−−−−−−
⇀ 2 2 2 –
∥ v ∥ = √ (−1 ) + (2 ) + (2 ) = √9 = 3.

⇀ ^ ^ ^
v −i + 2 j + 2 k 1 2 2 1 2
Therefore, ⇀
= =−
^
i +
^
j +
^
k is a unit vector in the direction of ⇀
v , so cos α = − , cos β = , and
∥ v∥ 3 3 3 3 3 3

2
cos γ = . Next, we calculate the partial derivatives of f :
3

fx (x, y, z) = 10x − 2y + 3z

fy (x, y, z) = −2x + 2y − 4z

fz (x, y, z) = −4y + 2z + 3x,

then substitute them into Equation 13.5.20:


D⇀ f (x, y, z) = fx (x, y, z) cos α + fy (x, y, z) cos β + fz (x, y, z) cos γ
v

1 2 2
= (10x − 2y + 3z)(− ) + (−2x + 2y − 4z)( ) + (−4y + 2z + 3x)( )
3 3 3

10x 2y 3z 4x 4y 8z 8y 4z 6x
=− + − − + − − + +
3 3 3 3 3 3 3 3 3
8x 2y 7z
=− − − .
3 3 3

Last, to find D ⇀ f (1,


v
−2, 3), we substitute x = 1, y = −2 , and z = 3 :

12/31/2020 13.5.11 CC-BY-NC-SA https://math.libretexts.org/@go/page/8260


8(1) 2(−2) 7(3)
D⇀ f (1, −2, 3) = − − −
v
3 3 3
8 4 21
=− + −
3 3 3
25
=− .
3

Exercise 13.5.6 :
Calculate D ⇀ f (x,
v
y, z) and D⇀ f (0,
v
−2, 5) in the direction of ⇀ ^ ^ ^
v = −3 i + 12 j − 4 k for the function
2 2 2
f (x, y, z) = 3 x + xy − 2 y + 4yz − z + 2xz.

Hint
First, divide ⇀
v by its magnitude, calculate the partial derivatives of f , then use Equation 13.5.20.
Answer
3 12 4
D⇀ f (x, y, z) = − (6x + y + 2z) + (x − 4y + 4z) − (2x + 4y − 2z)
v
13 13 13
384
D⇀ f (0, −2, 5) =
v
13

Summary
A directional derivative represents a rate of change of a function in any given direction.
The gradient can be used in a formula to calculate the directional derivative.
The gradient indicates the direction of greatest change of a function of more than one variable.

Key Equations
directional derivative (two dimensions)
f (a + h cos θ, b + h sin θ) − f (a, b)
D⇀ f (a, b) = lim
u
h→0 h

or

D⇀ f (x, y) = fx (x, y) cos θ + fy (x, y) sin θ


u

gradient (two dimensions)



^ ^
∇f (x, y) = fx (x, y) i + fy (x, y) j

gradient (three dimensions)



^ ^ ^
∇f (x, y, z) = fx (x, y, z) i + fy (x, y, z) j + fz (x, y, z) k

directional derivative (three dimensions)




D⇀ f (x, y, z) = ∇f (x, y, z) ⋅ u = fx (x, y, z) cos α + fy (x, y, z) cos β + fx (x, y, z) cos γ
u

Glossary
directional derivative
the derivative of a function in the direction of a given unit vector
gradient

the gradient of the function f (x, y) is defined to be ^ ^
∇f (x, y) = (∂f /∂x) i + (∂f /∂y) j , which can be generalized to a function of
any number of independent variables

Contributors and Attributions


Gilbert Strang (MIT) and Edwin “Jed” Herman (Harvey Mudd) with many contributing authors. This content by OpenStax is
licensed with a CC-BY-SA-NC 4.0 license. Download for free at http://cnx.org.

12/31/2020 13.5.12 CC-BY-NC-SA https://math.libretexts.org/@go/page/8260

You might also like