Functions of Several Variables

Everything you have done in calculus so far ran on one input. A single-variable function eats one number and returns one number — and that was the right place to learn, the way you learn to ride with training wheels. But look at the quantities the world actually cares about:

A function of several variables takes a whole tuple of inputs and returns a single number,

f : D \subseteq \mathbb{R}^n \to \mathbb{R}, \qquad (x_1, \dots, x_n) \mapsto f(x_1, \dots, x_n).

The domain D is now a region of n-dimensional space, not a slice of the line. For n = 2 we write z = f(x, y), with the domain a region of the plane; for n = 3, w = f(x, y, z), with the domain a chunk of space. The output is still one honest number — what has grown is the address you feed in. Everything in this branch of calculus is the one-variable story told one variable at a time, and this page is about the first skill: reading such a function — as a table, as a surface, and as a contour map.

Evaluating, step by step

Evaluation is exactly as dull as you hope: substitute, then arithmetic. Take the function f(x, y) = x^2 + y^2 and find f(3, 4).

Step 1 — substitute the input coordinates. Put x = 3 and y = 4 into the rule:

f(3, 4) = 3^2 + 4^2.

Step 2 — evaluate each term.

= 9 + 16.

Step 3 — combine.

f(3, 4) = 25.

The order of the inputs matters in general — for g(x, y) = x^2 y we get g(2, 3) = 12 but g(3, 2) = 18 — though for this symmetric x^2 + y^2 it happens not to. An input is an ordered tuple, and swapping coordinates is generally a different point of the domain.

Worked example: the natural domain

When no domain is announced, the convention is the natural domain: every point where the formula makes sense. In one variable that gave you intervals; now it gives you regions of the plane, and finding them is a small geometry puzzle.

Example 1. f(x, y) = \sqrt{\,1 - x^2 - y^2\,}. The square root demands

1 - x^2 - y^2 \ge 0 \quad\Longleftrightarrow\quad x^2 + y^2 \le 1,

so the natural domain is the closed unit disc — every point on or inside the circle of radius 1. (The graph, if you are curious, is the upper half of the unit sphere: a perfect dome sitting on that disc.)

Example 2. g(x, y) = \ln(x + y). The logarithm demands x + y > 0, i.e. y > -x: an open half-plane, everything strictly above the line y = -x. The boundary line itself is excluded — on it the log blows up.

Notice the change of scenery: one-variable domains were unions of intervals, but a two-variable domain can be a disc, a half-plane, a plane with a curve deleted (think 1/(y - x^2), the plane minus a parabola), or something far stranger. Sketching the domain is usually the first move in any problem.

Three pictures of one function

A function of two variables can be read three ways, and fluency means moving between them freely.

1. As a table. Fix a grid of inputs and list the outputs. This is how wind chill is actually published: rows are wind speed v, columns are air temperature T, and each cell is W(T, v) in °C:

v \backslash T 0\,°\mathrm{C} -5\,°\mathrm{C} -10\,°\mathrm{C}
10 km/h−3−9−15
20 km/h−5−12−18
30 km/h−6−13−20

Read down a column and you see what more wind does at fixed temperature; read along a row and you see what colder air does at fixed wind. (That "hold one input still and vary the other" reflex is exactly the idea that becomes the partial derivative.) A table is honest but blurry — it only samples the function.

2. As a surface. The graph of z = f(x, y) lives in three dimensions: above every point (x, y) of the domain, plot the height z = f(x, y). The result is a surface — a landscape floating over the plane. The paraboloid z = x^2 + y^2 is a bowl with its lowest point at the origin (height 0 there, rising in every direction); z = -(x^2 + y^2) is the same bowl flipped into a dome; z = x^2 - y^2 is a saddle — a mountain pass that climbs along the x-axis and falls along the y-axis.

3. As a contour map — the star of this page, coming next. A surface is hard to draw on flat paper, so cartographers solved the problem centuries ago: flatten the landscape into curves of constant height.

See a surface for real

A function of two variables is a surface — a landscape of heights floating over the xy plane. Here is z = \sin x \cos y, a rolling egg-carton of hills and valleys. Drag it to rotate and explore the peaks and troughs from any angle.

Reading a contour map

A level curve (or level set) of f is the set of points where the function takes a fixed value c,

\{(x, y) : f(x, y) = c\}.

Picture slicing the surface with the horizontal plane z = c and dropping the cut edge straight down onto the floor: that shadow is the level curve. Draw the curves for several evenly spaced values of c on one plane and you have a contour map — the hiker's-map view of the function.

Worked example. For f(x, y) = x^2 + y^2 the level curve at value c is

x^2 + y^2 = c,

which for c > 0 is a circle of radius \sqrt{c}; at c = 0 it collapses to the single point at the origin (the bottom of the bowl), and for c < 0 it is empty — the bowl never dips below zero. The family is a set of nested rings, like a target. And notice the spacing: the levels c = 1, 4, 9 are equally spaced in height, but their radii 1, 2, 3 crowd closer together going outward per unit of height gained — the bowl steepens as you climb its wall, and the map shows it by bunching. Reading the map is a skill worth drilling:

Slide the level c below and watch the single curve x^2 + y^2 = c sweep outward as a growing circle.

A function of several variables is a map f : D \subseteq \mathbb{R}^n \to \mathbb{R} assigning one real number to each point of a domain D. For n = 2:

A gallery of contour shapes

Different functions leave utterly different fingerprints on the plane, and with a little practice you can name the surface from its map alone.

Worked example: f(x, y) = xy. The level curve xy = c is, for c \ne 0, the hyperbola y = c/x: for c > 0 its two branches sit in the first and third quadrants, for c < 0 in the second and fourth. The zero set xy = 0 is the pair of coordinate axes — the crossed lines that the hyperbolas hug ever closer without touching.

Worked example: f(x, y) = x^2 - y^2. Same story rotated by 45°: x^2 - y^2 = c gives hyperbolas opening left–right for c > 0 and up–down for c < 0, while c = 0 factors as (x - y)(x + y) = 0 — the crossed lines y = \pm x. This is the map of the saddle: stand at the origin and the ground rises ahead and behind (along the x-axis) and falls to your left and right (along the y-axis). Hikers know this map instantly — it is a mountain pass.

One more for the collection: a linear function f(x, y) = ax + by has level curves ax + by = c — a family of parallel, evenly spaced straight lines. The surface is a tilted plane: an infinite ramp, equally steep everywhere, which is exactly what evenly spaced contours say.

Because it is one. Atmospheric pressure is a function p(x, y) of position, and the isobars on a weather chart are precisely its level curves; isotherms are level curves of the temperature field T(x, y). All the reading rules apply verbatim: closed loops ring a HIGH (a peak of the pressure surface) or a LOW (a pit), and tightly bunched isobars mean pressure changing fast — which is where the wind howls. Even better, at large scales the wind does something delightful: instead of blowing from high to low pressure it blows along the isobars (the Earth's rotation deflects it), circling lows anticlockwise in the northern hemisphere. A forecaster glancing at contour spacing and loop direction is doing multivariable calculus by eye.

Video games pull the same trick from the other side. A game "terrain" is usually a heightmap: a grayscale image whose pixel brightness at (x, y) is the height z — literally a function z = f(x, y) stored as a table of samples, which the engine skins into the mountains you run over. Every open-world landscape you have explored was a function of two variables wearing a costume.

For w = f(x, y, z) the graph would need four dimensions, so we give up on graphs — but level sets survive beautifully: the set f(x, y, z) = c is a level surface in ordinary 3-D space. For f = x^2 + y^2 + z^2 the level surfaces are concentric spheres of radius \sqrt{c} — nested shells, the 3-D answer to the target of nested rings. The isothermal surfaces inside a heated solid, or surfaces of constant electric potential around a charge, are exactly this.

And the definition doesn't blink at n = 30: a machine-learning loss function takes millions of inputs (the model's parameters) and returns one number, and "training" is nothing but hiking downhill on that unimaginable landscape — guided by the same contour intuition you are building on this page. We can't draw \mathbb{R}^{1{,}000{,}000}, but the two-variable pictures are the intuition everyone actually uses.

See it explained