Math Core

Lesson 3.6 · Partial Derivatives

Directional derivatives and the gradient

Partial derivatives tell you the rate of change of ff when you move parallel to the xx-axis or the yy-axis. But on a real hillside you can walk in any direction. This lesson measures the rate of change in an arbitrary direction and packages all of that information into a single vector, the gradient, which points uphill and is perpendicular to the level curves.

Directional derivatives

A direction in the plane is described by a unit vector u=⟨a,b⟩\mathbf{u} = \langle a, b\rangle with a2+b2=1a^2 + b^2 = 1.

Definition

Directional derivative

The directional derivative of ff at (x0,y0)(x_0, y_0) in the direction of the unit vector u=⟨a,b⟩\mathbf{u} = \langle a, b\rangle is

Duf(x0,y0)=lim⁡h→0f(x0+ha,y0+hb)−f(x0,y0)h,D_{\mathbf{u}} f(x_0, y_0) = \lim_{h \to 0} \frac{f(x_0 + ha, y_0 + hb) - f(x_0, y_0)}{h},

if the limit exists.

With u=i=⟨1,0⟩\mathbf{u} = \mathbf{i} = \langle 1, 0\rangle this is exactly fxf_x, and with u=j\mathbf{u} = \mathbf{j} it is fyf_y. To compute it in general, notice that g(h)=f(x0+ha,y0+hb)g(h) = f(x_0 + ha, y_0 + hb) is ff evaluated along a line, so the chain rule gives g′(0)=fx a+fy bg'(0) = f_x\,a + f_y\,b. That is:

Duf(x0,y0)=fx(x0,y0) a+fy(x0,y0) b.D_{\mathbf{u}} f(x_0, y_0) = f_x(x_0, y_0)\,a + f_y(x_0, y_0)\,b.

The gradient vector

The expression fxa+fybf_x a + f_y b is a dot product. The vector of partial derivatives is important enough to have its own name.

The gradient

The gradient of f(x,y)f(x, y) is the vector ∇f=⟨fx,fy⟩\nabla f = \langle f_x, f_y\rangle. For f(x,y,z)f(x, y, z) it is ∇f=⟨fx,fy,fz⟩\nabla f = \langle f_x, f_y, f_z\rangle. For any unit vector u\mathbf{u},

Duf=∇f⋅u.D_{\mathbf{u}} f = \nabla f \cdot \mathbf{u}.

Worked example: A directional derivative

Let f(x,y)=x2y−3yf(x, y) = x^2y - 3y. Find the directional derivative at (2,1)(2, 1) in the direction of v=⟨3,4⟩\mathbf{v} = \langle 3, 4\rangle.

The gradient is ∇f=⟨2xy, x2−3⟩\nabla f = \langle 2xy,\ x^2 - 3\rangle, so ∇f(2,1)=⟨4,1⟩\nabla f(2, 1) = \langle 4, 1\rangle.

The vector v\mathbf{v} is not a unit vector: ∣v∣=5\lvert\mathbf{v}\rvert = 5. Normalize it: u=⟨35,45⟩\mathbf{u} = \left\langle \tfrac{3}{5}, \tfrac{4}{5}\right\rangle. Then

Duf(2,1)=⟨4,1⟩⋅⟨35,45⟩=125+45=165.D_{\mathbf{u}} f(2, 1) = \langle 4, 1\rangle \cdot \left\langle \tfrac{3}{5}, \tfrac{4}{5}\right\rangle = \frac{12}{5} + \frac{4}{5} = \frac{16}{5}.

Common mistake

Always convert the direction to a unit vector before taking the dot product. Using v=⟨3,4⟩\mathbf{v} = \langle 3, 4\rangle directly would give 1616, five times too large. If a direction is given as an angle θ\theta, the unit vector is ⟨cos⁡θ,sin⁡θ⟩\langle \cos\theta, \sin\theta\rangle.

Steepest ascent

Write the dot product with the angle θ\theta between ∇f\nabla f and u\mathbf{u}:

Duf=∣∇f∣ ∣u∣cos⁡θ=∣∇f∣cos⁡θ.D_{\mathbf{u}} f = \lvert\nabla f\rvert\,\lvert\mathbf{u}\rvert\cos\theta = \lvert\nabla f\rvert\cos\theta.

Since cos⁡θ\cos\theta ranges from −1-1 to 11, this single line answers three questions at once.

What the gradient tells you

At a point where ∇f≠0\nabla f \ne \mathbf{0}:

  • ff increases fastest in the direction of ∇f\nabla f (θ=0\theta = 0), and the maximum rate is ∣∇f∣\lvert\nabla f\rvert.
  • ff decreases fastest in the direction of −∇f-\nabla f (θ=π\theta = \pi), at rate −∣∇f∣-\lvert\nabla f\rvert.
  • The rate of change is 00 in directions perpendicular to ∇f\nabla f (θ=π/2\theta = \pi/2).

Worked example: Heat-seeking

The temperature on a metal plate is T(x,y)=100−x2−2y2T(x, y) = 100 - x^2 - 2y^2. A bug sits at (3,1)(3, 1). In which direction should it move to warm up as fast as possible, and how fast does the temperature rise in that direction?

∇T=⟨−2x,−4y⟩\nabla T = \langle -2x, -4y\rangle, so ∇T(3,1)=⟨−6,−4⟩\nabla T(3, 1) = \langle -6, -4\rangle. The bug should head in the direction of ⟨−6,−4⟩\langle -6, -4\rangle, or equivalently the unit vector ⟨−313,−213⟩\left\langle -\tfrac{3}{\sqrt{13}}, -\tfrac{2}{\sqrt{13}}\right\rangle. The maximum rate of increase is

∣∇T(3,1)∣=36+16=52=213≈7.21 degrees per unit distance.\lvert\nabla T(3, 1)\rvert = \sqrt{36 + 16} = \sqrt{52} = 2\sqrt{13} \approx 7.21 \text{ degrees per unit distance}.

The gradient is perpendicular to level curves

Moving along a level curve keeps ff constant, so the rate of change in the direction tangent to the level curve is 00. By the last bullet above, that tangent direction is perpendicular to ∇f\nabla f. So the gradient at a point is perpendicular to the level curve through that point, and it points toward higher values.

Level curves of f = x² + 2y². At (2, 1.5), the gradient ⟨4, 6⟩ (drawn scaled down) is perpendicular to the level curve x² + 2y² = 8.5 through that point.Open in grapher →

This is the same fact a hiker uses: the steepest path up a mountain crosses the contour lines at right angles.

Tangent planes to level surfaces

The same reasoning works in three dimensions. If F(x,y,z)=kF(x, y, z) = k is a level surface and P=(x0,y0,z0)P = (x_0, y_0, z_0) lies on it, then ∇F(P)\nabla F(P) is perpendicular to every curve on the surface through PP. So ∇F(P)\nabla F(P) is a normal vector to the surface, and the tangent plane is

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

This handles surfaces, like spheres and ellipsoids, that are not graphs of a single function z=f(x,y)z = f(x, y).

Worked example: Tangent plane to an ellipsoid

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

With F=x2+2y2+3z2F = x^2 + 2y^2 + 3z^2, ∇F=⟨2x,4y,6z⟩\nabla F = \langle 2x, 4y, 6z\rangle and ∇F(1,1,1)=⟨2,4,6⟩\nabla F(1, 1, 1) = \langle 2, 4, 6\rangle. The tangent plane is

2(x−1)+4(y−1)+6(z−1)=0⟺x+2y+3z=6.2(x - 1) + 4(y - 1) + 6(z - 1) = 0 \quad\Longleftrightarrow\quad x + 2y + 3z = 6.

Tip

The tangent plane formula from the previous lessons is a special case. The graph z=f(x,y)z = f(x, y) is the level surface F(x,y,z)=f(x,y)−z=0F(x, y, z) = f(x, y) - z = 0, whose gradient is ⟨fx,fy,−1⟩\langle f_x, f_y, -1\rangle. Plugging that into the formula above gives z−z0=fx(x−x0)+fy(y−y0)z - z_0 = f_x(x - x_0) + f_y(y - y_0).

Practice

Practice 1

Find ∇f(1,−1)\nabla f(1, -1) for f(x,y)=x3y+2y2f(x, y) = x^3y + 2y^2.

Enter a point like (2, -3)

Practice 2

Find ∇f(0,π2)\nabla f\left(0, \tfrac{\pi}{2}\right) for f(x,y)=exsin⁡yf(x, y) = e^x\sin y.

Enter a point like (2, -3)

Practice 3

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

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 4

Find the directional derivative of f(x,y)=xy2f(x, y) = xy^2 at (2,1)(2, 1) in the direction making an angle θ=π3\theta = \tfrac{\pi}{3} with the positive xx-axis.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 5

Find the maximum rate of change of f(x,y)=x2+4y2f(x, y) = x^2 + 4y^2 at the point (3,1)(3, 1).

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 6

Find the unit vector in the direction in which f(x,y)=x2yf(x, y) = x^2y decreases most rapidly at (1,2)(1, 2).

Enter a point like (2, -3)

Practice 7

The tangent plane to the sphere x2+y2+z2=14x^2 + y^2 + z^2 = 14 at (1,2,3)(1, 2, 3) can be written as x+2y+3z=dx + 2y + 3z = d. Find dd.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 8

At a point PP, ∇f(P)=⟨3,4⟩\nabla f(P) = \langle 3, 4\rangle. In which unit direction is the directional derivative of ff at PP equal to 00?