Gradient

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)=x2xy+3y2

b. f(x,y)=sin3xcos3y

Try it

Find the gradient f(x,y) of f(x,y)=(x23y2)/(2x+y).

Try It

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 ab=abcosφ. 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)ucosφ=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).

An upward facing paraboloid in xyz space with point P0 (x0, y0, z0). From this point, there are arrows going up, down, and around the paraboloid. On the xy plane, the point (x0, y0) is marked, and the corresponding arrows are drawn onto the plane: the down arrow corresponds to −∇f (most rapid decrease in f), the up arrow corresponds to ∇f (most rapid increase in f), and the arrows around correspond to no change in f. The up/down arrows are perpendicular to the around arrows in their projection on the plane.

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)=3x24xy+2y2 at (2,3) is a maximum. What is the maximum value?

Try it

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

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.

An surface in xyz space with point at f(a, b). There is an arrow in the direction 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.

Two crossing dashed lines that pass through the origin and a series of curved lines approaching the crosses dashed lines as if they are asymptotes.

Figure 4. Contour map for the function f(x,y)=x2y2 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)=2x23xy+8y2+2x4y+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.

Try it

For the function f(x,y)=x22xy+5y2+3x2y+4find 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.