The idea: slice the surface, take one slope

A function of two variables, z = f(x, y), is a surface. At a point P = (a, b) it has no single slope: walking east is not the same as walking north. So take one direction at a time. Freeze y = b. The vertical plane y = b cuts the surface in a curve, z = f(x, b), and that curve is an ordinary graph of one variable x. Its slope at x = a is the partial derivative

∂f/∂x (a, b) = limh→0 (f(a + h, b) − f(a, b)) / h

Left: the bowl z = x² + y² with the vertical plane y = 0.5 cutting it in an orange curve, the point P = (1, 0.5, 1.25) on it. An arrow lifts the curve out. Right: the same curve as a 2D graph z = x² + 0.25 with its tangent line at x = 1, run 1 and rise 2, labelled ∂f/∂x(1, 0.5) = 2.
Freeze y: the slice is a one-variable graph, and its slope at P is ∂f/∂x.

Freeze x = a instead and the slice z = f(a, y) gives the other partial derivative, ∂f/∂y. Other names: fx, fy, ∂z/∂x. On the canvas each slice takes four steps: the vertical plane appears, it cuts the surface, the cut is lifted out onto its own 2D graph, and the tangent line with its run and rise is drawn. (Demo 1: slice the bowl, take the x-slope)

Computing one: treat the other variable as a constant

Freezing y on the picture is the same as treating y as a number in the formula. Then the usual rules of one-variable calculus apply.

f(x, y)∂f/∂x (y constant)∂f/∂y (x constant)
x2 + y22x2y
x2 − y22x−2y
3e−(x2 + y2)/2−x·f(x, y)−y·f(x, y)
sin x · cos ycos x · cos y−sin x · sin y
x2y2xyx2

For the bowl at P = (1, 0.5) the x-slice is z = x2 + 0.25: the 0.25 = y2 is just a constant that shifts the curve up, so its slope is 2x = 2. The page checks every slope against the difference quotient with h = 0.01: (f(1.01, 0.5) − f(1, 0.5)) / 0.01 = 2.01. The chain rule works the same way for the hill: d/dx of e−(x2 + y2)/2 is −x times itself. More on that rule: The Chain Rule.

Two slices, two slopes

The two slopes at one point are usually different, and can have opposite signs.

  • Saddle z = x2 − y2 at (1, 1): the x-slice x2 − 1 climbs with slope 2, the y-slice 1 − y2 falls with slope −2. (Demo 3: saddle: one slope up, one down)
  • Wave sin x · cos y at (1, 1): fx = cos 1 · cos 1 = 0.29 (gentle rise), fy = −sin 1 · sin 1 = −0.71 (steeper fall). (Demo 5: wave: two different slopes)
  • Hill at (1, 0): the y-slice runs around the hill, across its side, so fy = 0 while fx = −1.82 points straight downhill.

Put together as a vector, (fx, fy) is the gradient ∇f. It points straight uphill, at right angles to the level curve through P (see Level Curves and Contour Maps), and Gradient Descent walks against it.

The tangent plane

A surface patch with the point P. An orange tangent line along x with slope f_x and a green tangent line along y with slope f_y both pass through P; a purple plane contains both lines. Below: z = f(a, b) + f_x (x − a) + f_y (y − b).
Two tangent lines through P span one plane: the tangent plane.

The two tangent lines both pass through P, so they lie in one plane. Moving Δx along x raises it by fxΔx, moving Δy along y raises it by fyΔy, so

z = f(a, b) + fx(a, b)·(x − a) + fy(a, b)·(y − b)

For the bowl at (1, 0.5): z = 1.25 + 2(x − 1) + (y − 0.5). Near P the plane hugs the surface: at (1.2, 0.6) the plane says 1.75 and f says 1.80. This is local linearity in two variables: zoom in on a smooth surface and it looks flat. (Demo 2: both slopes and the tangent plane) For a surface given as F(x, y, z) = 0 instead of a graph, the same plane comes from ∇F: Tangent Planes to Quadric Surfaces.

A flat tangent plane: top, bottom or saddle

When fx = fy = 0 both slices are flat at P and the tangent plane is horizontal. That happens at the top of the hill (z = 3), the bottom of the bowl and the middle of the saddle. The two first derivatives cannot tell these apart: the saddle's x-slice has a bottom at P while its y-slice has a top. The second-derivative test does that job, see Critical and Singular Points. (Demo 4: top of the hill: both slopes 0)

See also Level Curves and Contour Maps, The Derivative as a Limit, Lagrange Multipliers and Hyperbolic Paraboloid.

What the page leaves out

Directional derivatives in other directions, second and mixed partials fxx, fxy (and Clairaut's theorem fxy = fyx), functions of three or more variables, differentiability (a function can have both partial derivatives at a point and still no tangent plane), and hidden-line removal in the 3D view.

On the mind map

Open the Calculus mind mapCalculusLimits and derivatives: slope at a point, as a limitLimits and derivativesReading derivatives: what f′ and f″ say about fReading derivativesIntegrals: add up thin slicesIntegralsSeries: a function as an infinite sumSeriesNumerical methods: approximate when exact is hardNumerical methodsDifferential equations: know the slope, find the curveDifferential equationsChaos: simple rules, unpredictable pathsChaosVector calculus: fields that spread and spinVector calculusf, f′, f″ graphsf, f′, f″ graphssign of f′: up or down; f″: concavityCritical pointsCritical pointsf′ = 0 or undefined: max, min or neitherMean value theoremMean value theoremsome tangent is parallel to the secantLevel curvesLevel curvesclose contour lines mean steep groundLagrange multipliersLagrange multipliersoptimum where ∇f = λ∇g, curves tangentOptimization problemsOptimization problemsmax where f′ = 0, check the endsRelated ratesRelated ratesdifferentiate the link with timePartial derivativesslice the surface, take one slopeOpen the Calculus mind mapCalculuswhat f′ and f″ say about fReading derivativesf, f′, f″ graphsf, f′, f″ graphssign of f′: up or down; f″: concavityCritical pointsCritical pointsf′ = 0 or undefined: max, min or neitherMean value theoremMean value theoremsome tangent is parallel to the secantLevel curvesLevel curvesclose contour lines mean steep groundLagrange multipliersLagrange multipliersoptimum where ∇f = λ∇g, curves tangentOptimization problemsOptimization problemsmax where f′ = 0, check the endsRelated ratesRelated ratesdifferentiate the link with timePartial derivativesslice the surface, take one slope
This page on the Calculus mind map · 42 pages in 8 branches · open it to see the whole map and test yourself in recall mode.