Suppose that you are hiking in rugged terrain. You can think of your altitude at the point given by longitude x and latitude y as defining a function f (x, y) . This is obviously not a function you would be likely to have a handy formula for, but you can learn more about this function than you might expect. Observe that if you face due east, the slope of the terrain (which you could measure) is given by the partial derivative . Similarly, facing due north, the slope of the terrain is given by . However, in terms of f (x, y) , how would you compute the slope in some other direction, say north-by-northwest? In this section, we develop the notion of directional derivative, which will answer this question.

Suppose we want to find the instantaneous rate of change of f (x, y) at the point P(a, b) and in the direction given by the unit vector . Let Q(x, y) be any point on the line through P(a, b) in the direction of u. Notice that the vector is then parallel to u. We know that two vectors are parallel if and only if one is a scalar multiple of the other, in which case, for some scalar h. This says that

Remember that two vectors are equal only when all of their components are the same. We must then have
 x = a+hu1       and      y = b+hu2,
so that the point Q is described by (a+hu1, b+hu2) , as indicated in Figure 12.33.

Figure 12.33
The vector

Notice that we can write the average rate of change of z = f (x, y) along the line from P to Q as
The instantaneous rate of change of f (x, y) at the point P(a, b) and in the direction of the unit vector u is then found by taking the limit as h 0. We give this limit a special name in the following definition.

 6.1

The directional derivative of f (x, y) at the point (a, b) and in the direction of the unit vector is given by
provided the limit exists.

Notice that this limit resembles the definition of partial derivative, except that in this case, both variables may change. Further, you should observe that the directional derivative in the direction of the positive x - axis (i.e., in the direction of the unit vector u = 1, 0) is
which you should recognize as the partial derivative . Likewise, the directional deriva-tive in the direction of the positive y - axis (i.e., in the direction of the unit vector ) is In fact, it turns out that any directional derivative can be calculated simply, in terms of the first partial derivatives, as we see in the following theorem.

 6.1

Suppose that f  is differentiable at (a, b) and u = u1, u2 is any unit vector. Then, we can write
 Duf (a, b) = f x(a, b)u1+f y(a, b)u2.

Let g(h) = f (a+hu1, b+hu2). Then, g(0) = f (a, b) and so, from Definition 6.1, we have

If we define x = a+hu1 and y = b+hu2, we have g(h) = f (x, y). From the chain rule (Theorem 5.1), we have

Finally, taking h = 0 gives us

as desired.

 6.1
Computing Directional Derivatives

For f (x, y) = x2y-4y3 , compute Duf (2, 1) for the directions (a) and (b) u in the direction from (2, 1) to (4, 0) .

Regardless of the direction, we first need to compute the first partial deri-vatives and . Then fx(2, 1) = 4 and fy(2, 1) = -8. For (a), the unit vector is given as and so, from Theorem 6.1 we have
In particular, notice that this says that the function is decreasing in this direction.

For (b), we must first find the unit vector u in the indicated direction. Observe that the vector from (2, 1) to (4, 0) corresponds to the position vector and so, the unit vector in that direction is . We then have from Theorem 6.1 that

Notice that this says that the function is increasing rapidly in this direction.

 For convenience, we define the gradient of a function to be the vector-valued function whose components are the first-order partial derivatives of f  . We denote the gradient of a function f  by grad f  or f  (read “del f  '').

 6.2

The gradient of f (x, y) is the vector-valued function
provided both partial derivatives exist.

Observe that, using the gradient, we can write a directional derivative as the dot product of the gradient and the unit vector in the direction of interest, as follows. For any unit vector ,
We state this result in the following theorem.

 6.2

If f  is a differentiable function of x and y and u is any unit vector, then
 Du f (x, y) = f (x, y) u.

 Theorem 6.2 makes it easy to compute directional derivatives. Further, writing directional derivatives as a dot product has many important consequences, one of which we see in the following example.

 6.2
Finding Directional Derivatives

For f (x, y) = x2+y2 , find Duf (1, -1) for (a) u in the direction of and (b) u in the direction of .

First, note that
At the point (1, -1) , we have . For (a), a unit vector in the same direction as v is . The directional derivative in this direction is then
For (b), the unit vector is and so, the directional derivative in this direction is

 A graphical interpretation of the directional derivatives in example 6.2 is given below. Suppose we intersect the surface z = f (x, y) with a plane passing through the point (1, -1, 2), which is perpendicular to the xy - plane and parallel to the vector u (see Figure 12.34a). Notice that the intersection is a curve in two dimensions. Sketch this curve on a new set of coordinate axes, chosen so that the new origin corresponds to the point (1, -1, 2) , the new vertical axis is in the z - direction and the new positive horizontal axis points in the direction of the vector u . In Figure 12.34b, we show the case for and in Figure 12.34c, we show the case for . In each case, the directional derivative gives the slope of the curve at the origin (in the new coordinate system). Notice that the direction vectors in example 6.2 parts (a) and (b) differ only by sign and the resulting curves in Figures 12.34b and 12.34c are exact mirror images of each other. Figure 12.34a Intersection of surface with plane. Figure 12.34b u = -, Figure 12.34c u = , - Another way of viewing the directional derivative graphically is with level curves.

 6.3
Directional Derivatives and Level Curves

Use a contour plot of z = x2+y2 to estimate Duf (1, -1) for

A contour plot of z = x2+y2 is shown in Figure 12.35 with the direction vector sketched in with its initial point located at the point (1, -1) . The level curves shown correspond to z = 0.2, 0.5, 1, 2 and 3. From the graph, you can approxi-mate the directional derivative by estimating , where u is the distance traveled along the unit vector u. For the unit vector shown, u = 1 . Further, the vector appears to extend from the z = 2 level curve to the z = 0.2 level curve. In this case, z = 0.2-2 = -1.8 and our estimate of the directional derivative is . Compared to the actual directional derivative of - = -2.8 (found in example 6.2), this is not very accurate. A better estimate could be obtained with a smaller u . For example, to get from the z = 2 level curve to the z = 1 level curve, it appears that we travel along about 40% of the unit vector. Then . You could continue this process by drawing more level curves, corresponding to values of z closer to z = 2.

Figure 12.35
Contour plot of z = x2+y2 .

Keep in mind that the directional derivative gives the rate of change of a function in a given direction. In this case, it's reasonable to ask in what direction a given function has its maximum or minimum rate of increase. In order to answer such questions, you must first recall from Theorem 3.2 in Chapter 10 that for any two vectors a and b, we have , where is the angle between the vectors a and b. Applying this to the form of the directional derivative given in Theorem 6.2, we have
where is the angle between the gradient vector at (a, b) and the direction vector u .

Notice now that the maximum value of occurs when = 0, so that cos = 1 . The directional derivative is then . Further, observe that the angle = 0 when f (a, b) and u are in the same direction, so that . Similarly, the minimum value of the directional derivative occurs when = , so that cos = -1 . In this case, f (a, b) and u have opposite directions, so that . Finally, observe that when u is perpendicular to f (a, b) and the directional derivative in this direction is zero. Since the level curves are curves in the xy - plane on which f  is constant, notice that a zero directional derivative at a point indicates that u is tangent to a level curve. We summarize these observations in the following theorem.

 6.3

Suppose that f  is a differentiable function of x and y at the point (a, b) . Then
 (i) the maximum rate of change of f  at (a, b) is and occurs in the direction of the gradient, ; (ii) the minimum rate of change of f  at (a, b) is and occurs in the direction opposite the gradient, and (iii) the gradient f (a, b) is orthogonal to the level curve f (x, y) = c at the point (a, b) , where c = f (a, b) .

 In using Theorem 6.3, remember that the directional derivative corresponds to the rate of change of the function f (x, y) in the given direction.

 6.4
Finding Maximum and Minimum Rates of Change

Find the maximum and minimum rates of change of the function f (x, y) = x2+y2 at the point (1, 3) .

We first compute the gradient and evaluate it at the point (1, 3) : . From Theorem 6.3, the maximum rate of change of f  at (1, 3) is , and occurs in the direction
Similarly, the minimum rate of change is , which occurs in the direction

 Notice that the direction of maximum increase in example 6.3 points away from the origin, since the displacement vector from (0, 0) to (1, 3) is parallel to . This should make sense given the familiar shape of the paraboloid. The contour plot of f (x, y) shown in Figure 12.36 indicates that the gradient is perpendicular to the level curves. We expand on this idea in the following example. Figure 12.36 Contour plot of z = x2+y2 .

 6.5
Finding the Direction of Steepest Ascent

The contour plot of f (x, y) = 3x-x3-3xy2 shown in Figure 12.37 indicates several level curves near a relative maximum at (1, 0) . Find the direction of maximum increase from the point A(0.6, -0.7) and sketch in the path of steepest ascent.

Figure 12.37
Contour plot of z = 3x-x3-3xy2 .

From Theorem 6.3, the direction of maximum increase at (0.6, -0.7) is given by the gradient f (0.6, -0.7) . We have f = 3-3x2-3y2, -6xy and so, f (0.6, -0.7) = 0.45, 2.52. The unit vector in this direction is then u = 0.176, 0.984 . A vector in this direction (not drawn to scale) at the point (0.6, -0.7) is shown in Figure 12.38a. Notice that this vector does not point to the maximum at (1, 0) . (By analogy, on a mountain, the steepest path from a given point will not always point to the actual peak.) The path of steepest ascent is a curve that remains perpendicular to each level curve it passes through. Notice that at the tip of the vector drawn in Figure 12.38a, the vector is no longer perpendicular to the level curve. Finding an equation for the path of steepest ascent is difficult. In Figure 12.38b, we sketch in a plausible steepest curve.

Figure 12.38a
Direction of steepest ascent at (0.6, -0.7).

Figure 12.38b
Path of steepest ascent.

 Most of the results of this section extend easily to functions of any number of variables.

 6.3

The directional derivative of f (x, y, z) at the point (a, b, c) in the direction of the unit vector is given by
provided the limit exists.

The gradient of f (x, y, z) is the vector-valued function

provided all the partial derivatives are defined.

 As was the case for functions of two variables, the gradient gives us a simple representation of directional derivatives in three dimensions.

 6.4

If f  is a differentiable function of x, y and z and u is any unit vector, then
 Duf (x, y, z) = f (x, y, z) u.
(6.1)

As in two dimensions, we have that
where is the angle between the vectors f (x, y, z) and u. For precisely the same reasons as in two dimensions, you can now see that the direction of maximum increase at any given point is given by the gradient at that point.

 6.6
Finding the Direction of Maximum Increase

If the temperature at point (x, y, z) is given by find the direction from the point (2, 0, 99) in which the temperature increases most rapidly.

and To find a unit vector in this direction, you can simplify the algebra by canceling the common factor of e-4 (think about why this makes sense) and multiplying by 100. A unit vector in the direction of -4, 0, -1, and also in the direction of f (2, 0, 99), is then

Recall that for any constant k, the equation f (x, y, z) = k defines a level surface of the function f (x, y, z). Now, suppose that u is any unit vector lying in the tangent plane to the level surface f (x, y, z) = k at a point (a, b, c) on the level surface. Then, it follows that the rate of change of f  in the direction of u at (a, b, c) [given by the directional derivative Du f (a, b, c) ] is zero, since f  is constant on a level surface. From (6.1), we now have that
 0 = Du f (a, b, c) = f (a, b, c) u.
This occurs only when the vectors f (a, b, c) and u are orthogonal. Since u was taken to be any vector lying in the tangent plane, we now have that f (a, b, c) is orthogonal to every vector lying in the tangent plane at the point (a, b, c). Observe that this says that f (a, b, c) is a normal vector to the tangent plane to the surface f (x, y, z) = k at the point (a, b, c). This proves the following theorem.

 6.5

Suppose that f (x, y, z ) has continuous partial derivatives at the point (a, b, c). Then, f (a, b, c) is a normal vector to the tangent plane to the surface f (x, y, z) = k, at the point (a, b, c). Further, the equation of the tangent plane is
 0 = f x(a, b, c)(x-a)+f y(a, b, c)(y-b)+f z(a, b, c)(z-c).

We refer to the line through (a, b, c) in the direction of f (a, b, c) as the normal line to the surface at the point (a, b, c). Observe that this has equations
 x = a+f x(a, b, c)t,       y = b+f y(a, b, c)t,       z = c+f z(a, b, c)t.

In the following example, we illustrate the use of the gradient at a point to find the tangent plane to a surface at that point.

 6.7
Using a Gradient to Find a Tangent Plane and Normal Line to a Surface

Find an equation of the tangent plane to x3y-y2+z2 = 7 at the point (1, 2, 3).

If we interpret the surface as a level surface of the function f (x, y, z) = x3y-y2+z2, a normal vector to the tangent plane at the point (1, 2, 3) is given by f (1, 2, 3). We have f = 3x2y, x3-2y, 2z and Given the normal vector 6, -3, 6 and point (1, 2, 3), an equation of the tangent plane is
 6(x-1)-3(y-2)+6(z-3) = 0.
The normal line has equations
 x = 1+6t,       y = 2-3t,       z = 3+6t.

Recall that in section 12.4, we found that a normal vector to the tangent plane to the surface z = f (x, y) at the point (a, b, f (a, b)) is given by Note that this is simply a special case of the gradient formula of example 6.7, as follows. First, observe that we can rewrite the equation z = f (x, y) as f (x, y)-z = 0. We can then think of this surface as a level surface of the function g(x, y, z) = f (x, y)-z, which at the point (a, b, f (a, b)) has normal vector

 Just as it is important to constantly think of ordinary derivatives as slopes of tangent lines and as instantaneous rates of change, it is crucial to keep in mind at all times the interpretations of gradients. Always think of gradients as vector-valued functions whose values specify the direction of maximum increase of a function and whose values provide normal vectors (to the level curves in two dimensions and to the level surfaces in three dimensions).

 6.8
Using a Gradient to Find a Tangent Plane to a Surface

Find an equation of the tangent plane to z = sin(x+y) at the point (, , 0).

We rewrite the equation of the surface as g(x, y, z) = sin(x+y) - z = 0 and compute At the point (, , 0), the normal to the surface is given by An equation of the tangent plane is then
 (x-)+(y-)-z = 0.