Learning Objectives
- 4.6.1 Determine the directional derivative in a given direction for a function of two variables.
- 4.6.2 Determine the gradient vector of a given real-valued function.
- 4.6.3 Explain the significance of the gradient vector with regard to direction of change along a surface.
- 4.6.4 Use the gradient to find the tangent to a level curve of a given function.
- 4.6.5 Calculate directional derivatives and gradients in three dimensions.
In Partial Derivatives we introduced the partial derivative. 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 x, y-plane, starting at zero from the positive x-axis (Figure 4.39). 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+hcosθ,b+hsinθ).
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
To find the slope of the tangent line in the same direction, we take the limit as h approaches zero.
Definition
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
provided the limit exists.
Equation 4.36 provides a formal definition of the directional derivative that can be used in many cases to calculate a directional derivative.
Example 4.31
Finding a Directional Derivative from the Definition
Let θ=arccos(3/5). Find the directional derivative Duf(x,y) of f(x,y)=x2−xy+3y2 in the direction of u=(cosθ)i+(sinθ)j. What is Duf(−1,2)?
Solution
First of all, since cosθ=3/5 and θ is acute, this implies
Using f(x,y)=x2−xy+3y2, we first calculate f(x+hcosθ,y+hsinθ):
We substitute this expression into Equation 4.36:
To calculate Duf(−1,2), we substitute x=−1 and y=2 into this answer:
(See the following figure.)
Another approach to calculating a directional derivative involves partial derivatives, as outlined in the following theorem.
Theorem 4.12
Directional Derivative of a Function of Two Variables
Let z=f(x,y) be a function of two variables xandy, and assume that fx and fy exist and f(x, y) is differentiable everywhere. Then the directional derivative of f in the direction of u=cosθi+sinθj is given by
Proof
Equation 4.36 states that the directional derivative of f in the direction of u=cosθi+sinθj is given by
Let x=a+tcosθ and y=b+tsinθ, and define g(t)=f(x,y). Since fx and fy both exist, and therefore f is differentiable, we can use the chain rule for functions of two variables to calculate g′(t):
If t=0, then x=x0(=a) and y=y0(=b), so
By the definition of g′(t), it is also true that
Therefore, Duf(x0,y0)=fx(x,y)cosθ+fy(x,y)sinθ.
□
Example 4.32
Finding a Directional Derivative: Alternative Method
Let θ=arccos(3/5). Find the directional derivative Duf(x,y) of f(x,y)=x2−xy+3y2 in the direction of u=(cosθ)i+(sinθ)j. What is Duf(−1,2)?
Solution
First, we must calculate the partial derivatives of f:
Then we use Equation 4.37 with θ=arccos(3/5):
To calculate Duf(−1,2), let x=−1 and y=2:
This is the same answer obtained in Example 4.31.
Gradient
The right-hand side of Equation 4.37 is equal to fx(x,y)cosθ+fy(x,y)sinθ, which can be written as the dot product of two vectors. Define the first vector as ∇f(x,y)=fx(x,y)i+fy(x,y)j and the second vector as u=(cosθ)i+(sinθ)j. Then the right-hand side of the equation can be written as the dot product of these two vectors:
The first vector in Equation 4.38 has a special name: the gradient of the function f. The symbol ∇ is called nabla and the vector ∇f is read “delf.”
Definition
Let z=f(x,y) be a function of xandy such that fx and fy exist. The vector ∇f(x,y) is called the gradient of f and is defined as
The vector ∇f(x,y) is also written as “gradf.”
Checkpoint 4.28
Find the directional derivative Duf(x,y) of f(x,y)=3x2y−4xy3+3y2−4x in the direction of u=(cosπ3)i+(sinπ3)j using Equation 4.37. What is Duf(3,4)?
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 4.32 in the direction of the vector 〈−5,12〉, we would first divide by its magnitude to get u. This gives us u=〈−(5/13),12/13〉. Then
Example 4.33
Finding Gradients
Find the gradient ∇f(x,y) of each of the following functions:
- f(x,y)=x2−xy+3y2
- f(x,y)=sin3xcos3y
Solution
For both parts a. and b., we first calculate the partial derivatives fx and fy, then use Equation 4.39.
fx(x,y)=2x−yandfy(x,y)=−x+6y,so∇f(x,y)=fx(x,y)i+fy(x,y)j=(2x−y)i+(−x+6y)j.
fx(x,y)=3cos3xcos3yandfy(x,y)=−3sin3xsin3y,so∇f(x,y)=fx(x,y)i+fy(x,y)j=(3cos3xcos3y)i−(3sin3xsin3y)j.
Checkpoint 4.29
Find the gradient ∇f(x,y) of f(x,y)=(x2−3y2)/(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(x0,y0) and u=(cosθ)i+(sinθ)j is φ, we have
The ‖u‖ disappears because u is a unit vector. Therefore, the directional derivative is equal to the magnitude of the gradient evaluated at (x0,y0) multiplied by cosφ. Recall that cosφ ranges from −1 to 1. If φ=0, then cosφ=1 and ∇f(x0,y0) and u both point in the same direction. If φ=π, then cosφ=−1 and ∇f(x0,y0) and u point in opposite directions. In the first case, the value of Duf(x0,y0) is maximized; in the second case, the value of Duf(x0,y0) is minimized. If ∇f(x0,y0)=0, then Duf(x0,y0)=∇f(x0,y0)·u=0 for any vector u. These three cases are outlined in the following theorem.
Theorem 4.13
Properties of the Gradient
Suppose the function z=f(x,y) is differentiable at (x0,y0) (Figure 4.41).
- If ∇f(x0,y0)=0, then Duf(x0,y0)=0 for any unit vector u.
- If ∇f(x0,y0)≠0, then Duf(x0,y0) is maximized when u points in the same direction as ∇f(x0,y0). The maximum value of Duf(x0,y0) is ‖∇f(x0,y0)‖.
- If ∇f(x0,y0)≠0, then Duf(x0,y0) is minimized when u points in the opposite direction from ∇f(x0,y0). The minimum value of Duf(x0,y0) is −‖∇f(x0,y0)‖.
Example 4.34
Finding a Maximum Directional Derivative
Find the direction for which the directional derivative of f(x,y)=3x2−4xy+2y2 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):
Next, we evaluate the gradient at (−2,3):
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)2+(20)2=√976=4√61. Therefore,
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
for θ. Since cosine is negative and sine is positive, the angle must be in the second quadrant. Therefore, θ=π−arcsin((5√61)/61)≈2.45rad.
The maximum value of the directional derivative at (−2,3) is ‖∇f(−2,3)‖=4√61 (see the following figure).
Checkpoint 4.30
Find the direction for which the directional derivative of g(x,y)=4x−xy+2y2 at (−2,3) is a maximum. What is the maximum value?
Figure 4.43 shows a portion of the graph of the function f(x,y)=3+sinxsiny. Given a point (a,b) in the domain of f, the maximum value of the gradient 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.
When using a topographical map, the steepest slope is always in the direction where the contour lines are closest together (see Figure 4.44). 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.
Gradients and Level Curves
Recall that if a curve is defined parametrically by the function pair then the vector is tangent to the curve for every value of in the domain. Now let’s assume is a differentiable function of and is in its domain. Let’s suppose further that and for some value of and consider the level curve Define and calculate on the level curve. By the chain Rule,
But because for all Therefore, on the one hand,
on the other hand,
Therefore,
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.
Theorem 4.14
Gradient Is Normal to the Level Curve
Suppose the function has continuous first-order partial derivatives in an open disk centered at a point If then is normal to the level curve of at
We can use this theorem to find tangent and normal vectors to level curves of a function.
Example 4.35
Finding Tangents to Level Curves
For the function find a tangent vector to the level curve at point Graph the level curve corresponding to and draw in and a tangent vector.
Solution
First, we must calculate
Next, we evaluate at
This vector is orthogonal to the curve at point We can obtain a tangent vector by reversing the components and multiplying either one by Thus, for example, is a tangent vector (see the following graph).
Checkpoint 4.31
For the function find the tangent to the level curve at point Draw the graph of the level curve corresponding to and draw and a tangent vector.
Three-Dimensional Gradients and Directional Derivatives
The definition of a gradient can be extended to functions of more than two variables.
Definition
Let be a function of three variables such that exist. The vector is called the gradient of and is defined as
can also be written as
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 and and then we use Equation 4.40.
Example 4.36
Finding Gradients in Three Dimensions
Find the gradient of each of the following functions:
Solution
For both parts a. and b., we first calculate the partial derivatives and then use Equation 4.40.
Checkpoint 4.32
Find the gradient of
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 in standard form (i.e., the initial point is at the origin), this vector forms three different angles with the positive and z-axes. Let’s call these angles and Then the directional cosines are given by and These are the components of the unit vector since is a unit vector, it is true that
Definition
Suppose is a function of three variables with a domain of Let and let be a unit vector. Then, the directional derivative of in the direction of is given by
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 4.38.
Theorem 4.15
Directional Derivative of a Function of Three Variables
Let be a differentiable function of three variables and let be a unit vector. Then, the directional derivative of in the direction of is given by
The three angles determine the unit vector In practice, we can use an arbitrary (nonunit) vector, then divide by its magnitude to obtain a unit vector in the desired direction.
Example 4.37
Finding a Directional Derivative in Three Dimensions
Calculate in the direction of for the function
Solution
First, we find the magnitude of
Therefore, is a unit vector in the direction of so Next, we calculate the partial derivatives of
then substitute them into Equation 4.42:
Last, to find we substitute
Checkpoint 4.33
Calculate and in the direction of for the function
Section 4.6 Exercises
For the following exercises, find the directional derivative using the limit definition only.
at point in the direction of
Find the directional derivative of at point in the direction of
For the following exercises, find the directional derivative of the function at point in the direction of or as appropriate.
For the following exercises, find the directional derivative of the function in the direction of the unit vector
For the following exercises, find the gradient.
Find the gradient of Then, find the gradient at point
Find the gradient of at and the directional derivative in the direction of
For the following exercises, find the directional derivative of the function at point in the direction of
For the following exercises, find the derivative of the function at in the direction of
[T] Use technology to sketch the level curve of that passes through and draw the gradient vector at
[T] Use technology to sketch the level curve of that passes through and draw the gradient vector at
For the following exercises, find the gradient vector at the indicated point.
For the following exercises, find the derivative of the function.
at point in the direction the function increases most rapidly
at point in the direction the function increases most rapidly
at point in the direction the function increases most rapidly
For the following exercises, find the maximum rate of change of at the given point and the direction in which it occurs.
For the following exercises, find equations of
- the tangent plane and
- the normal line to the given surface at the given point.
The level surface for at point
at point
For the following exercises, solve the problem.
The temperature in a metal sphere is inversely proportional to the distance from the center of the sphere (the origin: The temperature at point is
- Find the rate of change of the temperature at point in the direction toward point
- Show that, at any point in the sphere, the direction of greatest increase in temperature is given by a vector that points toward the origin.
The electrical potential (voltage) in a certain region of space is given by the function
- Find the rate of change of the voltage at point in the direction of the vector
- In which direction does the voltage change most rapidly at point
- What is the maximum rate of change of the voltage at point
If the electric potential at a point in the xy-plane is then the electric intensity vector at is
- Find the electric intensity vector at
- Show that, at each point in the plane, the electric potential decreases most rapidly in the direction of the vector
In two dimensions, the motion of an ideal fluid is governed by a velocity potential The velocity components of the fluid in the x-direction and in the y-direction, are given by Find the velocity components associated with the velocity potential