8. Functions of several variables: level curves and surfaces

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

Every function so far has taken one number and produced one number. Temperature depends on both latitude and longitude; the volume of a cylinder depends on both radius and height. This module rebuilds calculus for functions that take more than one input — starting, before any derivative is touched, with how to even visualize such a function at all.

Functions of two variables

z=f(x,y)

assigns a number z to each point (x,y) in some region of the plane (the domain). The most direct way to visualize f is as a surface in three-dimensional space — plot the point (x,y,z) for every (x,y) in the domain, and the collection forms a surface, the same way y=f(x) formed a curve back in §1.0. §9.3's preview of the paraboloid z=x^2+y^2 was exactly this: the graph of a two-variable function.

A full 3D surface is often hard to read from a flat page or screen. There's a second, frequently more practical way to visualize f.

Level curves

A level curve (or contour) is the set of points where f takes a constant value c:

f(x,y)=c

Plotted in the flat xy-plane (not in 3D at all), a family of level curves for several values of c works exactly like a topographic map: each curve traces out a fixed "elevation," and curves packed closely together indicate the surface is climbing or descending steeply there, while widely spaced curves indicate a gentle slope. This single idea — slicing a surface horizontally and looking straight down — turns a three-dimensional visualization problem into a two-dimensional one, which is why level curves are the standard tool for understanding multivariable functions before any calculus is applied to them at all.

Reading a function's shape from its level curves:

  • f(x,y)=x^2+y^2: level curves x^2+y^2=c are circles of radius \sqrt c — evenly spaced, concentric rings, the signature of a bowl-shaped paraboloid that's symmetric in every horizontal direction.
  • f(x,y)=y-x^2: level curves y-x^2=c, i.e. y=x^2+c, are identical parabolas, just shifted vertically — a "trough" shape that runs along a curved path rather than radiating outward symmetrically.
  • f(x,y)=x^2-y^2: level curves x^2-y^2=c are hyperbolas (or, at c=0, a pair of crossing lines y=\pm x) — the signature of a saddle shape, rising in one direction and falling in the perpendicular direction simultaneously, previewed again in §10.6's extrema classification.

Functions of three variables and level surfaces

w=f(x,y,z)

takes a point in space and returns a number — think of w as temperature or pressure at position (x,y,z). Its graph would need four dimensions (three inputs plus one output), impossible to draw directly — but the level-curve idea still works, one dimension up: a level surface f(x,y,z)=c is an ordinary surface in three-dimensional space, exactly the kind §9.3 introduced. A sphere x^2+y^2+z^2=r^2 is literally a level surface of f(x,y,z)=x^2+y^2+z^2 at the constant value c=r^2.

Doing it in Python

Finding the equation of specific level curves for f(x,y)=x^2+y^2:

import sympy as sp

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

for c_val in (1, 4, 9):
    level_curve = sp.Eq(f, c_val)
    print(f"level curve at c={c_val}: {level_curve}  (a circle of radius {sp.sqrt(c_val)})")

Comparing the shapes of level curves for a bowl (paraboloid) versus a saddle, by evaluating f on a small grid and observing the pattern:

def bowl(x, y):
    return x**2 + y**2

def saddle(x, y):
    return x**2 - y**2

print(f"{'(x,y)':>10} {'bowl':>8} {'saddle':>8}")
for x in (-1, 0, 1):
    for y in (-1, 0, 1):
        print(f"({x:>2},{y:>2})   {bowl(x,y):>8} {saddle(x,y):>8}")
print("\nbowl: same sign everywhere, min at origin")
print("saddle: positive along x-axis, negative along y-axis -- a saddle point at origin")

Confirming a sphere is a level surface of a three-variable function:

import sympy as sp

x, y, z, r = sp.symbols('x y z r', positive=True)
f = x**2 + y**2 + z**2

level_surface = sp.Eq(f, r**2)
print(f"level surface f(x,y,z)=r^2: {level_surface}")
print("this is exactly the equation of a sphere of radius r, from section 9.3")

Worked example

Describe the level curves of f(x,y)=x^2-y^2 for c=0,1,4.

x^2-y^2=c

At c=0: x^2=y^2\Rightarrow y=\pm x — two straight lines through the origin, crossing at 45°.

At c=1: x^2-y^2=1 — a hyperbola opening left-right, vertices at (\pm1,0), approaching the same two lines y=\pm x as asymptotes far from the origin.

At c=4: x^2-y^2=4 — the same family of hyperbola, vertices further out at (\pm2,0).

\boxed{\text{a family of hyperbolas opening left-right, degenerating to a pair of crossing lines at }c=0}

Sanity check. Along the x-axis (y=0), f(x,0)=x^2 — increasing as |x| grows, matching the hyperbolas opening in the x-direction with larger c farther out. Along the y-axis (x=0), f(0,y)=-y^2decreasing, so the level curves for negative c (not asked here, but worth noting) would instead be hyperbolas opening up-down. The function rises along one axis and falls along the perpendicular one — precisely the saddle behavior flagged in the concept section. ✓

Your turn

1. Describe the level curves of f(x,y)=4x^2+y^2 for c=1,4 (an elliptical paraboloid rather than a circular one).

2. Describe the level curve of f(x,y)=\dfrac yx at c=2 (careful: this function isn't defined at x=0).

3. True or false: two different level curves of the same function f(x,y) (for two different values of c) can cross each other.

Solutions

1. 4x^2+y^2=c\Rightarrow\dfrac{x^2}{c/4}+\dfrac{y^2}c=1 — an ellipse, with semi-axis \dfrac{\sqrt c}2 along x and \sqrt c along y. At c=1: semi-axes \dfrac12 and 1. At c=4: semi-axes 1 and 2 — twice as large in both directions, but the same 1:2 ratio between the axes throughout, since that ratio is fixed by the 4x^2 versus y^2 coefficients, not by c.

2. \dfrac yx=2\Rightarrow y=2x — a straight line through the origin (excluding the origin itself, where f is undefined), with slope 2. Every level curve of this function is a line of some slope through the origin — f(x,y)=y/x measures exactly that slope.

3. False. If two level curves f(x,y)=c_1 and f(x,y)=c_2 (with c_1\ne c_2) crossed at some point (x_0,y_0), that single point would need to satisfy f(x_0,y_0)=c_1 and f(x_0,y_0)=c_2 simultaneously — impossible, since f can only output one value at any given point (that's the definition of a function). Level curves for different constants never intersect, exactly the way the elevation contours on a real topographic map never cross each other.

Check yourself in code

For f(x,y)=x^2+y^2, find the level curve equations at c=1,4,9 and the corresponding radius \sqrt c.

Print exactly this:

c=1: circle of radius 1
c=4: circle of radius 2
c=9: circle of radius 3
import sympy as sp

for c_val in (1, 4, 9):
    radius = sp.sqrt(c_val)
    print(f"c={c_val}: circle of radius ...")
import sympy as sp

for c_val in (1, 4, 9):
    radius = sp.sqrt(c_val)
    print(f"c={c_val}: circle of radius {radius}")

A function of two variables graphs as a surface in three dimensions, but its level curves — the flat-plane slices f(x,y)=c — are often the more practical way to read its shape: circles for a symmetric bowl, identical shifted parabolas for a trough, hyperbolas for a saddle. Level curves for different constants never cross, since a function can never output two values at the same point, and the same idea extends one dimension up to level surfaces for functions of three variables — a sphere being nothing more than one level surface of f(x,y,z)=x^2+y^2+z^2.

Next: what a limit even means when there are infinitely many directions to approach a point from, instead of just two.