← Chapter 4 §4.6 Directional Derivatives and the Gradient 方向导数与梯度 · Chapter 4 · Differentiation of Functions of Several Variables

Calculus Volume 3 · Chapter 4 · Section 4.6

Directional Derivatives and the Gradient

Stand on a hill and turn around: every direction has its own slope. One vector predicts them all.

Colour key ∇f gradient u direction level curve, tangent slope, surface key idea · round handles can be dragged · 3D figures turn · page links open the textbook

Level 1 · see itSlopes in every directionbefore any formula

Which way is uphill?

Stand on the hill z=3+sinxsinyz=3+\sin x\sin y at (π4,π4)(\tfrac\pi4,\tfrac\pi4) (Figure 4.43). Walk east: slope 0.5. Walk north-east: 0.71. Walk south-east: 0.

0.71 cos φ

Every direction has its own slope, but one vector, ⟨0.5, 0.5⟩, predicts all of them: the gradient.

Height drawn from z=3z=3. Walking direction, the step on the surface, ∇f in the floor.

Turn the compass

  1. A direction is a unit vector u=cosθ,sinθ\mathbf u=\langle\cos\theta,\sin\theta\rangle (p374).
  2. The slope that way is the directional derivative DufD_{\mathbf u}f. East gives fxf_x, north gives fyf_y.
  3. It is a dot product: Duf=fu=fcosφD_{\mathbf u}f=\nabla f\cdot\mathbf u=\|\nabla f\|\cos\varphi. Turn u and the slope follows a cosine.

Drag the blue handle round the circle.

Contours of 3+sinxsiny3+\sin x\sin y; the point (π4,π4)(\tfrac\pi4,\tfrac\pi4) sits on the level 3.5.

The gradient points uphill

Draw f\nabla f at many points of a contour map (Figure 4.44):

  • every arrow crosses its contour at a right angle;
  • arrows are longest where contours crowd — the steep ground;
  • arrows vanish at peaks, pits and passes.

A hiker who always walks along ∇f climbs as fast as the hill allows.

One picture

Along ∇f: fastest increase, ‖∇f‖. Against it: fastest decrease, −‖∇f‖. Along the level curve: no change. (Figure 4.41)

The gradient is the uphill arrow; every other slope is its shadow.

Level 2 · compute itFormulas, examples, four labstwo and three variables

Directional derivative and gradient

Definition · (4.36) Duf(a,b)=limh0f(a+hcosθ, b+hsinθ)f(a,b)h D_{\mathbf u}f(a,b)=\lim_{h\to0}\frac{f(a+h\cos\theta,\ b+h\sin\theta)-f(a,b)}{h}

The slope of the secant, then the limit — as for ff'.

Theorem 4.12 · (4.37) Duf(x,y)=fx(x,y)cosθ+fy(x,y)sinθ D_{\mathbf u}f(x,y)=f_x(x,y)\cos\theta+f_y(x,y)\sin\theta

For differentiable ff: no limit needed.

Gradient · (4.39) f(x,y)=fx(x,y)i+fy(x,y)j \nabla f(x,y)=f_x(x,y)\,\mathbf i+f_y(x,y)\,\mathbf j

Read "del f" or "grad f".

As a dot product · (4.38) Duf=fu D_{\mathbf u}f=\nabla f\cdot\mathbf u

u must be a unit vector: divide a given vector by its length first (p378).

Two partial derivatives, packed into one vector, answer the slope question for every direction at once.

Steepest ascent and level curves

Theorem 4.13 (p378) and Theorem 4.14 (p381).

at a point wherethenbecause
f0\nabla f\ne\mathbf 0, u along f\nabla fDufD_{\mathbf u}f is largest: f\|\nabla f\|cos0=1\cos 0=1
f0\nabla f\ne\mathbf 0, u against f\nabla fDufD_{\mathbf u}f is smallest: f-\|\nabla f\|cosπ=1\cos\pi=-1
u along the level curveDuf=0D_{\mathbf u}f=0cosπ2=0\cos\tfrac\pi2=0
f=0\nabla f=\mathbf 0Duf=0D_{\mathbf u}f=0 for every ua flat spot: peak, pit or pass
f0\nabla f\ne\mathbf 0, continuous partialsf\nabla f is normal to the level curveff does not change along it

A tangent to the level curve: swap the components of f\nabla f and change one sign.

Three variables

Gradient · (4.40) f=fxi+fyj+fzk \nabla f=f_x\,\mathbf i+f_y\,\mathbf j+f_z\,\mathbf k
Theorem 4.15 · (4.42) Duf=fu=fxcosα+fycosβ+fzcosγ D_{\mathbf u}f=\nabla f\cdot\mathbf u=f_x\cos\alpha+f_y\cos\beta+f_z\cos\gamma

cosα,cosβ,cosγ\cos\alpha,\cos\beta,\cos\gamma: the direction cosines of u (§2.3).

Nothing new: one more component. And f\nabla f is normal to the level surface f(x,y,z)=cf(x,y,z)=c — which gives tangent planes (Lab 4).

Examples 4.31–4.37

Examplegivenresult
4.31 · p375f=x2xy+3y2f=x^2-xy+3y^2, θ=arccos35\theta=\arccos\tfrac35, by the limitDuf=2x+21y5D_{\mathbf u}f=\frac{2x+21y}{5}; at (1,2)(-1,2): 8
4.32 · p377the same, by Theorem 4.12fx=2xyf_x=2x-y, fy=x+6yf_y=-x+6y; again 8
p378 · p378the same ff, along 5,12\langle -5,12\rangleu=513,1213\mathbf u=\langle-\tfrac5{13},\tfrac{12}{13}\rangle; Duf=22x+77y13D_{\mathbf u}f=\frac{-22x+77y}{13}*
4.33 · p378(a) x2xy+3y2x^2-xy+3y^2; (b) sin3xcos3y\sin3x\cos3y(a) (2xy)i+(x+6y)j(2x-y)\mathbf i+(-x+6y)\mathbf j; (b) 3cos3xcos3yi3sin3xsin3yj3\cos3x\cos3y\,\mathbf i-3\sin3x\sin3y\,\mathbf j
4.34 · p3793x24xy+2y23x^2-4xy+2y^2 at (2,3)(-2,3): steepest wayf=24,20\nabla f=\langle-24,20\rangle; max 46131.244\sqrt{61}\approx31.24 at θ2.45\theta\approx2.45 rad
4.35 · p3812x23xy+8y2+2x4y+42x^2-3xy+8y^2+2x-4y+4 at (2,1)(-2,1)level 18; f=9,18\nabla f=\langle-9,18\rangle; tangent 18,9\langle-18,-9\rangle
4.36 · p382(a) 5x22xy+y24yz+z2+3xz5x^2-2xy+y^2-4yz+z^2+3xz10x2y+3z, 2x+2y4z, 3x4y+2z\langle 10x-2y+3z,\ -2x+2y-4z,\ 3x-4y+2z\rangle
(b) e2zsin2xcos2ye^{-2z}\sin2x\cos2y2e2zcos2xcos2y, sin2xsin2y, sin2xcos2y2e^{-2z}\langle\cos2x\cos2y,\ -\sin2x\sin2y,\ -\sin2x\cos2y\rangle
4.37 · p3834.36(a) at (1,2,3)(1,-2,3) along 1,2,2\langle-1,2,2\ranglev=3\|\mathbf v\|=3, f=23,18,17\nabla f=\langle23,-18,17\rangle; Duf=253D_{\mathbf u}f=-\tfrac{25}3

* The book prints 2213x+1713y-\tfrac{22}{13}x+\tfrac{17}{13}y; the yy-coefficient is 5(1)+12613=7713\tfrac{-5\cdot(-1)+12\cdot 6}{13}=\tfrac{77}{13}.

Lab 1 · the direction dial

function
53.13°
Drag the point. Contours are spaced evenly in height.

Try: Ex 4.32 at 53.13° gives 8. Press point u along ∇f: the slope jumps to ‖∇f‖. Turn 90° further: 0.

Lab 2 · gradient field and level curves

function
Drag the point. Arrows in the field are scaled down to fit; the direction is exact.

Try: Ex 4.35 at (2,1)(-2,1): the level 18 ellipse, normal 9,18\langle-9,18\rangle. x² − y² at the origin: f=0\nabla f=\mathbf 0, no arrow, and the level curve is two crossing lines.

Lab 3 · climbing the surface

surface
−1.2 −0.6
Blue: the direction in the floor. Amber: the matching step along the surface. Red: ∇f. Dashed: the steepest path.

Try: turn u until the amber arrow climbs most steeply — it lines up over the red arrow. The steepest path crosses every floor contour at a right angle.

Lab 4 · normal to a level surface

f(x,y,z)=x2+2y2+3z2f(x,y,z)=x^2+2y^2+3z^2. Each level f=cf=c is an ellipsoid; f=2x,4y,6z\nabla f=\langle 2x,4y,6z\rangle sticks straight out of it.

6 45° 54.74°
∇f drawn at a third of its length.

At (1,1,1)(1,1,1), level 6: f=2,4,6\nabla f=\langle2,4,6\rangle, tangent plane x+2y+3z=6x+2y+3z=6 — the same method as Exercises 302–305.

Common mistakes

MistakeResultFix
Dotting with 5,12\langle-5,12\rangle itself176 at (1,2)(-1,2), not 1761313.54\tfrac{176}{13}\approx13.54divide by the length first
Giving f\nabla f as the maximum rate"24,20\langle-24,20\rangle" in Example 4.34the rate is a number: f=461\|\nabla f\|=4\sqrt{61}
θ=arcsin561\theta=\arcsin\tfrac{5}{\sqrt{61}} alone0.69 rad: the wrong quadrantcosθ<0\cos\theta<0, so θ=π0.692.45\theta=\pi-0.69\approx2.45
Swapping components without a sign change18,9\langle18,-9\rangle is not tangent in Example 4.3518,9\langle-18,-9\rangle: its dot with f\nabla f is 0
Calling 9,18\langle-9,18\rangle the tangenta vector across the level curvef\nabla f is the normal; the tangent is perpendicular to it
Reading ∇f as a vector on the surfacean arrow in space∇f of f(x,y)f(x,y) lives in the xyxy-plane

Practice and answers

Exercises from p384; the book's key: p863864, p869870.

Checkpoints 4.28–4.33
#taskanswer
4.283x2y4xy3+3y24x3x^2y-4xy^3+3y^2-4x, θ=π3\theta=\tfrac\pi3, at (3,4)(3,4)9452532548.66-94-\tfrac{525\sqrt3}{2}\approx-548.66
4.29x23y22x+y\nabla\dfrac{x^2-3y^2}{2x+y}2x2+2xy+6y2(2x+y)2ix2+12xy+3y2(2x+y)2j\dfrac{2x^2+2xy+6y^2}{(2x+y)^2}\mathbf i-\dfrac{x^2+12xy+3y^2}{(2x+y)^2}\mathbf j
4.304xxy+2y24x-xy+2y^2 at (2,3)(-2,3): steepest wayg=i+14j\nabla g=\mathbf i+14\mathbf j; max 197\sqrt{197} at θ1.499\theta\approx1.499 rad
4.31x22xy+5y2+3x2y+4x^2-2xy+5y^2+3x-2y+4 at (1,1)(1,1)f=3i+6j\nabla f=3\mathbf i+6\mathbf j; tangent 6i3j6\mathbf i-3\mathbf j (level 9*)
4.32x23y2+z22x+y4z\nabla\dfrac{x^2-3y^2+z^2}{2x+y-4z}2x2+2xy+6y28xz2z2, (x2+12xy+3y224yz+z2), 4x212y24z2+4xz+2yz(2x+y4z)2\dfrac{\langle 2x^2+2xy+6y^2-8xz-2z^2,\ -(x^2+12xy+3y^2-24yz+z^2),\ 4x^2-12y^2-4z^2+4xz+2yz\rangle}{(2x+y-4z)^2}
4.333x2+xy2y2+4yzz2+2xz3x^2+xy-2y^2+4yz-z^2+2xz along 3,12,4\langle-3,12,-4\rangle, at (0,2,5)(0,-2,5)38413\tfrac{384}{13}

* The key's graph labels the curve f=8f=8; f(1,1)=9f(1,1)=9.

Exercises
#taskanswerkey step
261y2cos2xy^2\cos2x at (π3,2)(\tfrac\pi3,2), θ=π4\theta=\tfrac\pi4262-2\sqrt6-\sqrt2f=43,2\nabla f=\langle-4\sqrt3,-2\rangle
263xyxy at (0,2)(0,-2)1-1f=2,0\nabla f=\langle-2,0\rangle
265xyzxyz at (2,1,1)(2,1,1) along 2,1,1\langle2,1,-1\rangle26\tfrac{2}{\sqrt6}normalize
267x2y2x^2-y^2 at (1,0)(1,0)3\sqrt3f=2,0\nabla f=\langle2,0\rangle
269excosye^x\cos y at (0,π2)(0,\tfrac\pi2), u=0,1\mathbf u=\langle0,1\rangle1-1just fyf_y
271ln(x2+y2)\ln(x^2+y^2) at (1,2)(1,2)2225\tfrac{22}{25}f=25,45\nabla f=\langle\tfrac25,\tfrac45\rangle
273y2+xzy^2+xz at (1,2,2)(1,2,2) along 2,1,2\langle2,-1,2\rangle23\tfrac23v=3\|\mathbf v\|=3
275yx+2y\tfrac{y}{x+2y}, θ=π4\theta=-\tfrac\pi42(x+y)2(x+2y)2-\dfrac{\sqrt2(x+y)}{2(x+2y)^2}quotient rule
277yexye^x, θ=π3\theta=\tfrac\pi3ex(y+3)2\tfrac{e^x(y+\sqrt3)}{2}
279ln(x+2y)\ln(x+2y), θ=π3\theta=\tfrac\pi31+232(x+2y)\dfrac{1+2\sqrt3}{2(x+2y)}
281xy+yz+xzxy+yz+xz at (1,2,3)(1,2,3)5,4,3\langle5,4,3\rangley+z,x+z,x+y\langle y+z,x+z,x+y\rangle
2834x5y2z34x^5y^2z^3 at (2,1,1)(2,-1,1)320-320f=320,256,384\nabla f=\langle320,-256,384\rangle
285yx+z\tfrac{y}{x+z}, P(2,1,1)P(2,1,-1) toward Q(1,2,0)Q(-1,2,0)311\tfrac{3}{\sqrt{11}}PQ=3,1,1\overrightarrow{PQ}=\langle-3,1,1\rangle
287ln(5x+4y)\ln(5x+4y) at (3,9)(3,9) along 6i+8j6\mathbf i+8\mathbf j31255\tfrac{31}{255}u=35,45\mathbf u=\langle\tfrac35,\tfrac45\rangle
289level curve of x2+4y2x^2+4y^2 through (2,0)(-2,0)the ellipse x2+4y2=4x^2+4y^2=4; f=4i\nabla f=-4\mathbf iLab 2
291xeylnxxe^y-\ln x at (3,0)(-3,0)43i3j\tfrac43\mathbf i-3\mathbf jas printed; lnx\ln x needs x>0x>0
293xy2+z2x\sqrt{y^2+z^2} at (2,1,1)(-2,-1,-1)2i+2j+2k\sqrt2\,\mathbf i+\sqrt2\,\mathbf j+\sqrt2\,\mathbf k
295exye^{xy} at (6,7)(6,7), fastest rate1.6×1019\approx1.6\times10^{19}e4285e^{42}\sqrt{85}
297ln(xy+yz+zx)\ln(xy+yz+zx) at (9,18,27)(-9,-18,-27)5299\tfrac{5\sqrt2}{99}f\|\nabla f\|
299xeyxe^{-y} at (1,0)(1,0)2\sqrt2 along 1,1\langle1,-1\rangle
301cos(3x+2y)\cos(3x+2y) at (π6,π8)(\tfrac\pi6,-\tfrac\pi8)13/2\sqrt{13/2} along 3,2\langle-3,-2\rangle3x+2y=π43x+2y=\tfrac\pi4
303xy+yz+xz=3xy+yz+xz=3 at (1,1,1)(1,1,1)plane x+y+z=3x+y+z=3; line x1=y1=z1x-1=y-1=z-1f=2,2,2\nabla f=\langle2,2,2\rangle
305xeycoszz=1xe^y\cos z-z=1 at (1,0,0)(1,0,0)plane x+yz=1x+y-z=1; line x1=y=zx-1=y=-zf=1,1,1\nabla f=\langle1,1,-1\rangle
307V=5x23xy+xyzV=5x^2-3xy+xyz at (3,4,5)(3,4,5)323\tfrac{32}{\sqrt3}; 38,6,12\langle38,6,12\rangle; 24062\sqrt{406}(a) along 1,1,1\langle1,1,-1\rangle
309φ=sinπxsin2πy\varphi=\sin\pi x\sin2\pi yπcosπxsin2πy, 2πsinπxcos2πy\langle\pi\cos\pi x\sin2\pi y,\ 2\pi\sin\pi x\cos2\pi y\rangleu,v=φ\langle u,v\rangle=\nabla\varphi
Level 3 · why it worksWhere the gradient's powers come fromshort arguments

Why Duf = fx cos θ + fy sin θ

Walk along the line and watch the height: g(t)=f(a+tcosθ, b+tsinθ)g(t)=f(a+t\cos\theta,\ b+t\sin\theta) (p376). By definition Duf(a,b)=g(0)D_{\mathbf u}f(a,b)=g'(0); by the chain rule (§4.5)

g(t)=fxdxdt+fydydt=fxcosθ+fysinθ. g'(t)=f_x\,\frac{dx}{dt}+f_y\,\frac{dy}{dt}=f_x\cos\theta+f_y\sin\theta .

A directional derivative is an ordinary derivative along a straight walk; the chain rule splits the walk into east and north.

Why the gradient is the steepest way

Duf=fu=fucosφ=fcosφ D_{\mathbf u}f=\nabla f\cdot\mathbf u=\|\nabla f\|\,\|\mathbf u\|\cos\varphi=\|\nabla f\|\cos\varphi

With u=1\|\mathbf u\|=1 fixed, only cosφ\cos\varphi can change, and it lies in [1,1][-1,1] (p378). This is the Cauchy–Schwarz inequality fuf|\nabla f\cdot\mathbf u|\le\|\nabla f\| from §2.3, with equality exactly when u is parallel to f\nabla f.

Direction and size are split: u chooses, ‖∇f‖ caps.

Why the gradient crosses level curves at right angles

Trace the level curve f=kf=k as (x(t),y(t))(x(t),y(t)) (p381). Then f(x(t),y(t))=kf(x(t),y(t))=k for all tt, so

0=ddtf(x(t),y(t))=fxx(t)+fyy(t)=fx(t),y(t). 0=\frac{d}{dt}f\big(x(t),y(t)\big)=f_x\,x'(t)+f_y\,y'(t)=\nabla f\cdot\langle x'(t),\,y'(t)\rangle .

x,y\langle x',y'\rangle is tangent to the curve, so f\nabla f is normal to it. In three variables the same argument, for every curve on the level surface, makes f\nabla f normal to the surface.

Paths of steepest ascent

Follow the gradient: r(t)=f(r(t))\mathbf r'(t)=\nabla f(\mathbf r(t)). The path is always normal to the contour it is crossing, so on a map it cuts every level curve at a right angle — the way water runs down (along f-\nabla f).

It stops where f=0\nabla f=\mathbf 0: a peak, or a pass it cannot leave. Those flat points are §4.7's critical points.

Steepest paths and level curves are two families of curves that meet at right angles everywhere.

Contours of 3+sinxsiny3+\sin x\sin y; dashed: steepest paths from the floor of the map to the peaks.