11. Tangent planes, linear approximation, and total differentials

📖 Reading · 10 min
💡 Every code box below is live — edit it and hit Run.

§3.1 approximated a curve near a point with its tangent line — a single slope, capturing how y changes as x moves. §10.2 gave a surface two slopes at every point, f_x and f_y. This lesson combines them into a single tangent plane, the direct two-variable generalization of linear approximation, and shows it works exactly the way §3.1's did: extremely well for small steps away from the point of tangency.

The tangent plane

At a point (x_0,y_0), the tangent plane to z=f(x,y) is the plane that matches the surface's height and both slopes there:

z=f(x_0,y_0)+f_x(x_0,y_0)(x-x_0)+f_y(x_0,y_0)(y-y_0)

Compare directly to §3.1's tangent line, y=f(a)+f'(a)(x-a): the same structure, "value at the point plus slope times displacement," just with two slope terms instead of one, matching the fact that displacement away from (x_0,y_0) now has two independent components. This is also exactly §9.3's plane-through-a-point-with-a-normal construction: rearranging gives f_x(x_0,y_0)(x-x_0)+f_y(x_0,y_0)(y-y_0)-(z-z_0)=0, a plane with normal vector \langle f_x,f_y,-1\rangle.

Linear approximation

Just as §3.1 used the tangent line to approximate f(x) near a without recomputing f exactly, the tangent plane approximates f(x,y) near (x_0,y_0):

f(x,y)\approx f(x_0,y_0)+f_x(x_0,y_0)(x-x_0)+f_y(x_0,y_0)(y-y_0)

The accuracy behavior is identical to the one-variable case: the approximation is excellent for (x,y) close to (x_0,y_0) and degrades as the displacement grows, for exactly the same reason §3.1's linear approximation degraded — a plane can only match a curved surface's actual value, slope, and nothing about its curvature.

The total differential

Writing dx=x-x_0 and dy=y-y_0 for small displacements, the total differential is the linear approximation's change in z, stripped down to just the linear part:

dz=f_x(x_0,y_0)\,dx+f_y(x_0,y_0)\,dy

This is §3.1's differential dy=f'(x)dx, generalized: instead of one term capturing the change from moving in the single available direction, two terms capture the separate contributions from moving in the x-direction and the y-direction, added together. dz\approx\Delta z (the true change f(x_0+dx,y_0+dy)-f(x_0,y_0)) for small dx,dy, exactly mirroring §3.1's dy\approx\Delta y.

Practical use: estimating error propagation. If x and y are measurements with small uncertainties dx,dy, the total differential estimates how much uncertainty in x and y propagates into uncertainty in a computed quantity f(x,y) — a two-variable version of §3.1's tangent-line error estimation, and the same idea Module 9's physics applications leaned on repeatedly.

Doing it in Python

Finding the tangent plane to f(x,y)=x^2+y^2 at (1,2), and using it to approximate a nearby value without recomputing f exactly:

import sympy as sp

x, y = sp.symbols('x y')
f = x**2 + y**2

f_x = sp.diff(f, x)
f_y = sp.diff(f, y)

x0, y0 = 1, 2
f0 = f.subs({x: x0, y: y0})
fx0 = f_x.subs({x: x0, y: y0})
fy0 = f_y.subs({x: x0, y: y0})

tangent_plane = f0 + fx0 * (x - x0) + fy0 * (y - y0)
print(f"tangent plane: z = {tangent_plane}")

# approximate f(1.02, 1.97) using the plane, versus the exact value
approx = tangent_plane.subs({x: sp.Rational(102, 100), y: sp.Rational(197, 100)})
exact = f.subs({x: sp.Rational(102, 100), y: sp.Rational(197, 100)})
print(f"approx f(1.02, 1.97) = {float(approx)}")
print(f"exact  f(1.02, 1.97) = {float(exact)}")

Using the total differential directly to estimate a small change, without building the full tangent plane:

import sympy as sp

x, y = sp.symbols('x y')
f = x**2 + y**2

f_x = sp.diff(f, x)
f_y = sp.diff(f, y)

x0, y0 = 1, 2
dx, dy = sp.Rational(2, 100), sp.Rational(-3, 100)

dz = f_x.subs({x: x0, y: y0}) * dx + f_y.subs({x: x0, y: y0}) * dy
print(f"dz (estimated change) = {dz} = {float(dz)}")

true_change = f.subs({x: x0 + dx, y: y0 + dy}) - f.subs({x: x0, y: y0})
print(f"true change            = {float(true_change)}")

Error propagation: estimating uncertainty in a computed volume from uncertainty in measured dimensions:

import sympy as sp

r, h = sp.symbols('r h', positive=True)
V = sp.pi * r**2 * h   # volume of a cylinder

V_r = sp.diff(V, r)
V_h = sp.diff(V, h)

r0, h0 = 5, 10       # measured radius and height, cm
dr, dh = 0.1, 0.2    # measurement uncertainties, cm

dV = V_r.subs({r: r0, h: h0}) * dr + V_h.subs({r: r0, h: h0}) * dh
print(f"estimated volume uncertainty dV = {float(dV):.4f} cm^3")

Worked example

Find the tangent plane to f(x,y)=x^2+y^2 at (1,2), and use it to approximate f(1.02,1.97).

f_x=2x,\qquad f_y=2y

At (1,2): f(1,2)=1+4=5, f_x(1,2)=2, f_y(1,2)=4.

z=5+2(x-1)+4(y-2)

Approximating f(1.02,1.97): here x-1=0.02, y-2=-0.03.

f(1.02,1.97)\approx5+2(0.02)+4(-0.03)=5+0.04-0.12=\boxed{4.92}

Sanity check. Exact value: f(1.02,1.97)=1.02^2+1.97^2=1.0404+3.8809=4.9213. The approximation, 4.92, is off by only about 0.0013 — a tiny error for a displacement of just a couple hundredths in each coordinate, exactly the "excellent for small steps" behavior expected of a linear approximation, and matching §3.1's original accuracy pattern precisely. ✓

Your turn

1. Find the tangent plane to f(x,y)=xy at (2,3).

2. Using the total differential of f(x,y)=\sqrt{x^2+y^2}, estimate the change in f when (x,y) moves from (3,4) to (3.1,3.9).

3. True or false: the tangent plane to f(x,y) at (x_0,y_0) always touches the surface z=f(x,y) at exactly one point.

Solutions

1. f_x=y, f_y=x. At (2,3): f(2,3)=6, f_x(2,3)=3, f_y(2,3)=2.

\boxed{z=6+3(x-2)+2(y-3)}

2. f_x=\dfrac x{\sqrt{x^2+y^2}}, f_y=\dfrac y{\sqrt{x^2+y^2}}. At (3,4): \sqrt{9+16}=5, so f_x(3,4)=\frac35, f_y(3,4)=\frac45. dx=0.1, dy=-0.1:

dz=\frac35(0.1)+\frac45(-0.1)=0.06-0.08=\boxed{-0.02}

(Check: exact change is \sqrt{3.1^2+3.9^2}-5=\sqrt{9.61+15.21}-5=\sqrt{24.82}-5\approx4.9820-5=-0.0180 — close to the estimate -0.02, as expected for a small displacement.)

3. False. This is exactly the point of a tangent plane — it generally shares only the single point (x_0,y_0,f(x_0,y_0)) with the surface where the surface is genuinely curved (like a paraboloid), but if f itself happens to be a plane (a linear function of x and y), its "tangent plane" at every point is the surface itself, touching along the entire surface, not just one point — the same degenerate case §3.1 acknowledged when a function's tangent line coincides with the function because the function was already linear.

Check yourself in code

Find the tangent plane to f(x,y)=x^2+y^2 at (1,2), and use it to approximate f(1.02,1.97).

Print exactly this:

tangent plane: z = 2*x + 4*y - 5
approx f(1.02, 1.97) = 4.92
import sympy as sp

x, y = sp.symbols('x y')
f = x**2 + y**2

f_x = sp.diff(f, x)
f_y = sp.diff(f, y)

x0, y0 = 1, 2
f0 = f.subs({x: x0, y: y0})
fx0 = f_x.subs({x: x0, y: y0})
fy0 = f_y.subs({x: x0, y: y0})

tangent_plane = sp.expand(f0 + fx0 * (x - x0) + fy0 * (y - y0))
print("tangent plane: z = ...")

approx = tangent_plane.subs({x: sp.Rational(102, 100), y: sp.Rational(197, 100)})
print("approx f(1.02, 1.97) = ...")
import sympy as sp

x, y = sp.symbols('x y')
f = x**2 + y**2

f_x = sp.diff(f, x)
f_y = sp.diff(f, y)

x0, y0 = 1, 2
f0 = f.subs({x: x0, y: y0})
fx0 = f_x.subs({x: x0, y: y0})
fy0 = f_y.subs({x: x0, y: y0})

tangent_plane = sp.expand(f0 + fx0 * (x - x0) + fy0 * (y - y0))
print(f"tangent plane: z = {tangent_plane}")

approx = tangent_plane.subs({x: sp.Rational(102, 100), y: sp.Rational(197, 100)})
print(f"approx f(1.02, 1.97) = {float(approx)}")

The tangent plane, z=f(x_0,y_0)+f_x(x_0,y_0)(x-x_0)+f_y(x_0,y_0)(y-y_0), is §3.1's tangent line with a second slope term added — one contribution per coordinate direction — and it approximates a surface near a point with the same "excellent for small steps, worse further out" behavior linear approximation always has. The total differential dz=f_x\,dx+f_y\,dy strips that plane down to just the linear change, directly useful for estimating how measurement uncertainty in several inputs propagates into a computed quantity.

Next: the chain rule, rebuilt for functions of several variables — what happens when x and y themselves depend on other variables, or on a single parameter like time.