---
title: Continuity on Metric Spaces
module: Limits and Continuity
moduleNumber: 4
lessonNumber: 5
order: 405
summary: >
  The epsilon–delta definition used only distances, so continuity transfers to
  maps between metric spaces by replacing absolute values with the two metrics.
  In this generality continuity still admits a sequential form, preserves
  compactness and connectedness, is uniform on a compact domain, and reads
  topologically as preimages of open sets being open, the formulation that
  defines homeomorphisms.
topics: [Limits and Continuity]
sources:
  - book: Lebl
    ref: "Ch. 7 — Metric Spaces; §7.5 Continuous functions"
  - book: Rosenlicht
    ref: "Ch. 4 — Continuous functions"
draft: false
---

Nothing in the [definition of continuity](/real-analysis/continuity/continuous-functions)
used the arithmetic of $\mathbb{R}$; it used only the distances $|x - c|$ between
inputs and $|f(x) - f(c)|$ between outputs. Replace those absolute values with a
[metric](/real-analysis/metric-spaces/metric-spaces-norms) on the domain and a
metric on the codomain, and the theory of real limits and continuity acquires a
general form. The abstraction covers functions of several variables, maps between
function spaces, and operators on sequences under one definition.

## Continuity between metric spaces

> **Definition (Continuity, metric form).** Let $(X, d_X)$ and $(Y, d_Y)$ be
> metric spaces and $c \in X$. A map $f : X \to Y$ is **continuous at** $c$ if for
> every $\epsilon > 0$ there is a $\delta > 0$ such that
> $$
> d_X(x, c) < \delta \implies d_Y\!\big(f(x), f(c)\big) < \epsilon.
> $$
> If this holds at every $c \in X$, then $f$ is continuous.[^lebl-def]

Read it as before: every output ball of radius $\epsilon$ around $f(c)$ is reached
by some input ball of radius $\delta$ around $c$. On $\mathbb{R}$ with the standard
metric this reduces to the old definition. The sequential characterization carries
over unchanged.

> **Proposition (Sequential characterization).** $f : X \to Y$ is continuous at
> $c$ if and only if for every sequence $x_n \to c$ in $X$, the images $f(x_n) \to
> f(c)$ in $Y$.[^lebl-def]

$$
% caption: Continuity as a ball condition: for the epsilon-ball around f(c) in Y,
% some delta-ball around c in X maps entirely inside it.
\begin{tikzpicture}[scale=1.0, font=\small]
\definecolor{acc}{HTML}{4A6FA5}
% domain
\draw[black] (0,0) circle (1.7);
\node[black, anchor=south east] at (1.6,1.3) {$X$};
\fill[acc!12] (0,0.1) circle (0.7); \draw[acc] (0,0.1) circle (0.7);
\fill[acc] (0,0.1) circle (1.6pt); \node[acc, anchor=north] at (0,0.02) {$c$};
\node[acc, anchor=south, font=\footnotesize] at (0,0.82) {input ball};
% codomain
\begin{scope}[xshift=6cm]
\draw[black] (0,0) circle (1.7);
\node[black, anchor=south west] at (-1.6,1.3) {$Y$};
\fill[acc!12] (0,0.1) circle (0.95); \draw[acc] (0,0.1) circle (0.95);
\fill[acc] (0,0.1) circle (1.6pt); \node[acc, anchor=north] at (0,0.02) {$f(c)$};
\node[acc, anchor=south, font=\footnotesize] at (0,1.08) {output ball};
\end{scope}
\draw[acc, ->, thick] (1.95,0.5) .. controls (3,1.2) .. (4.0,0.5);
\node[acc, anchor=south] at (3,1.0) {$f$};
\end{tikzpicture}
$$

> **Worked example (polynomials on $\mathbb{R}^n$).** A polynomial
> $f : \mathbb{R}^2 \to \mathbb{R}$ is continuous: if $(x_n, y_n) \to (x, y)$
> then $x_n \to x$ and $y_n \to y$ coordinatewise, and the sequence limit laws
> give $f(x_n, y_n) \to f(x, y)$.

> **Worked example (separate versus joint continuity).** Let $f(x, y) =
> \frac{xy}{x^2 + y^2}$ off the origin and $f(0,0) = 0$. For each fixed $x$, the
> map $y \mapsto f(x,y)$ is continuous, and likewise for each fixed $y$, yet $f$
> is not continuous at the origin: along the line $y = x$,
> $$
> f(x, x) = \frac{x^2}{x^2 + x^2} = \frac{1}{2} \quad (x \neq 0),
> $$
> so the sequence $(1/n, 1/n) \to (0,0)$ has images constantly $\tfrac{1}{2}
> \neq 0 = f(0,0)$. Continuity in each variable separately does not imply joint
> continuity; the metric definition, which lets $(x,y)$ approach the origin along
> any path, is strictly stronger than the two one-variable conditions.

> **Worked example (discrete domain).** Let $X$ carry the discrete metric
> ($d(p,q) = 1$ for $p \neq q$, $d(p,p) = 0$) and let $f : X \to Y$ be **any**
> map into any metric space. Given $\epsilon > 0$, take $\delta = \tfrac{1}{2}$:
> the only $x$ with $d(x, c) < \tfrac{1}{2}$ is $c$ itself, and
> $d_Y(f(c), f(c)) = 0 < \epsilon$. Every map out of a discrete space is
> continuous; the domain's metric can trivialize the condition.

$$
% caption: The saddle xy over x-squared plus y-squared: constant along each ray
% through the origin at a value set by the ray's slope, so approaching along
% different lines gives different limits and joint continuity fails.
\begin{tikzpicture}[scale=1.0, font=\small]
\definecolor{acc}{HTML}{4A6FA5}
\definecolor{wrn}{HTML}{B0672F}
\draw[black, ->] (-2.6,0) -- (2.6,0) node[anchor=north] {$x$};
\draw[black, ->] (0,-2.2) -- (0,2.4) node[anchor=east] {$y$};
% rays with values
\draw[acc, thick] (-2.2,-2.2) -- (2.2,2.2);
\node[acc, anchor=south west, font=\footnotesize] at (1.5,1.5) {value $\frac{1}{2}$};
\draw[wrn, thick] (-2.2,2.2) -- (2.2,-2.2);
\node[wrn, anchor=south east, font=\footnotesize] at (-1.5,1.5) {opposite sign here};
\draw[black, thick] (-2.4,0) -- (2.4,0);
\node[black, anchor=north east, font=\footnotesize] at (-1.5,-0.05) {value $0$};
\fill[black] (0,0) circle (1.8pt);
\node[black, anchor=south west, font=\footnotesize] at (0.08,0.1) {origin};
\end{tikzpicture}
$$

## Compactness and the extreme value theorem

The proof that a continuous function attains its extremes on $[a,b]$ used only
that $[a,b]$ is [compact](/real-analysis/metric-spaces/compactness). In a metric
space the same argument, via sequential compactness, gives the general statement.

> **Lemma (Continuous image of compact is compact).** If $f : X \to Y$ is
> continuous and $K \subseteq X$ is compact, then $f(K)$ is compact.[^lebl-cpt]

> **Proof.** Any sequence in $f(K)$ is $\{f(x_n)\}$ for some $\{x_n\}$ in $K$;
> sequential compactness of $K$ gives a subsequence $x_{n_j} \to x \in K$, and
> continuity sends $f(x_{n_j}) \to f(x) \in f(K)$. So every sequence in $f(K)$
> has a subsequence converging within $f(K)$.

> **Theorem (Extreme value theorem, general form).** If $(X, d)$ is a nonempty
> compact metric space and $f : X \to \mathbb{R}$ is continuous, then $f$ is
> bounded and attains an absolute minimum and maximum.[^lebl-cpt]

> **Proof.** The image $f(X) \subseteq \mathbb{R}$ is compact, hence closed and
> bounded, hence contains its supremum and infimum, and those are attained at
> points of $X$.

The statement about closed bounded intervals is the special case $X = [a,b]$.

Continuity likewise preserves [connectedness](/real-analysis/metric-spaces/connectedness):
the image of a connected space under a continuous map is connected. This is the
general intermediate value theorem: if $X$ is connected and $f : X \to \mathbb{R}$
is continuous, $f$ takes every value between any two of its values.

$$
% caption: A continuous map carries a compact set to a compact set and a
% connected set to a connected set; both structural properties survive the arrow.
\begin{tikzpicture}[scale=1.0, font=\small,
  bx/.style={draw, black, minimum width=20mm, minimum height=13mm, align=center, font=\footnotesize}]
\definecolor{acc}{HTML}{4A6FA5}
\node[bx] (kc) at (0,1.3) {$K$ compact};
\node[bx] (fc) at (5.4,1.3) {$f(K)$ compact};
\node[bx] (cc) at (0,-1.0) {$C$ connected};
\node[bx] (fcc) at (5.4,-1.0) {$f(C)$ connected};
\draw[acc, ->, thick] (kc) -- (fc) node[midway, above, font=\footnotesize] {$f$};
\draw[acc, ->, thick] (cc) -- (fcc) node[midway, above, font=\footnotesize] {$f$};
\node[black, anchor=west, font=\footnotesize] at (6.7,1.3) {extreme values};
\node[black, anchor=west, font=\footnotesize] at (6.7,-1.0) {intermediate values};
\end{tikzpicture}
$$

## The topological characterization

The formulation that generalizes most cleanly drops $\epsilon$ and $\delta$ and
speaks only of [open sets](/real-analysis/metric-spaces/open-closed-sets).

> **Lemma (Local form).** $f : X \to Y$ is continuous at $c$ if and only if for
> every open neighborhood $U$ of $f(c)$, the preimage $f^{-1}(U)$ contains an open
> neighborhood of $c$.[^lebl-top]

> **Theorem (Global form).** $f : X \to Y$ is continuous if and only if
> $f^{-1}(U)$ is open in $X$ for every open $U \subseteq Y$.[^lebl-top]

> **Proof.** If $f$ is continuous and $U$ is open, then for $c \in f^{-1}(U)$
> some ball $B_Y(f(c), \epsilon) \subseteq U$; continuity gives $\delta$ with
> $B_X(c, \delta) \subseteq f^{-1}(B_Y(f(c),\epsilon)) \subseteq f^{-1}(U)$, so
> $f^{-1}(U)$ is open. Conversely, openness of the preimages of the balls around
> $f(c)$ yields the required $\delta$.

$$
% caption: Local topological continuity: for any open U around f(c), the preimage
% contains an open neighborhood W of c that f maps into U.
\begin{tikzpicture}[scale=1.0, font=\small]
\definecolor{acc}{HTML}{4A6FA5}
% domain with preimage and W
\draw[black] (0,0) circle (1.9);
\node[black, anchor=south east] at (1.8,1.5) {$X$};
\fill[acc!8] (-0.1,0) ellipse (1.2 and 1.0);
\draw[acc!45] (-0.1,0) ellipse (1.2 and 1.0);
\node[acc, anchor=south, font=\footnotesize] at (-0.1,1.0) {preimage of $U$};
\fill[acc!18] (-0.2,-0.1) circle (0.5); \draw[acc] (-0.2,-0.1) circle (0.5);
\fill[acc] (-0.2,-0.1) circle (1.5pt); \node[acc, anchor=north, font=\footnotesize] at (-0.2,-0.2) {$c$};
\node[acc, font=\footnotesize] at (-0.2,0.28) {$W$};
% codomain with U
\begin{scope}[xshift=6cm]
\draw[black] (0,0) circle (1.9);
\node[black, anchor=south west] at (-1.8,1.5) {$Y$};
\fill[acc!12] (0.1,0) ellipse (1.1 and 0.9); \draw[acc] (0.1,0) ellipse (1.1 and 0.9);
\node[acc, anchor=south, font=\footnotesize] at (0.1,0.9) {$U$};
\fill[acc] (0.1,-0.05) circle (1.5pt); \node[acc, anchor=north, font=\footnotesize] at (0.1,-0.15) {$f(c)$};
\end{scope}
\draw[acc, ->, thick] (1.6,0.4) .. controls (3,1.3) .. (4.3,0.4);
\node[acc, anchor=south] at (3,1.1) {$f$};
\end{tikzpicture}
$$

> **Worked example (a preimage computed).** Take $f(x) = x^2$ on $\mathbb{R}$ and
> the open interval $U = (1, 4)$. Then
> $$
> f^{-1}(U) = \{x : 1 < x^2 < 4\} = (-2, -1) \cup (1, 2),
> $$
> a union of two open intervals, hence open — as the theorem requires. The
> preimage need not be an interval or resemble $U$ in any way; only openness is
> promised. By contrast the jump function $g(x) = 0$ ($x < 0$), $g(x) = 1$
> ($x \ge 0$) has $g^{-1}\big((\tfrac{1}{2}, \tfrac{3}{2})\big) = [0, \infty)$,
> which is not open, certifying the discontinuity at $0$ without any
> $\epsilon$–$\delta$ work.

> **Worked example (zero sets are closed).** If $f : X \to \mathbb{R}$ is
> continuous, then $\{0\}$ is closed in $\mathbb{R}$, so $f^{-1}(\{0\}) =
> \{x : f(x) = 0\}$ is closed in $X$: the zero set of a continuous function, in
> particular of a polynomial, is closed. Likewise $\{f > 0\}$ is open and
> $\{f \ge 0\}$ is closed.

## Uniform continuity and homeomorphisms

The definition of uniform continuity transfers the same way.

> **Definition (Uniform continuity, metric form).** $f : X \to Y$ is uniformly
> continuous if for every $\epsilon > 0$ there is a $\delta > 0$ with
> $d_X(p, q) < \delta \implies d_Y(f(p), f(q)) < \epsilon$ for all $p, q \in
> X$.[^lebl-unif]

> **Theorem.** A continuous map on a compact metric space is uniformly
> continuous.[^lebl-unif]

> **Proof.** The compact-interval proof generalizes through the **Lebesgue
> covering lemma**: cover $X$ by balls $B(c, \delta_c)$ on which $f$ varies by
> less than $\epsilon/2$; compactness yields a single $\delta$ such that every
> $\delta$-ball fits inside some $B(c, \delta_c)$, and the triangle inequality
> finishes the proof.

As on the line, Lipschitz maps (those with $d_Y(f(p), f(q)) \le K\,d_X(p, q)$)
are uniformly continuous, with $\delta = \epsilon/K$.

The open-set formulation also defines the maps that identify two metric spaces
topologically.

> **Definition (Homeomorphism).** A bijection $f : X \to Y$ is a
> **homeomorphism** if both $f$ and $f^{-1}$ are continuous. Equivalently, $f$ is
> a bijection under which a set is open exactly when its image is open.

A continuous bijection need not have a continuous inverse in general, but
compactness forces it: a continuous bijection from a compact space to a metric
space is automatically a homeomorphism, since it carries closed (hence compact)
sets to compact, hence closed, sets, so preimages under $f^{-1}$ of closed sets
are closed. Homeomorphisms preserve every property defined purely from the open
sets, compactness and connectedness among them.

Two settings on the real line fall outside this metric picture: limits as the
variable runs off to $\pm\infty$, and the control that
[monotonicity](/real-analysis/continuity/limits-infinity-monotone) imposes on
where a function may be discontinuous. Both use the order of $\mathbb{R}$, which
a general metric space lacks.

[^lebl-def]: **Lebl**, _Basic Analysis I_, §7.5 — Definition 7.5.1 and Proposition 7.5.2 (continuity between metric spaces and its sequential characterization).
[^lebl-cpt]: **Lebl**, _Basic Analysis I_, §7.5 — Lemma 7.5.5 (continuous image of a compact set) and Theorem 7.5.6 (extreme value theorem on a compact metric space).
[^lebl-top]: **Lebl**, _Basic Analysis I_, §7.5 — Lemma 7.5.7, Theorem 7.5.8, and Example 7.5.9 (topological characterization of continuity; zero sets closed).
[^lebl-unif]: **Lebl**, _Basic Analysis I_, §7.5 — Definition 7.5.10, Theorem 7.5.11 (continuity on a compact space is uniform), and Example 7.5.13 (Lipschitz maps).
