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.
Last week you saw partial derivatives: fx is the rate of change only in the x direction, fy only in the y direction. But how fast does the function change in the 45∘ 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:
In a directional derivative, always convert the direction vector into a unit vector.
Duf=∇f⋅u. The largest value is ∣∇f∣, in the direction of the gradient.
The gradient is perpendicular to the level curve (level surface). The tangent line and tangent plane formulas follow from this sentence.
For 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).
The gradient
Definition.
∇f(x,y)=⟨fx,fy⟩,∇f(x,y,z)=⟨fx,fy,fz⟩.
It is read “nabla f” or “grad f”. When evaluated at a point, it becomes a vector.
Example 1.f(x,y)=x2y−3y. ∇f=⟨2xy,x2−3⟩. At (2,1), ⟨4,1⟩.
The directional derivative
Definition. Let u=⟨u1,u2⟩ be a unit vector. The derivative of f at the point (a,b) in the direction of u is
Duf(a,b)=limh→0hf(a+hu1,b+hu2)−f(a,b).
That is, how much f changes if you walk one unit from (a,b) in the direction u.
Theorem. If f is differentiable,
Duf=∇f⋅u=fxu1+fyu2.
For u=i, Duf=fx; the partial derivatives are special cases of the directional derivative.
Example 1 (continued). At (2,1) in the direction ⟨1,1⟩: u=21⟨1,1⟩, Duf=24+1=25≈3.54.
Example 2 (three variables, direction given by two points).f(x,y,z)=xyz2, from P(1,2,1) toward 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 when v is not a unit vector, your answer will be wrong by a factor of ∣v∣. In Q2, if you had multiplied directly with ⟨3,4⟩ you would have found 27; the correct answer is 27/5. Divide the moment you see the phrase “in the direction of”.
Fastest increase
Duf=∇f⋅u=∣∇f∣∣u∣cosθ=∣∇f∣cosθ. θ is the angle between u and the gradient. From this:
Direction
θ
Duf
direction of ∇f
0
∣∇f∣ (largest)
direction of −∇f
π
−∣∇f∣ (smallest, fastest decrease)
perpendicular to ∇f
π/2
0 (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.
Example 3. The temperature of a plate is T(x,y)=100−x2−2y2. In which direction should an ant at (1,1) go to cool down fastest? ∇T=⟨−2x,−4y⟩=⟨−2,−4⟩. The fastest decrease is in the direction −∇T=⟨2,4⟩, that is, 51⟨1,2⟩. In this direction the temperature drops at a rate of ∣∇T∣=20≈4.47 degrees/unit.
The gradient and level curves
Along the level curve f(x,y)=c, f does not change, that is, Duf=0 in the direction tangent to the curve. That is why ∇f is perpendicular to the level curve. The tangent line to the level curve at (x0,y0):
fx(x0,y0)(x−x0)+fy(x0,y0)(y−y0)=0.
In three dimensions it is the same idea: ∇F is perpendicular to the level surface F(x,y,z)=c.
Tangent plane and normal line
Level surface F(x,y,z)=c. The normal of the tangent plane at P0(x0,y0,z0) is ∇F(P0):
Graph z=f(x,y). If you write F=f(x,y)−z=0, then ∇F=⟨fx,fy,−1⟩ and the formula is
z−z0=fx(x0,y0)(x−x0)+fy(x0,y0)(y−y0).
Example 4.z=x2+3y2, (1,1,4): fx=2, fy=6. z=4+2(x−1)+6(y−1)=2x+6y−4.
Example 5. The ellipsoid x2+2y2+3z2=6, (1,1,1): ∇F=⟨2x,4y,6z⟩=⟨2,4,6⟩∥⟨1,2,3⟩. The tangent plane is x+2y+3z=6. The normal line is (1+t,1+2t,1+3t).
TIP · which formula? If the surface is in the form z=…, the second formula is quick. If the surface is a mixed equation in x, y, z (xyz=6, x2+y2−z2=1), gather everything on one side, call it F, and take the gradient.
Linearization and the differential
The linearization of z=f(x,y) at (a,b) is the equation of the tangent plane:
Example 6.f(x,y)=xey, (1,0): f=1, fx=ey=1, fy=xey=1. L=1+(x−1)+y. f(1.1,−0.1)≈1+0.1−0.1=1.0. The true value is 0.99532.
Total differential.
dz=fxdx+fydy.
In measurement error questions, dx, dy 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
Wrong
Correct
Multiplying without making the direction a unit vector
u=v/∣v∣
Calling the largest directional derivative "∇f"
The value is ∣∇f∣ (a number), the direction is ∇f
Taking the direction from P to Q as the position vector of Q
PQ=Q−P
Thinking the gradient is tangent to the level curve
The gradient is perpendicular
Forgetting z0 in the tangent plane
z−z0=…
Computing the gradient for F(x,y,z)=c without plugging in the point
∇F(P0) must be a numerical vector
Writing a plane instead of a line for the normal line
The line: P0+t∇F
Mixing up the signs in error estimation
Worst 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) for f(x,y)=x2y+y3.
Show answer
⟨4,13⟩
fx=2xy, fy=x2+3y2. At (1,2), fx=4, fy=1+12=13. ∇f=⟨4,13⟩.
Question 2easy
Find the directional derivative of f(x,y)=x2+3xy at (1,1) in the direction of v=⟨3,4⟩.
Show answer
27/5
∇f=⟨2x+3y,3x⟩=⟨5,3⟩. Make the direction a unit vector: u=⟨53,54⟩.Duf=∇f⋅u=5⋅53+3⋅54=3+512=527.
Question 3medium
For f(x,y)=xey at (2,0), find the direction of maximum increase and the maximum rate of change.
Show answer
Direction ⟨1,2⟩/5, rate 5
∇f=⟨ey,xey⟩=⟨1,2⟩. The fastest increase is in the direction of the gradient: 5⟨1,2⟩. The maximum rate of increase is ∣∇f∣=5.
Question 4medium
For f(x,y)=x2−y2 at (1,1), find the unit vectors in which the directional derivative is zero.
Show answer
±⟨1,1⟩/2
∇f=⟨2x,−2y⟩=⟨2,−2⟩. Duf=0⟺u⊥∇f. The unit vectors perpendicular to ⟨2,−2⟩ are ±21⟨1,1⟩. These are the directions tangent to the level curve.
Question 5medium
Find the directional derivative of f(x,y,z)=xyz at P(1,2,3) in the direction from P toward Q(2,4,5).
Find parametric equations of the normal line to x2+2y2+z2=7 at (1,1,2).
Show answer
x=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⟩. The line: (1+t,1+2t,2+2t).
Question 9medium
Use the linearization of f(x,y)=x2+y2 at (3,4) to approximate f(3.1,3.9).
Show answer
≈4.98
f(3,4)=5, fx=x2+y2x=53, fy=54.L=5+53(x−3)+54(y−4). L(3.1,3.9)=5+0.06−0.08=4.98. (The true value is 4.98197.)
Question 10medium
Find the tangent line to the level curve x2+xy+y2=7 at (1,2).
Show answer
4x+5y=14
The gradient is perpendicular to the level curve: ∇f=⟨2x+y,x+2y⟩=⟨4,5⟩. The tangent line is the line with normal ⟨4,5⟩: 4(x−1)+5(y−2)=0, 4x+5y=14.
Question 11hard
For f(x,y)=x2+y2 at (1,0), find all unit vectors u with Duf=1.
Show answer
u=⟨21,±23⟩
∇f=⟨2,0⟩. If u=⟨cosθ,sinθ⟩ then Duf=2cosθ=1, cosθ=21.θ=±60∘: u=⟨21,±23⟩.
Question 12hard
The radius and height of a cylinder are measured as r=3 cm and h=5 cm, with possible errors 0.01 cm and 0.02 cm. Estimate the maximum error in the computed volume.
Show answer
dV=0.48π≈1.51 cm3
V=πr2h. Total differential: dV=2πrhdr+πr2dh.2π(3)(5)(0.01)+π(9)(0.02)=0.30π+0.18π=0.48π≈1.508 cm3.
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