Learning Objectives
- 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.
The right-hand side of the Directional Derivative of a Function of Two Variables 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:
Duf(x,y)=∇f(x,y)⋅u.
The first vector in the previous equation has a special name: the gradient of the function f. The symbol ∇ is called nabla and the vector ∇f is read “del f“.
Definition
Let z=f(x,y) be a function of x and x such that fx and fy exist. The vector ∇f(x,y) is called the gradient of f and is defined as
∇f(x,y)=fx(x,y)i+fy(x,y)j.
The vector ∇f(x,y) is also written as “grad f“.
Example: finding gradients
Find the gradient ∇f(x,y) of each of the following functions:
a. f(x,y)=x2−xy+3y2
b. f(x,y)=sin3xcos3y
Show Solution
For both parts a. and b., we first calculate the partial derivatives fx and fy, then use the gradient of f.
a.
fx(x,y)=2x−y and fx(x,y)=−x+6y, so∇f(x,y)=fx(x,y)i+fy(x,y)j=(2x−y)i+(−x+6y)j.
b.
fx(x,y)=3cos3xcos3y and fx(x,y)=−3sin3xsin3y, so∇f(x,y)=fx(x,y)i+fy(x,y)j=(3cos3xcos3y)i−(3sin3xsin3y)j.
Try it
Find the gradient ∇f(x,y) of f(x,y)=(x2−3y2)/(2x+y).
Show Solution
∇f(x,y)=2x2+2xy+6y2(2x+y)2i−x2+12xy+3y2(2x+y)2j
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
Duf(x0,y0)=∇f(x0,y0)⋅u=∥∇f(x0,y0)∥∥u∥cosφ=∥∇f(x0,y0)∥cosφ
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 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 cases are outlined in the following theorem.
Theorem: properties of the gradient
Suppose the function z=f(x,y) is differentiable at (x0,y0) (Figure 3).
i. If ∇f(x0,y0)=0, then Duf(x0,y0)=0 for any unit vector u.
ii. 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)∥.
iii. 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)∥.
Figure 1. The gradient indicates the maximum and minimum values of the directional derivative at a point.
Example: 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?
Show 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)+3(3))j=−24i+20j.
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,
∇f(−2,3)∥∇f(−2,3)∥=−244√61i+204√61j=−6√6161i+5√6161j.
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
cosθ=−6√6161 and sinθ=5√6161.
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 (see the following figure).
Figure 2. The maximum value of the directional derivative at (−2,3) is in the direction of the gradient.
Try it
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?
Show Solution
The gradient of g at (−2,3) is ∇g(−2,3)=i+14j. The unit vector that points in the same direction as ∇g(−2,3) is ∇g(−2,3)∥∇g(−2,3)∥=1√197i+14√197j=√197197i+14√197197j, which gives an angle of θ=arcsin((14√197)/197≈1.499 rad. The maximum value of the directional derivative is ∇g(−2,3)≈√197.
Watch the following video to see the worked solution to the above Try It
.
Figure 5 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.
Figure 3. A typical surface in R3. Given a point on the surface, the directional derivative can be calculated using the gradient.
When using a topographical map, the steepest slope is always in the direction where the contour lines are closest together (see Figure 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 4. Contour map for the function f(x,y)=x2−y2 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 (x0,y0) is in its domain. Let’s suppose further that x0=x(t0) and y0=y(t0) for some value of t, and consider the level curve f(x,y)=k. Define 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).
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;
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)⟩.
Therefore,
∇f(x,y)⋅⟨x′(t),y′(t)⟩=0.
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: 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(x0,y0) is normal to the level curve of f at (x0,y0).
We can use this theorem to find tangent and normal vectors to level curves of a function.
Example: Finding Tangents to level curves
For the function f(x,y)=2x2−3xy+8y2+2x−4y+4, find a tangent vector to the level curve at point (−2,1). Graph the level curve corresponding to f(x,y)=18 and draw in ∇f(−2,1) and a tangent vector.
Show 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=−9i+18j.
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, −18i−9j is a tangent vector (see the following graph).
Figure 5. A rotated ellipse with equation f(x,y)=18. At the point (−2,1) on the ellipse, there are drawn two arrows, one tangent vector and one normal vector. The normal vector is marked ∇f(−2,1) and is perpendicular to the tangent vector.
Try it
For the function f(x,y)=x2−2xy+5y2+3x−2y+4, find the tangent to the level curve at point (1,1). Draw the graph of the level curve corresponding to f(x,y)=8 and draw ∇f(1,1) and a tangent vector.
Show Solution
∇f(x,y)=(2x−2y+3)i+(−2x+10y−2)j
∇f(1,1)=3i+6j
Tangent vector: 6i−6j or −6i+3j
Figure 6.
Candela Citations
CC licensed content, Original
CC licensed content, Shared previously