---
title: Metric Spaces, Norms, and Examples
module: Metric Spaces and Topology
moduleNumber: 3
lessonNumber: 1
order: 301
summary: >
  A metric is a function $d(x,y)$ obeying four axioms: nonnegativity, identity
  of indiscernibles, symmetry, and the triangle inequality. The Euclidean,
  taxicab, sup, discrete, and great-circle metrics all qualify, as does the sup
  metric on $C[a,b]$. Every norm induces a metric, and strongly equivalent
  metrics share the same open sets.
topics: [Metric Spaces and Topology]
draft: false
sources:
  - book: Lebl
    ref: "Ch. 7 — Metric Spaces; §7.1 Metric spaces"
  - book: Rosenlicht
    ref: "Ch. 3 — Metric spaces"
---

Every limit rests on a single number: the distance between two
things. A sequence of reals converges to $L$ when $|x_n - L|$ eventually stays
small; a function is continuous at $c$ when $f(x)$ is close to $f(c)$ whenever
$x$ is close to $c$. In each case "close" means only that $|x - y|$ is small.
If some other set carries a sensible notion of distance, every argument about
limits transfers to it without change.

A **metric space** is a set together with such a distance function, stripped
to the properties the proofs use. One definition and one set of theorems then
govern sequences in $\mathbb{R}^n$, convergence of functions, points on a
sphere, and spaces whose elements are themselves functions, so nothing about
limits has to be re-proved in each new setting.[^lebl-71]

## The metric axioms

> **Definition (Metric space).** Let $X$ be a set. A function
> $d : X \times X \to \mathbb{R}$ is a **metric** on $X$ if for all
> $x, y, z \in X$:
>
> - **(M1) Nonnegativity.** $d(x, y) \ge 0$.
> - **(M2) Identity of indiscernibles.** $d(x, y) = 0$ if and only if $x = y$.
> - **(M3) Symmetry.** $d(x, y) = d(y, x)$.
> - **(M4) Triangle inequality.** $d(x, z) \le d(x, y) + d(y, z)$.
>
> The pair $(X, d)$ is a **metric space**, and $d$ is the **distance function**.

The first three axioms encode obvious demands on a notion of distance: it is
never negative, only a point and itself are at distance zero, and the distance
from $x$ to $y$ equals the distance back. The triangle inequality (M4) is the
one with content. It says a detour through $y$ can never be a shortcut from $x$
to $z$, and essentially every estimate in analysis is an application of it.

$$
% caption: The triangle inequality: the direct distance from $x$ to $z$ (accent
% edge) is at most the sum of the two legs of the detour through $y$.
\begin{tikzpicture}[scale=1.0, font=\small]
\definecolor{acc}{HTML}{4A6FA5}
\coordinate (x) at (0,0);
\coordinate (y) at (4.2,-1.3);
\coordinate (z) at (5.4,2.1);
\fill[acc] (x) circle (2pt);
\fill[acc] (y) circle (2pt);
\fill[acc] (z) circle (2pt);
\node[below left] at (x) {$x$};
\node[below] at (y) {$y$};
\node[above right] at (z) {$z$};
\draw[acc, thick] (x) -- node[above left]{direct}  (z);
\draw[black, thick] (x) -- node[below, pos=0.5]{leg} (y);
\draw[black, thick] (y) -- node[right, pos=0.5]{leg} (z);
\node[black] at (5.2,-0.2) {detour};
\end{tikzpicture}
$$

A useful consequence, obtained by applying (M4) twice, is the **reverse
triangle inequality**:

$$
\bigl| d(x, z) - d(y, z) \bigr| \;\le\; d(x, y).
$$

It bounds how much a distance can change when one endpoint moves, and is the
metric-space form of the estimate $\bigl||a| - |b|\bigr| \le |a - b|$ from the
[real line](/real-analysis/foundations/absolute-value-bounds).

## Examples

The verifications are mechanical for (M1)–(M3); the triangle inequality is
the only step that ever takes work.

**The real line.** On $X = \mathbb{R}$, set $d(x, y) = |x - y|$. Axioms
(M1)–(M3) are immediate, and (M4) is the ordinary triangle inequality for
absolute value:

$$
|x - z| = |(x - y) + (y - z)| \le |x - y| + |y - z|.
$$

This is the **standard metric** on $\mathbb{R}$; unqualified, "$\mathbb{R}$"
means this space.

**Euclidean space.** On $X = \mathbb{R}^n$, with points
$x = (x_1, \dots, x_n)$, the standard metric is

$$
d_2(x, y) \;=\; \sqrt{\sum_{k=1}^n (x_k - y_k)^2}.
$$

Only (M4) is delicate. It follows from the Cauchy–Schwarz inequality, worth
isolating because it recurs throughout analysis.[^lebl-cs]

> **Lemma (Cauchy–Schwarz).** For $x, y \in \mathbb{R}^n$,
> $$
> \Bigl( \sum_{k=1}^n x_k y_k \Bigr)^2 \;\le\;
> \Bigl( \sum_{k=1}^n x_k^2 \Bigr)\Bigl( \sum_{k=1}^n y_k^2 \Bigr).
> $$

The lemma comes from expanding the nonnegative double sum
$\sum_{k,\ell} (x_k y_\ell - x_\ell y_k)^2 \ge 0$ and relabelling.

> **Worked example (Euclidean triangle inequality).** Write $a_k = x_k - y_k$
> and $b_k = y_k - z_k$, so that $x_k - z_k = a_k + b_k$. Squaring $d_2(x, z)$,
> $$
> d_2(x, z)^2 = \sum_{k=1}^n (a_k + b_k)^2
> = \sum_{k=1}^n a_k^2 + 2 \sum_{k=1}^n a_k b_k + \sum_{k=1}^n b_k^2.
> $$
> Cauchy–Schwarz bounds the cross term,
> $$
> \sum_{k=1}^n a_k b_k \le \sqrt{\textstyle\sum_k a_k^2}\,\sqrt{\textstyle\sum_k b_k^2}
> = d_2(x, y)\, d_2(y, z),
> $$
> so $d_2(x, z)^2 \le d_2(x, y)^2 + 2\, d_2(x, y)\, d_2(y, z) + d_2(y, z)^2 =
> \bigl( d_2(x, y) + d_2(y, z) \bigr)^2$. Taking square roots gives (M4).

**The taxicab and sup metrics.** The same set $\mathbb{R}^n$ carries other
metrics. The **taxicab** (or $\ell^1$) metric sums coordinate distances; the
**sup** (or $\ell^\infty$) metric takes the largest:

$$
d_1(x, y) = \sum_{k=1}^n |x_k - y_k|,
\qquad
d_\infty(x, y) = \max_{1 \le k \le n} |x_k - y_k|.
$$

Both satisfy all four axioms; their triangle inequalities reduce term-by-term
to the scalar case. On $\mathbb{R}^n$ these three are the working examples, and
they are genuinely different distance functions on the same underlying set.

| Metric | Formula on $\mathbb{R}^n$ | Distance from $0$ to $(1,1)$ | Unit ball |
| --- | --- | --- | --- |
| Taxicab $d_1$ | $\sum_k \lvert x_k - y_k\rvert$ | $2$ | diamond |
| Euclidean $d_2$ | $\bigl(\sum_k (x_k - y_k)^2\bigr)^{1/2}$ | $\sqrt{2}$ | disk |
| Sup $d_\infty$ | $\max_k \lvert x_k - y_k\rvert$ | $1$ | square |

> **Worked example (Discrete metric).** On _any_ set $X$, define
> $$
> d(x, y) =
> \begin{cases}
> 0 & \text{if } x = y, \\
> 1 & \text{if } x \ne y.
> \end{cases}
> $$
> (M1)–(M3) hold by inspection. For (M4), fix $x, y, z$. If $x = z$ the left
> side is $0$, at most the right. If $x \ne z$, then $x$ differs from at least
> one of $y, z$ (otherwise $x = y = z$), so at least one term on the right is
> $1$ and $d(x, z) = 1 \le d(x, y) + d(y, z)$. Every pair of distinct points is
> at distance $1$.

The discrete metric serves as a stress test: a claim about metric spaces that
fails under it is false in general. It also shows a set with no numerical
structure can still be a metric space.

**A bounded remetrization of $\mathbb{R}$.** The function

$$
d(x, y) = \frac{|x - y|}{1 + |x - y|}
$$

is a metric on $\mathbb{R}$ under which every pair of points is less than $1$
apart. It is $\varphi(|x-y|)$ for the increasing, subadditive $\varphi(t) =
t/(1+t)$, and subadditivity of $\varphi$ gives (M4). The same set can thus
be bounded under one metric and unbounded under another, so boundedness is a
property of the metric, not of the set alone.

**Continuous functions.** Let $C[a,b]$ be the set of continuous
$f : [a, b] \to \mathbb{R}$, with the sup metric
$d_\infty(f, g) = \sup_{t \in [a,b]} |f(t) - g(t)|$.

> **Worked example (Sup metric on $C[a,b]$).** The supremum is finite because
> $f - g$ is continuous on a closed bounded interval, hence bounded, so
> $d_\infty(f, g) \in \mathbb{R}$. (M1)–(M3) are direct. For (M4), the pointwise
> triangle inequality gives, for every $t \in [a, b]$,
> $$
> |f(t) - h(t)| \le |f(t) - g(t)| + |g(t) - h(t)| \le d_\infty(f, g) + d_\infty(g, h).
> $$
> The right side is an upper bound for $|f(t) - h(t)|$ independent of $t$, so it
> dominates the supremum: $d_\infty(f, h) \le d_\infty(f, g) + d_\infty(g, h)$.

Two functions are close in this metric exactly when their graphs stay uniformly
near each other, so the largest vertical gap between the graphs _is_ the
distance.

$$
% caption: The sup metric on $C[a,b]$: the distance between $f$ and $g$ is the
% largest vertical gap between their graphs, attained at some point $t_0$.
\begin{tikzpicture}[scale=1.0, font=\small]
\definecolor{acc}{HTML}{4A6FA5}
\draw[->, black] (0,0) -- (6.4,0) node[right]{$t$};
\draw[->, black] (0,-0.3) -- (0,3.2);
\node[below] at (0.6,0) {$a$};
\node[below] at (5.8,0) {$b$};
\draw[black, dashed] (0.6,-0.15) -- (0.6,0.15);
\draw[black, dashed] (5.8,-0.15) -- (5.8,0.15);
% curve f (upper)
\draw[acc, thick] (0.6,1.6) .. controls (2.2,2.9) and (3.6,2.4) .. (5.8,2.8) node[right]{$f$};
% curve g (lower)
\draw[black, thick] (0.6,0.9) .. controls (2.4,0.5) and (3.8,1.6) .. (5.8,1.3) node[right]{$g$};
% largest gap at t0
\draw[acc, very thick, <->] (2.9,2.68) -- (2.9,0.86);
\node[acc, right] at (2.95,1.8) {sup gap};
\draw[black, dashed] (2.9,0) -- (2.9,0.86);
\node[below] at (2.9,0) {$t_0$};
\end{tikzpicture}
$$

Treating a whole set of functions as points in one metric space is
what makes uniform convergence, and fixed-point arguments such as
[Picard's theorem](/real-analysis/function-sequences/picard-ode), a matter of
convergence in a single space.

**The sphere.** On the unit sphere $S^2 = \{ x \in \mathbb{R}^3 :
x_1^2 + x_2^2 + x_3^2 = 1 \}$, the **great-circle distance** takes $d(x, y)$ to
be the angle $\theta \in [0, \pi]$ between the radii to $x$ and $y$, computable
as $d(x, y) = \arccos(x_1 y_1 + x_2 y_2 + x_3 y_3)$. The first three axioms are
clear; the triangle inequality is the spherical law of cosines. This is the
distance used on the surface of the earth, and it is not the restriction of the
Euclidean metric of $\mathbb{R}^3$ (that would be the straight-line chord
through the interior). The same point set thus supports two natural, different
metrics.

### The discrete metric as a source of counterexamples

The discrete metric is extreme, and any claim that looks obvious from Euclidean
pictures should be checked against it. A ball is either a single point or the
whole space; every set is bounded and closed; and there is no notion of
"between". When a statement about metric spaces holds for Euclidean space but
fails under the discrete metric, the Euclidean intuition was using structure the
axioms do not provide.

## Norms

Most of these metrics measure distance as the "size" of a difference vector.
Abstracting that pattern gives a **norm**, the source of nearly every metric on
a vector space.[^rosen-3]

> **Definition (Norm).** A **norm** on a real vector space $V$ is a function
> $\lVert \cdot \rVert : V \to \mathbb{R}$ such that for all $x, y \in V$ and
> scalars $\alpha$:
>
> - $\lVert x \rVert \ge 0$, with $\lVert x \rVert = 0$ iff $x = 0$;
> - $\lVert \alpha x \rVert = |\alpha|\,\lVert x \rVert$ (homogeneity);
> - $\lVert x + y \rVert \le \lVert x \rVert + \lVert y \rVert$ (triangle
>   inequality).

Every norm induces a metric by measuring the size of the difference.

> **Proposition (Norm induces a metric).** If $\lVert \cdot \rVert$ is a norm
> on $V$, then $d(x, y) = \lVert x - y \rVert$ is a metric on $V$.

Nonnegativity and (M2) come from the first norm axiom; symmetry from
homogeneity with $\alpha = -1$; and (M4) from the norm's triangle inequality,
since $x - z = (x - y) + (y - z)$. The three metrics on $\mathbb{R}^n$ arise
this way from the **$\ell^p$ norms**

$$
\lVert x \rVert_p = \Bigl( \sum_{k=1}^n |x_k|^p \Bigr)^{1/p}
\ \ (p \ge 1),
\qquad
\lVert x \rVert_\infty = \max_{1 \le k \le n} |x_k|,
$$

with $p = 1$ giving taxicab, $p = 2$ Euclidean, and the limiting case the sup
norm. The metrics differ, but their **unit balls** show the difference most
clearly: the set $\{x : \lVert x \rVert \le 1\}$ is a diamond for $\ell^1$, the
round disk for $\ell^2$, and a square for $\ell^\infty$.

$$
% caption: Unit balls of the three norms on $\mathbb{R}^2$: the taxicab
% diamond sits inside the Euclidean disk, which sits inside the sup square.
\begin{tikzpicture}[scale=1.5, font=\small]
\definecolor{acc}{HTML}{4A6FA5}
\draw[->, black] (-1.5,0) -- (1.5,0) node[right]{$x_1$};
\draw[->, black] (0,-1.5) -- (0,1.5) node[above]{$x_2$};
% sup square
\draw[black, thick] (-1,-1) rectangle (1,1);
\node[black] at (1.02,1.18) {sup};
% euclidean disk
\draw[acc, thick] (0,0) circle (1);
\node[acc] at (0.86,0.86) {Euclidean};
% taxicab diamond
\draw[black, thick, fill=acc!10] (1,0) -- (0,1) -- (-1,0) -- (0,-1) -- cycle;
\node[black] at (1.15,-1.15) {taxicab};
\end{tikzpicture}
$$

The nesting $\{\lVert x \rVert_\infty \le 1\} \supseteq \{\lVert x \rVert_2 \le
1\} \supseteq \{\lVert x \rVert_1 \le 1\}$ reflects the pointwise inequality
$\lVert x \rVert_\infty \le \lVert x \rVert_2 \le \lVert x \rVert_1$ on
$\mathbb{R}^n$. On a _finite_-dimensional space these norms also satisfy
reverse bounds like $\lVert x \rVert_1 \le \sqrt{n}\,\lVert x \rVert_2$, so any
two are within constant factors of each other.

> **Definition (Strongly equivalent metrics).** Two metrics $d, d'$ on the same
> set $X$ are **strongly equivalent** if there are constants $\alpha, \beta > 0$
> with $\alpha\, d(x, y) \le d'(x, y) \le \beta\, d(x, y)$ for all $x, y$.

The three $\ell^p$ metrics on $\mathbb{R}^n$ are pairwise strongly equivalent.
Strong equivalence forces a ball of one metric to sit inside a ball of the other
and vice versa, so the two metrics have the _same open sets_, the same
convergent sequences, and the same continuous functions, even though they assign
different numerical distances. Properties unchanged by remetrization (open,
convergent, compact) are topological; properties that do change (the numerical
value of a distance, whether a specific radius works) are metric-specific. The
distinction recurs when the
[topology](/real-analysis/metric-spaces/open-closed-sets) is built.

## Balls, boundedness, and diameter

Every later definition is built from one geometric object, the ball: all points
within a fixed distance of a center.

> **Definition (Open and closed ball).** In a metric space $(X, d)$, for
> $x \in X$ and $\delta > 0$, the **open ball** and **closed ball** of radius
> $\delta$ about $x$ are
> $$
> B(x, \delta) = \{ y \in X : d(x, y) < \delta \},
> \qquad
> C(x, \delta) = \{ y \in X : d(x, y) \le \delta \}.
> $$

The shape of a ball depends entirely on the metric. In $\mathbb{R}$ with the
standard metric, $B(x, \delta) = (x - \delta, x + \delta)$ is an open interval.
On $\mathbb{R}^2$ the unit balls of the three norms above are the diamond,
disk, and square. Under the discrete metric on any $X$, $B(x, \delta) = \{x\}$
for $\delta \le 1$ and $B(x, \delta) = X$ for $\delta > 1$: the balls have only
two possible shapes.

Boundedness is expressed through balls: a set is bounded when it fits inside
one.

> **Definition (Bounded set, diameter).** A subset $S \subseteq X$ is
> **bounded** if there exist $p \in X$ and $B \in \mathbb{R}$ with
> $d(p, x) \le B$ for all $x \in S$. For nonempty $S$, its **diameter** is
> $$
> \operatorname{diam}(S) = \sup \{ d(x, y) : x, y \in S \},
> $$
> and $S$ is bounded exactly when $\operatorname{diam}(S) < \infty$.

For subsets of $\mathbb{R}$ this recovers the earlier notion of a
[bounded set](/real-analysis/foundations/absolute-value-bounds): every element
lies within a fixed distance of a reference point. The choice of reference
point $p$ does not matter, since moving it changes the required $B$ by only
$d(p, p')$ by the triangle inequality. Under the discrete metric every set has
diameter at most $1$, so every set is bounded, whatever its size.

$$
% caption: A bounded set $S$ sits inside a ball $C(p, B)$ about a reference
% point; its diameter is the largest distance between two of its points.
\begin{tikzpicture}[scale=1.0, font=\small]
\definecolor{acc}{HTML}{4A6FA5}
\draw[black, thick, dashed] (1.4,0.7) circle (2.3);
\node[black] at (3.7,2.85) {ball about $p$};
\draw[black, thick, fill=acc!8] plot[smooth cycle, tension=0.7]
  coordinates {(0.2,0.4) (1.6,-0.5) (2.7,0.6) (2.2,1.8) (0.6,1.6)};
\node[black] at (1.9,1.3) {$S$};
\fill[acc] (1.4,0.7) circle (1.5pt);
\node[above] at (1.4,0.78) {$p$};
\fill[black] (0.35,0.7) circle (1.6pt);
\node[left] at (0.3,0.7) {$a$};
\fill[black] (2.6,0.75) circle (1.6pt);
\node[right] at (2.65,0.75) {$b$};
\draw[acc, very thick, <->] (0.42,0.55) -- (2.52,0.6);
\node[acc, below, font=\scriptsize] at (1.45,0.5) {diam};
\end{tikzpicture}
$$

## Subspaces

Any subset of a metric space is a metric space in its own right, by simply
restricting $d$.

> **Definition (Subspace).** If $(X, d)$ is a metric space and $Y \subseteq X$,
> then $d' = d|_{Y \times Y}$ is a metric on $Y$, and $(Y, d')$ is a
> **subspace** of $(X, d)$. We usually write $d$ for $d'$.

Balls in a subspace are computed with the restricted metric, so they can
differ from the ambient balls. In $[0, 1]$ as a subspace of $\mathbb{R}$,

$$
B_{[0,1]}(0, \tfrac{1}{2}) = \{ y \in [0,1] : |0 - y| < \tfrac{1}{2} \}
= [0, \tfrac{1}{2}),
$$

which includes its left endpoint, unlike $B_\mathbb{R}(0, \tfrac{1}{2}) =
(-\tfrac{1}{2}, \tfrac{1}{2})$. The ball is always computed in whichever space
is the ambient one, and the answer can change when the ambient space does.

$$
% caption: The same radius gives different balls: in $[0,1]$ the ball about $0$
% keeps its left endpoint, while in $\mathbb{R}$ it extends to negative numbers.
\begin{tikzpicture}[scale=1.0, font=\small]
\definecolor{acc}{HTML}{4A6FA5}
% ambient R line (top)
\draw[black, thick] (-2.6,1.1) -- (3.6,1.1);
\node[black, left] at (-2.7,1.1) {in $\mathbb{R}$};
\draw[acc, very thick] (-1.5,1.1) -- (1.5,1.1);
\draw[acc, thick, fill=white] (-1.5,1.1) circle (2.2pt);
\draw[acc, thick, fill=white] (1.5,1.1) circle (2.2pt);
\fill[black] (0,1.1) circle (1.6pt);
\node[below] at (0,1.0) {$0$};
\node[acc, above, font=\scriptsize] at (0,1.25) {open at both ends};
% subspace [0,1] line (bottom)
\draw[black, thick] (0,-0.4) -- (3.6,-0.4);
\node[black, left] at (-0.2,-0.4) {in [0,1]};
\draw[acc, very thick] (0,-0.4) -- (1.5,-0.4);
\fill[acc] (0,-0.4) circle (2.2pt);
\draw[acc, thick, fill=white] (1.5,-0.4) circle (2.2pt);
\node[below] at (0,-0.5) {$0$};
\fill[black] (3.0,-0.4) circle (1.6pt);
\node[below] at (3.0,-0.5) {$1$};
\node[acc, above, font=\scriptsize] at (0.75,-0.25) {keeps its left endpoint};
\end{tikzpicture}
$$

Properties like "open" and "closed" are likewise relative to the surrounding
space, made precise once the [topology](/real-analysis/metric-spaces/open-closed-sets)
is built from these balls.

[^lebl-71]: **Lebl**, _Basic Analysis I_, §7.1 — Metric spaces: the axioms, the standard metric on $\mathbb{R}$ and $\mathbb{R}^n$, the discrete metric, the sphere, and $C[a,b]$ under the uniform norm.
[^lebl-cs]: **Lebl**, _Basic Analysis I_, §7.1, Lemma 7.1.4 — the Cauchy–Schwarz inequality on $\mathbb{R}^n$ and its use in verifying the Euclidean triangle inequality.
[^rosen-3]: **Rosenlicht**, _Introduction to Analysis_, Ch. 3 — Metric spaces: normed vector spaces, the metric induced by a norm, and the standard examples in Euclidean space and function spaces.
