MAT1052 · Week 10 · Directional Derivatives, Gradient, Tangent Planes

Gradient, directional derivative and tangent plane

You learn to compute the gradient vector, to find the rate of change in any direction with it (the directional derivative), to determine the direction and value of fastest increase, to write tangent planes and normal lines to surfaces, and to approximate with linearization and differentials.

gradientdirectional derivativeunit vectormaximum rate of changelevel curvetangent planenormal linelinearizationtotal differentialerror estimation

Last week you saw partial derivatives: fxf_x is the rate of change only in the xx direction, fyf_y only in the yy direction. But how fast does the function change in the 45∘45^\circ direction, or in any direction? The answer to this question is the directional derivative, and the key to computing it is the gradient vector. The gradient is the most important object in multivariable calculus: it points in the direction of fastest increase, it is perpendicular to level curves, and it gives the normal of the tangent plane. A directional derivative, a “maximum rate of change” and a tangent plane question are almost guaranteed on this topic in the exam.

Golden rules:

  1. In a directional derivative, always convert the direction vector into a unit vector.
  2. Duf=∇f⋅uD_{\mathbf u}f = \nabla f\cdot\mathbf u. The largest value is ∣∇f∣\lvert\nabla f\rvert, in the direction of the gradient.
  3. The gradient is perpendicular to the level curve (level surface). The tangent line and tangent plane formulas follow from this sentence.
  4. For z=f(x,y)z = f(x,y), the tangent plane and the linearization are the same thing: L(x,y)=f(a,b)+fx(x−a)+fy(y−b)L(x,y) = f(a,b)+f_x(x-a)+f_y(y-b).

The gradient

Definition.

∇f(x,y)=⟨fx, fy⟩,∇f(x,y,z)=⟨fx, fy, fz⟩.\nabla f(x,y) = \langle f_x,\,f_y\rangle,\qquad\nabla f(x,y,z) = \langle f_x,\,f_y,\,f_z\rangle.

It is read “nabla f” or “grad f”. When evaluated at a point, it becomes a vector.

Example 1. f(x,y)=x2y−3yf(x,y) = x^2y-3y. ∇f=⟨2xy, x2−3⟩\nabla f = \langle2xy,\,x^2-3\rangle. At (2,1)(2,1), ⟨4,1⟩\langle4,1\rangle.

The directional derivative

Definition. Let u=⟨u1,u2⟩\mathbf u = \langle u_1,u_2\rangle be a unit vector. The derivative of ff at the point (a,b)(a,b) in the direction of u\mathbf u is

Duf(a,b)=lim⁡h→0f(a+hu1, b+hu2)−f(a,b)h.D_{\mathbf u}f(a,b) = \lim_{h\to0}\frac{f(a+hu_1,\,b+hu_2)-f(a,b)}{h}.

That is, how much ff changes if you walk one unit from (a,b)(a,b) in the direction u\mathbf u.

Theorem. If ff is differentiable,

Duf=∇f⋅u=fxu1+fyu2.D_{\mathbf u}f = \nabla f\cdot\mathbf u = f_xu_1+f_yu_2.

For u=i\mathbf u = \mathbf i, Duf=fxD_{\mathbf u}f = f_x; the partial derivatives are special cases of the directional derivative.

Example 1 (continued). At (2,1)(2,1) in the direction ⟨1,1⟩\langle1,1\rangle: u=12⟨1,1⟩\mathbf u = \frac{1}{\sqrt2}\langle1,1\rangle, Duf=4+12=52≈3.54D_{\mathbf u}f = \frac{4+1}{\sqrt2} = \frac{5}{\sqrt2}\approx3.54.

Example 2 (three variables, direction given by two points). f(x,y,z)=xyz2f(x,y,z) = xyz^2, from P(1,2,1)P(1,2,1) toward Q(3,3,3)Q(3,3,3).

PQ    = <2, 1, 2>,  |PQ| = 3,  u = <2/3, 1/3, 2/3>
∇f    = <y z^2, x z^2, 2xyz>  →  at P: <2, 1, 4>
D_u f = (2·2 + 1·1 + 4·2)/3 = 13/3

PITFALL · the unit vector. If you compute with ∇f⋅v\nabla f\cdot\mathbf v when v\mathbf v is not a unit vector, your answer will be wrong by a factor of ∣v∣\lvert\mathbf v\rvert. In Q2, if you had multiplied directly with ⟨3,4⟩\langle3,4\rangle you would have found 2727; the correct answer is 27/527/5. Divide the moment you see the phrase “in the direction of”.

Fastest increase

Duf=∇f⋅u=∣∇f∣∣u∣cos⁡θ=∣∇f∣cos⁡θD_{\mathbf u}f = \nabla f\cdot\mathbf u = \lvert\nabla f\rvert\lvert\mathbf u\rvert\cos\theta = \lvert\nabla f\rvert\cos\theta. θ\theta is the angle between u\mathbf u and the gradient. From this:

Directionθ\thetaDufD_{\mathbf u}f
direction of ∇f\nabla f00∣∇f∣\lvert\nabla f\rvert (largest)
direction of −∇f-\nabla fπ\pi−∣∇f∣-\lvert\nabla f\rvert (smallest, fastest decrease)
perpendicular to ∇f\nabla fπ/2\pi/200 (no change)

Intuition. Imagine you are standing on the slope of a mountain. The gradient is a compass pointing in the direction of steepest climb. Its length is the slope in that direction. If you walk perpendicular to the gradient, you neither climb nor descend; you walk along a contour line. If you release a ball, it rolls in the direction of −∇f-\nabla f.

Example 3. The temperature of a plate is T(x,y)=100−x2−2y2T(x,y) = 100-x^2-2y^2. In which direction should an ant at (1,1)(1,1) go to cool down fastest? ∇T=⟨−2x,−4y⟩=⟨−2,−4⟩\nabla T = \langle-2x,-4y\rangle = \langle-2,-4\rangle. The fastest decrease is in the direction −∇T=⟨2,4⟩-\nabla T = \langle2,4\rangle, that is, 15⟨1,2⟩\frac{1}{\sqrt5}\langle1,2\rangle. In this direction the temperature drops at a rate of ∣∇T∣=20≈4.47\lvert\nabla T\rvert = \sqrt{20}\approx4.47 degrees/unit.

The gradient and level curves

Along the level curve f(x,y)=cf(x,y) = c, ff does not change, that is, Duf=0D_{\mathbf u}f = 0 in the direction tangent to the curve. That is why ∇f\nabla f is perpendicular to the level curve. The tangent line to the level curve at (x0,y0)(x_0,y_0):

fx(x0,y0)(x−x0)+fy(x0,y0)(y−y0)=0.f_x(x_0,y_0)(x-x_0)+f_y(x_0,y_0)(y-y_0) = 0.

In three dimensions it is the same idea: ∇F\nabla F is perpendicular to the level surface F(x,y,z)=cF(x,y,z) = c.

Tangent plane and normal line

Level surface F(x,y,z)=cF(x,y,z) = c. The normal of the tangent plane at P0(x0,y0,z0)P_0(x_0,y_0,z_0) is ∇F(P0)\nabla F(P_0):

Fx(P0)(x−x0)+Fy(P0)(y−y0)+Fz(P0)(z−z0)=0.F_x(P_0)(x-x_0)+F_y(P_0)(y-y_0)+F_z(P_0)(z-z_0) = 0.

The normal line: r(t)=P0+t ∇F(P0)\mathbf r(t) = P_0+t\,\nabla F(P_0).

Graph z=f(x,y)z = f(x,y). If you write F=f(x,y)−z=0F = f(x,y)-z = 0, then ∇F=⟨fx,fy,−1⟩\nabla F = \langle f_x,f_y,-1\rangle and the formula is

z−z0=fx(x0,y0)(x−x0)+fy(x0,y0)(y−y0).z-z_0 = f_x(x_0,y_0)(x-x_0)+f_y(x_0,y_0)(y-y_0).

Example 4. z=x2+3y2z = x^2+3y^2, (1,1,4)(1,1,4): fx=2f_x = 2, fy=6f_y = 6. z=4+2(x−1)+6(y−1)=2x+6y−4z = 4+2(x-1)+6(y-1) = 2x+6y-4.

Example 5. The ellipsoid x2+2y2+3z2=6x^2+2y^2+3z^2 = 6, (1,1,1)(1,1,1): ∇F=⟨2x,4y,6z⟩=⟨2,4,6⟩∥⟨1,2,3⟩\nabla F = \langle2x,4y,6z\rangle = \langle2,4,6\rangle\parallel\langle1,2,3\rangle. The tangent plane is x+2y+3z=6x+2y+3z = 6. The normal line is (1+t, 1+2t, 1+3t)(1+t,\,1+2t,\,1+3t).

TIP · which formula? If the surface is in the form z=…z = \ldots, the second formula is quick. If the surface is a mixed equation in xx, yy, zz (xyz=6xyz = 6, x2+y2−z2=1x^2+y^2-z^2 = 1), gather everything on one side, call it FF, and take the gradient.

Linearization and the differential

The linearization of z=f(x,y)z = f(x,y) at (a,b)(a,b) is the equation of the tangent plane:

L(x,y)=f(a,b)+fx(a,b)(x−a)+fy(a,b)(y−b),f(x,y)≈L(x,y)  ((x,y)≈(a,b)).L(x,y) = f(a,b)+f_x(a,b)(x-a)+f_y(a,b)(y-b),\qquad f(x,y)\approx L(x,y)\ \ ((x,y)\approx(a,b)).

Example 6. f(x,y)=xeyf(x,y) = xe^y, (1,0)(1,0): f=1f = 1, fx=ey=1f_x = e^y = 1, fy=xey=1f_y = xe^y = 1. L=1+(x−1)+yL = 1+(x-1)+y. f(1.1,−0.1)≈1+0.1−0.1=1.0f(1.1,-0.1)\approx1+0.1-0.1 = 1.0. The true value is 0.995320.99532.

Total differential.

dz=fx dx+fy dy.dz = f_x\,dx+f_y\,dy.

In measurement error questions, dxdx, dydy are the possible errors in the measurements; for the worst case you take all of them in the same direction (with the signs that give a positive contribution).

Common mistakes

WrongCorrect
Multiplying without making the direction a unit vectoru=v/∣v∣\mathbf u = \mathbf v/\lvert\mathbf v\rvert
Calling the largest directional derivative "∇f\nabla f"The value is ∣∇f∣\lvert\nabla f\rvert (a number), the direction is ∇f\nabla f
Taking the direction from PP to QQ as the position vector of QQPQ→=Q−P\overrightarrow{PQ} = Q-P
Thinking the gradient is tangent to the level curveThe gradient is perpendicular
Forgetting z0z_0 in the tangent planez−z0=…z-z_0 = \ldots
Computing the gradient for F(x,y,z)=cF(x,y,z)=c without plugging in the point∇F(P0)\nabla F(P_0) must be a numerical vector
Writing a plane instead of a line for the normal lineThe line: P0+t∇FP_0+t\nabla F
Mixing up the signs in error estimationWorst case: contributions with the same sign

Test yourself

Exam-style questions. Solve them on paper first, then reveal the answer.

Question 1easy

Find ∇f(1,2)\nabla f(1,2) for f(x,y)=x2y+y3f(x,y) = x^2y+y^3.

Show answer
⟨4,13⟩\langle4,13\rangle

fx=2xyf_x = 2xy, fy=x2+3y2f_y = x^2+3y^2. At (1,2)(1,2), fx=4f_x = 4, fy=1+12=13f_y = 1+12 = 13. ∇f=⟨4,13⟩\nabla f = \langle4,13\rangle.

Question 2easy

Find the directional derivative of f(x,y)=x2+3xyf(x,y) = x^2+3xy at (1,1)(1,1) in the direction of v=⟨3,4⟩\mathbf v = \langle3,4\rangle.

Show answer
27/527/5

∇f=⟨2x+3y, 3x⟩=⟨5,3⟩\nabla f = \langle2x+3y,\,3x\rangle = \langle5,3\rangle. Make the direction a unit vector: u=⟨35,45⟩\mathbf u = \langle\frac35,\frac45\rangle.Duf=∇f⋅u=5⋅35+3⋅45=3+125=275D_{\mathbf u}f = \nabla f\cdot\mathbf u = 5\cdot\frac35+3\cdot\frac45 = 3+\frac{12}{5} = \frac{27}{5}.

Question 3medium

For f(x,y)=xeyf(x,y) = xe^y at (2,0)(2,0), find the direction of maximum increase and the maximum rate of change.

Show answer
Direction ⟨1,2⟩/5\langle1,2\rangle/\sqrt5, rate 5\sqrt5

∇f=⟨ey, xey⟩=⟨1,2⟩\nabla f = \langle e^y,\,xe^y\rangle = \langle1,2\rangle. The fastest increase is in the direction of the gradient: ⟨1,2⟩5\dfrac{\langle1,2\rangle}{\sqrt5}.
The maximum rate of increase is ∣∇f∣=5\lvert\nabla f\rvert = \sqrt5.

Question 4medium

For f(x,y)=x2−y2f(x,y) = x^2-y^2 at (1,1)(1,1), find the unit vectors in which the directional derivative is zero.

Show answer
±⟨1,1⟩/2\pm\langle1,1\rangle/\sqrt2

∇f=⟨2x,−2y⟩=⟨2,−2⟩\nabla f = \langle2x,-2y\rangle = \langle2,-2\rangle. Duf=0  ⟺  u⊥∇fD_{\mathbf u}f = 0\iff\mathbf u\perp\nabla f.
The unit vectors perpendicular to ⟨2,−2⟩\langle2,-2\rangle are ±12⟨1,1⟩\pm\frac{1}{\sqrt2}\langle1,1\rangle. These are the directions tangent to the level curve.

Question 5medium

Find the directional derivative of f(x,y,z)=xyzf(x,y,z) = xyz at P(1,2,3)P(1,2,3) in the direction from PP toward Q(2,4,5)Q(2,4,5).

Show answer
16/316/3

PQ→=⟨1,2,2⟩\overrightarrow{PQ} = \langle1,2,2\rangle, length 33, u=13⟨1,2,2⟩\mathbf u = \frac13\langle1,2,2\rangle.∇f=⟨yz,xz,xy⟩=⟨6,3,2⟩\nabla f = \langle yz,xz,xy\rangle = \langle6,3,2\rangle. Duf=13(6+6+4)=163D_{\mathbf u}f = \frac13(6+6+4) = \frac{16}{3}.

Question 6easy

Find the tangent plane to z=x2+y2z = x^2+y^2 at (1,2,5)(1,2,5).

Show answer
z=2x+4y−5z = 2x+4y-5

fx=2x=2f_x = 2x = 2, fy=2y=4f_y = 2y = 4. z−5=2(x−1)+4(y−2)z-5 = 2(x-1)+4(y-2), that is, z=2x+4y−5z = 2x+4y-5.
Check: at (1,2)(1,2), 2+8−5=52+8-5 = 5 ✓.

Question 7easy

Find the tangent plane to the sphere x2+y2+z2=9x^2+y^2+z^2 = 9 at (1,2,2)(1,2,2).

Show answer
x+2y+2z=9x+2y+2z = 9

F=x2+y2+z2F = x^2+y^2+z^2, ∇F=⟨2x,2y,2z⟩=⟨2,4,4⟩∥⟨1,2,2⟩\nabla F = \langle2x,2y,2z\rangle = \langle2,4,4\rangle\parallel\langle1,2,2\rangle.(x−1)+2(y−2)+2(z−2)=0⇒x+2y+2z=9(x-1)+2(y-2)+2(z-2) = 0\Rightarrow x+2y+2z = 9.

Question 8medium

Find parametric equations of the normal line to x2+2y2+z2=7x^2+2y^2+z^2 = 7 at (1,1,2)(1,1,2).

Show answer
x=1+t, y=1+2t, z=2+2tx = 1+t,\ y = 1+2t,\ z = 2+2t

The direction of the normal line is the gradient: ∇F=⟨2x,4y,2z⟩=⟨2,4,4⟩∥⟨1,2,2⟩\nabla F = \langle2x,4y,2z\rangle = \langle2,4,4\rangle\parallel\langle1,2,2\rangle.
The line: (1+t, 1+2t, 2+2t)(1+t,\,1+2t,\,2+2t).

Question 9medium

Use the linearization of f(x,y)=x2+y2f(x,y) = \sqrt{x^2+y^2} at (3,4)(3,4) to approximate f(3.1, 3.9)f(3.1,\,3.9).

Show answer
≈4.98\approx 4.98

f(3,4)=5f(3,4) = 5, fx=xx2+y2=35f_x = \frac{x}{\sqrt{x^2+y^2}} = \frac35, fy=45f_y = \frac45.L=5+35(x−3)+45(y−4)L = 5+\frac35(x-3)+\frac45(y-4). L(3.1,3.9)=5+0.06−0.08=4.98L(3.1,3.9) = 5+0.06-0.08 = 4.98. (The true value is 4.981974.98197.)

Question 10medium

Find the tangent line to the level curve x2+xy+y2=7x^2+xy+y^2 = 7 at (1,2)(1,2).

Show answer
4x+5y=144x+5y = 14

The gradient is perpendicular to the level curve: ∇f=⟨2x+y, x+2y⟩=⟨4,5⟩\nabla f = \langle2x+y,\,x+2y\rangle = \langle4,5\rangle.
The tangent line is the line with normal ⟨4,5⟩\langle4,5\rangle: 4(x−1)+5(y−2)=04(x-1)+5(y-2) = 0, 4x+5y=144x+5y = 14.

Question 11hard

For f(x,y)=x2+y2f(x,y) = x^2+y^2 at (1,0)(1,0), find all unit vectors u\mathbf u with Duf=1D_{\mathbf u}f = 1.

Show answer
u=⟨12,±32⟩\mathbf u = \langle\frac12,\pm\frac{\sqrt3}{2}\rangle

∇f=⟨2,0⟩\nabla f = \langle2,0\rangle. If u=⟨cos⁡θ,sin⁡θ⟩\mathbf u = \langle\cos\theta,\sin\theta\rangle then Duf=2cos⁡θ=1D_{\mathbf u}f = 2\cos\theta = 1, cos⁡θ=12\cos\theta = \frac12.θ=±60∘\theta = \pm60^\circ: u=⟨12,±32⟩\mathbf u = \langle\frac12,\pm\frac{\sqrt3}{2}\rangle.

Question 12hard

The radius and height of a cylinder are measured as r=3r = 3 cm and h=5h = 5 cm, with possible errors 0.010.01 cm and 0.020.02 cm. Estimate the maximum error in the computed volume.

Show answer
dV=0.48π≈1.51dV = 0.48\pi\approx1.51 cm3^3

V=πr2hV = \pi r^2h. Total differential: dV=2πrh dr+πr2 dhdV = 2\pi rh\,dr+\pi r^2\,dh.2π(3)(5)(0.01)+π(9)(0.02)=0.30π+0.18π=0.48π≈1.5082\pi(3)(5)(0.01)+\pi(9)(0.02) = 0.30\pi+0.18\pi = 0.48\pi\approx1.508 cm3^3.

Verification: Gradients were checked with central differences, directional derivatives independently from the definition (the numerical derivative at h=0 of the function f(P + h u)), tangent planes by plugging in the point and the gradient, and linearization and differential results against the actual function value in node (verify/MAT1052/10.mjs).

Review card

∇f = <f_x, f_y, f_z> D_u f = ∇f · u (u must be a UNIT vector! u = v/|v|) D_u f = |∇f| cos θ Fastest increase: direction of ∇f, rate |∇f|. Fastest decrease: -∇f, rate -|∇f| D_u f = 0: u ⊥ ∇f (tangent to the level curve) ∇f is PERPENDICULAR to the level curve/surface Tangent plane, z = f(x,y): z - z0 = f_x(x-x0) + f_y(y-y0) Tangent plane, F(x,y,z) = c: F_x(x-x0)+F_y(y-y0)+F_z(z-z0) = 0 Normal line: (x0,y0,z0) + t ∇F L(x,y) = f(a,b) + f_x(a,b)(x-a) + f_y(a,b)(y-b) (the tangent plane!) dz = f_x dx + f_y dy error estimate: |dx|,|dy| with the worst-case sign