---
title: Functions of Several Variables, Limits, and Continuity
module: Partial Derivatives
moduleNumber: 11
lessonNumber: 1
order: 1101
summary: >
  A function of several variables assigns one number to each point of a region in
  the plane or in space. Domain, graph, level curve, and level surface describe
  it; limits and continuity extend to two variables, where a limit must agree
  along every path of approach, not just from the left and the right.
topics: [Partial Derivatives]
draft: false
sources:
  - book: Stewart
    ref: "Ch. 14 — Partial Derivatives; §14.1 Functions of Several Variables"
  - book: Stewart
    ref: "Ch. 14; §14.2 Limits and Continuity"
---

Single-variable calculus studies quantities that depend on one input. Most
quantities depend on several. The temperature on a metal plate depends on both
coordinates of a point; the volume of a cylinder depends on radius and height;
the wind-chill index depends on temperature and wind speed. Differentiating and
integrating such quantities rests on two objects: the functions themselves and
the limit that underlies calculus in more than one variable.

## Functions of two variables

> **Definition (Function of two variables).** A rule $f$ that assigns to each
> ordered pair $(x, y)$ in a set $D \subseteq \mathbb{R}^2$ a unique real number
> $f(x, y)$. The set $D$ is the **domain**; the set of output values is the
> **range**. We write $z = f(x, y)$, with $x, y$ the **independent variables**
> and $z$ the **dependent variable**.

When a function is given by a formula with no stated domain, the domain is the
set of all pairs for which the formula returns a real number.[^dom]

> **Worked example.** Find the domain of $f(x, y) = \dfrac{\sqrt{x + y + 1}}{x - 1}$.
>
> The square root requires $x + y + 1 \ge 0$; the denominator requires $x \ne 1$.
> Both conditions together give
>
> $$
> D = \{(x, y) \mid x + y + 1 \ge 0,\ x \ne 1\},
> $$
>
> the closed half-plane on and above the line $y = -x - 1$, with the vertical
> line $x = 1$ removed.

$$
% caption: The domain of $\sqrt{x+y+1}/(x-1)$ is the shaded closed half-plane on
% and above $y=-x-1$, minus the dashed vertical line $x=1$ where the denominator
% vanishes.
\begin{tikzpicture}[scale=0.85, >=stealth, font=\small]
  \definecolor{acc}{HTML}{4A6FA5}
  % shaded region on and above the line y = -x-1, within the frame
  \fill[acc!12] (-2.6,1.6) -- (1.6,-2.6) -- (2.8,-2.6) -- (2.8,2.6) -- (-2.6,2.6) -- cycle;
  % axes
  \draw[->, black] (-2.9,0) -- (3.1,0) node[right, font=\footnotesize] {$x$};
  \draw[->, black] (0,-2.9) -- (0,2.9) node[above, font=\footnotesize] {$y$};
  % boundary line y = -x-1 (included: solid)
  \draw[acc, thick] (-2.6,1.6) -- (2.0,-3.0);
  \node[acc, font=\footnotesize, anchor=south west] at (-2.5,1.55) {boundary line};
  % deleted vertical line x=1 (dashed)
  \draw[black, thick, dashed] (1,-2.9) -- (1,2.9);
  \node[black, font=\footnotesize, anchor=south west] at (1.05,2.0) {$x=1$};
\end{tikzpicture}
$$

A function of three variables assigns a number $f(x, y, z)$ to each point of a
region $D \subseteq \mathbb{R}^3$, and a function of $n$ variables assigns
$f(x_1, \dots, x_n)$ to each point of $D \subseteq \mathbb{R}^n$.

## Graphs

> **Definition (Graph).** For $f$ a function of two variables with domain $D$,
> the graph is the set of points $(x, y, z)$ in $\mathbb{R}^3$ with
> $z = f(x, y)$ and $(x, y) \in D$. It is a **surface** sitting above (or below)
> the domain in the plane.

A single-variable graph is a curve in the plane; a two-variable graph is a
surface in space. The graph of a linear function $f(x, y) = ax + by + c$ is a
plane. The graph of $f(x, y) = x^2 + y^2$ is a bowl (a circular paraboloid);
the graph of $f(x, y) = \sqrt{9 - x^2 - y^2}$ is the upper half of a sphere of
radius $3$.

Drawing a surface by hand is hard, and reading three-dimensional structure off a
flat page is harder. Two flat devices carry most of the information: **traces**
and **level curves**.

A **trace** is the curve where the surface meets a plane. The vertical trace in
the plane $x = a$ is the curve $z = f(a, y)$; the vertical trace in $y = b$ is
$z = f(x, b)$. Horizontal traces $z = k$ are the level curves.

## Level curves and contour maps

> **Definition (Level curve).** The level curve of $f$ at value $k$ is the set
> of domain points where $f$ equals $k$:
> $$
> \{(x, y) \in D \mid f(x, y) = k\}.
> $$
> It is the horizontal trace $z = k$ of the graph, projected straight down onto
> the $xy$-plane.

A **contour map** draws several level curves $f(x, y) = k$ for equally spaced
values of $k$. Reading it is reading a topographic map: each curve joins points
of equal height, and the surface is steep where the curves are close together,
gentle where they are far apart.

$$
% caption: A contour map: each closed curve joins points of equal height $k$.
% The curves crowd on the left, marking a steep face, and spread on the right,
% marking a gentle one.
\begin{tikzpicture}[scale=1.0, >=stealth, font=\small]
  \definecolor{acc}{HTML}{4A6FA5}
  % nested circles with centres shifting right, so the left edges bunch and the
  % right edges spread: a hill steep on the left, gentle on the right
  \foreach \r/\cx in {0.6/-1.4, 1.0/-1.0, 1.5/-0.5, 2.1/0.1, 2.8/0.8} {
    \draw[black, thick] (\cx,0) ellipse ({\r} and {\r*0.86});
  }
  \node[fill=white, inner sep=1pt] at (-1.35,0) {\footnotesize $50$};
  \node[fill=white, inner sep=1pt] at (0.35,0)  {\footnotesize $30$};
  \node[fill=white, inner sep=1pt] at (1.6,0)   {\footnotesize $20$};
  \node[fill=white, inner sep=1pt] at (2.9,0)   {\footnotesize $10$};
  % steepness annotations
  \draw[<->, black] (-2.15,-1.55) -- (-1.35,-1.55);
  \node[anchor=north, black, font=\footnotesize] at (-1.75,-1.6) {steep};
  \draw[<->, black] (0.6,-1.55) -- (3.6,-1.55);
  \node[anchor=north, black, font=\footnotesize] at (2.1,-1.6) {gentle: curves far apart};
\end{tikzpicture}
$$

> **Worked example.** Sketch the level curves of $f(x, y) = 6 - 3x - 2y$ and of
> $f(x, y) = \sqrt{9 - x^2 - y^2}$.
>
> For the plane $f = 6 - 3x - 2y$, the level curves solve $3x + 2y = 6 - k$, a
> family of parallel lines of slope $-\tfrac{3}{2}$, one per value of $k$. Equal
> steps in $k$ produce equally spaced lines, the signature of a plane.
>
> For the hemisphere $f = \sqrt{9 - x^2 - y^2}$, the level curves solve
> $x^2 + y^2 = 9 - k^2$, concentric circles that crowd near the rim ($k \to 0$),
> where the surface plunges to the $xy$-plane.

The surface and its contour map encode the same information.

$$
% caption: A surface and its contour map are the same information. Slicing the
% bowl by horizontal planes $z=k$ and dropping the slices to the floor produces
% the level curves.
\begin{tikzpicture}[scale=1.0, >=stealth, font=\small]
  \definecolor{acc}{HTML}{4A6FA5}
  % --- left: oblique bowl with slicing planes ---
  \begin{scope}
    % axes
    \draw[->, black] (0,-0.2) -- (0,3.3) node[above, font=\footnotesize] {$z$};
    \draw[->, black] (-1.7,-0.9) -- (1.9,0.55) node[right, font=\footnotesize] {$y$};
    \draw[->, black] (-1.4,-0.6) -- (1.5,-1.35) node[below, font=\footnotesize] {$x$};
    % parabola outline (a trace of the bowl)
    \draw[black, thick] (-1.5,3.0) .. controls (-0.7,0.3) and (0.7,0.3) .. (1.5,3.0);
    % three horizontal slicing ellipses
    \draw[black] (0,2.55) ellipse (1.25 and 0.32);
    \draw[acc] (0,1.55) ellipse (0.86 and 0.22);
    \draw[black] (0,0.75) ellipse (0.5 and 0.13);
    \node[black, font=\footnotesize, anchor=west] at (1.3,2.55) {$z=k_3$};
    \node[acc, font=\footnotesize, anchor=west] at (0.92,1.55) {$z=k_2$};
  \end{scope}
  % projection arrow
  \draw[->, black, thick] (2.6,1.0) -- (3.8,1.0) node[midway, above, font=\footnotesize] {project};
  % --- right: level curves on the floor ---
  \begin{scope}[xshift=5.7cm]
    \draw[->, black] (-1.7,0) -- (1.9,0) node[right, font=\footnotesize] {$x$};
    \draw[->, black] (0,-1.7) -- (0,1.9) node[above, font=\footnotesize] {$y$};
    \draw[black, thick] (0,0) circle (1.35);
    \draw[acc, thick] (0,0) circle (0.9);
    \draw[black, thick] (0,0) circle (0.45);
    \node[black, font=\footnotesize, fill=white, inner sep=1pt] at (0,1.35) {$k_3$};
    \node[acc, font=\footnotesize, fill=white, inner sep=1pt] at (0,0.9) {$k_2$};
  \end{scope}
\end{tikzpicture}
$$

## Functions of three or more variables

A function of three variables cannot be graphed (its graph would live in
$\mathbb{R}^4$), so it is studied through its **level surfaces**.

> **Definition (Level surface).** For $f$ a function of three variables, the
> level surface at value $k$ is the surface $f(x, y, z) = k$ in $\mathbb{R}^3$.
> As $(x, y, z)$ moves along it, $f$ stays constant.

For $f(x, y, z) = x^2 + y^2 + z^2$ the level surfaces $x^2 + y^2 + z^2 = k$ are
concentric spheres of radius $\sqrt{k}$ (for $k > 0$), a nested family that fills
space. A level surface is the three-variable analog of a level curve, one
dimension up.

$$
% caption: Level surfaces of $f(x,y,z)=x^2+y^2+z^2$ are nested spheres of radius
% $\sqrt{k}$; each carries a single value of $f$.
\begin{tikzpicture}[scale=1.0, >=stealth, font=\small]
  \definecolor{acc}{HTML}{4A6FA5}
  \foreach \r in {0.7, 1.25, 1.8} {
    \draw[black, thick] (0,0) circle (\r);
    \draw[black!55, dashed] (0,0) ellipse ({\r} and {\r*0.34});
  }
  \node[fill=white, inner sep=1pt, font=\footnotesize] at (0,0.7)  {$k=1$};
  \node[fill=white, inner sep=1pt, font=\footnotesize] at (0,1.25) {$k=4$};
  \node[fill=white, inner sep=1pt, font=\footnotesize] at (0,1.8)  {$k=9$};
  \fill[black] (0,0) circle (1.3pt);
\end{tikzpicture}
$$

## Limits of two-variable functions

The single-variable limit $\lim_{x \to a} f(x) = L$ requires the left limit and
the right limit to agree; $x$ can approach $a$ from only two sides. In the plane,
$(x, y)$ can approach $(a, b)$ along infinitely many paths, and the limit must
give the same value along all of them.

> **Definition (Limit).** Let $f$ be defined on a set containing points
> arbitrarily close to $(a, b)$. Then
> $$
> \lim_{(x, y) \to (a, b)} f(x, y) = L
> $$
> means: for every $\varepsilon > 0$ there is a $\delta > 0$ such that whenever
> $(x, y)$ is in the domain and
> $0 < \sqrt{(x - a)^2 + (y - b)^2} < \delta$, then $|f(x, y) - L| < \varepsilon$.

The quantity $|f(x, y) - L|$ is the distance between output and target;
$\sqrt{(x-a)^2 + (y-b)^2}$ is the distance from $(x, y)$ to $(a, b)$. So the
definition says the output can be forced within $\varepsilon$ of $L$ by keeping
the input within some disk of radius $\delta$ about $(a, b)$ — but not at the
center itself.

The multi-directional nature of the plane gives a decisive negative test.

> **Theorem (Path test for nonexistence).** If $f(x, y) \to L_1$ as
> $(x, y) \to (a, b)$ along one path, and $f(x, y) \to L_2$ along another, with
> $L_1 \ne L_2$, then $\displaystyle\lim_{(x, y) \to (a, b)} f(x, y)$ does not
> exist.

> **Worked example.** Show that $\displaystyle\lim_{(x,y)\to(0,0)} \frac{x^2 - y^2}{x^2 + y^2}$
> does not exist.
>
> Approach the origin along the $x$-axis ($y = 0$): $f(x, 0) = x^2 / x^2 = 1$, so
> the values approach $1$. Along the $y$-axis ($x = 0$): $f(0, y) = -y^2 / y^2 = -1$,
> so the values approach $-1$. Two paths give two different limits, so the limit
> does not exist.

$$
% caption: The limit of $(x^2-y^2)/(x^2+y^2)$ at the origin fails: the value is
% $+1$ everywhere on the $x$-axis but $-1$ everywhere on the $y$-axis.
\begin{tikzpicture}[scale=1.0, >=stealth, font=\small]
  \definecolor{acc}{HTML}{4A6FA5}
  \definecolor{red}{HTML}{C0392B}
  \draw[->, black] (-2.6,0) -- (2.6,0) node[right, font=\footnotesize] {$x$};
  \draw[->, black] (0,-2.1) -- (0,2.3) node[above, font=\footnotesize] {$y$};
  % approach arrows along x-axis
  \draw[->, acc, very thick] (-2.2,0) -- (-0.35,0);
  \draw[->, acc, very thick] (2.2,0) -- (0.35,0);
  \node[acc, anchor=south, font=\footnotesize] at (1.5,0.06) {$f = +1$};
  \node[acc, anchor=north, font=\footnotesize] at (-1.5,-0.06) {$f = +1$};
  % approach arrows along y-axis
  \draw[->, red, very thick] (0,2.0) -- (0,0.35);
  \draw[->, red, very thick] (0,-1.8) -- (0,-0.35);
  \node[red, anchor=west, font=\footnotesize] at (0.1,1.35) {$f =$ -1};
  \node[red, anchor=west, font=\footnotesize] at (0.1,-1.2) {$f =$ -1};
  \fill[black] (0,0) circle (1.6pt);
  \node[anchor=north east, font=\footnotesize] at (-0.05,-0.05) {(0, 0)};
\end{tikzpicture}
$$

The two paths need not be the coordinate axes.

> **Worked example.** Show that $\displaystyle\lim_{(x,y)\to(0,0)} \frac{xy}{x^2 + y^2}$
> does not exist.
>
> Along the $x$-axis ($y = 0$): $f(x, 0) = 0$, so the values approach $0$. Along
> the diagonal $y = x$:
> $$
> f(x, x) = \frac{x \cdot x}{x^2 + x^2} = \frac{x^2}{2x^2} = \frac{1}{2}.
> $$
> The axis gives $0$ and the diagonal gives $\tfrac{1}{2}$, so the limit does not
> exist. The value depends on the slope of the line of approach.

$$
% caption: The limit of $xy/(x^2+y^2)$ at the origin fails: it is $0$ along the
% $x$-axis but $\tfrac12$ along the diagonal $y=x$.
\begin{tikzpicture}[scale=1.0, >=stealth, font=\small]
  \definecolor{acc}{HTML}{4A6FA5}
  \definecolor{wrm}{HTML}{C0392B}
  \draw[->, black] (-2.6,0) -- (2.6,0) node[right, font=\footnotesize] {$x$};
  \draw[->, black] (0,-2.1) -- (0,2.3) node[above, font=\footnotesize] {$y$};
  % x-axis approach (f = 0)
  \draw[->, acc, very thick] (-2.2,0) -- (-0.35,0);
  \draw[->, acc, very thick] (2.2,0) -- (0.35,0);
  \node[acc, anchor=north, font=\footnotesize] at (1.5,-0.55) {$f=0$};
  % diagonal approach y=x (f = 1/2)
  \draw[wrm, thin, dashed] (0.45,0.45) -- (2.05,2.05);
  \draw[wrm, thin, dashed] (-0.45,-0.45) -- (-1.95,-1.95);
  \draw[->, wrm, very thick] (1.75,1.75) -- (0.3,0.3);
  \draw[->, wrm, very thick] (-1.6,-1.6) -- (-0.3,-0.3);
  \node[wrm, anchor=west, font=\footnotesize] at (0.15,1.95) {$f=\tfrac{1}{2}$ on $y=x$};
  \fill[black] (0,0) circle (1.6pt);
  \node[anchor=north east, font=\footnotesize] at (-0.05,-0.05) {(0, 0)};
\end{tikzpicture}
$$

A line-independent value along every line is still not enough.

> **Worked example.** Show that $\displaystyle\lim_{(x,y)\to(0,0)} \frac{xy^2}{x^2 + y^4}$
> does not exist, even though the limit along every straight line is $0$.
>
> Every line $y = mx$ gives
> $$
> f(x, mx) = \frac{x (mx)^2}{x^2 + (mx)^4} = \frac{m^2 x}{1 + m^4 x^2} \to 0,
> $$
> and the $y$-axis gives $0$ as well. Now approach along the parabola $x = y^2$:
> $$
> f(y^2, y) = \frac{y^2 \cdot y^2}{(y^2)^2 + y^4} = \frac{y^4}{2y^4} = \frac{1}{2}.
> $$
> A path giving $\tfrac{1}{2}$ contradicts the lines giving $0$, so the limit does
> not exist. Checking finitely many paths can disprove a limit, never prove one.

To **prove** a limit exists, bound $|f(x, y) - L|$ by a quantity depending only
on the distance $r = \sqrt{x^2 + y^2}$ that vanishes as $r \to 0$, then apply the
Squeeze Theorem.

> **Worked example.** Show that $\displaystyle\lim_{(x, y) \to (0, 0)} \frac{3x^2 y}{x^2 + y^2} = 0$.
>
> Use $x^2 \le x^2 + y^2$ and $|y| \le \sqrt{x^2 + y^2}$:
> $$
> \left| \frac{3x^2 y}{x^2 + y^2} \right|
> = 3 \cdot \frac{x^2}{x^2 + y^2} \cdot |y|
> \le 3 |y|
> \le 3\sqrt{x^2 + y^2}.
> $$
> The bound $3\sqrt{x^2 + y^2} \to 0$ as $(x, y) \to (0, 0)$, so by the Squeeze
> Theorem the limit is $0$.

## Continuity

> **Definition (Continuity).** A function $f$ of two variables is continuous at
> $(a, b)$ if
> $$
> \lim_{(x, y) \to (a, b)} f(x, y) = f(a, b).
> $$
> It is continuous on a set $D$ if it is continuous at every point of $D$.

Continuity means small changes in the input produce small changes in the output:
the graph has no hole, tear, or jump. Because limits of sums, differences,
products, and quotients behave the way they do in one variable, the standard
constructions stay continuous.

- **Polynomials.** A polynomial in $x$ and $y$ is a sum of terms $c\,x^m y^n$
  ($m, n$ nonnegative integers). Every polynomial is continuous on all of
  $\mathbb{R}^2$.
- **Rational functions.** A ratio of polynomials is continuous everywhere its
  denominator is nonzero.
- **Compositions.** If $g$ is continuous at $(a, b)$ and $h$ is continuous at
  $g(a, b)$, then $h \circ g$ is continuous at $(a, b)$. Feeding a continuous
  two-variable function into $\sin$, $\exp$, or a root keeps it continuous.

> **Worked example.** Where is $g(x, y) = \dfrac{x^2 - y^2}{x^2 + y^2}$
> continuous?
>
> As a ratio of polynomials, $g$ is continuous everywhere its denominator is
> nonzero, hence on all of $\mathbb{R}^2$ except $(0, 0)$, where it is undefined.
> The earlier limit computation shows no value can be assigned there to repair
> continuity: the discontinuity at the origin is not removable.

Continuity in three or more variables reads the same way,
$\lim_{(x, y, z) \to (a, b, c)} f(x, y, z) = f(a, b, c)$, with distance measured
in $\mathbb{R}^3$. All of it collapses to the one-variable case when the extra
inputs are held fixed — the idea behind the [partial derivative](/calculus/partial-derivatives/partial-derivatives),
which slices a surface with a plane and differentiates the resulting curve.

[^dom]: Stewart, §14.1 — domain and range conventions for functions of two and three variables, with the natural-domain rule for formulas.
