Real AnalysisMetric Spaces

Metric Spaces

A metric d measures distance: d(x, y) > 0 unless x = y, d(x, y) = d(y, x), and d(x, z) ≤ d(x, y) + d(y, z); the taxicab, Euclidean and max metrics on ℝ² are three examples.

Not started Jump to practice

Every definition in this course so far used one thing about the real line: the distance $|x - y|$. Limits, Cauchy sequences and continuity all make sense wherever you can measure distance, whether between points of the plane (as in the distance formula), between functions, or between strings. A metric space is the setting that keeps exactly what those proofs need.

Key idea

A metric on a set $X$ is a function $d : X \times X \to [0, \infty)$ with, for all $x, y, z \in X$: (1) $d(x, y) = 0$ exactly when $x = y$; (2) $d(x, y) = d(y, x)$; (3) the triangle inequality $d(x, z) \le d(x, y) + d(y, z)$. On $\mathbb{R}^{2}$ the taxicab metric $d_1 = |\Delta x| + |\Delta y|$, the Euclidean metric $d_2 = \sqrt{\Delta x^{2} + \Delta y^{2}}$ and the max metric $d_\infty = \max(|\Delta x|, |\Delta y|)$ are three examples.

Why it works

Checking that a formula is a metric means checking all three properties, and (3) is the one with content. For $d_\infty$, use the triangle inequality on $\mathbb{R}$ in each coordinate: $$|x_i - z_i| \le |x_i - y_i| + |y_i - z_i| \le d_\infty(x, y) + d_\infty(y, z).$$ The max over $i$ of the left side is $d_\infty(x, z)$. $\blacksquare$ For $d_1$, add the coordinate inequalities instead. For $d_2$ the proof needs the Cauchy–Schwarz inequality.

Now the old definitions transfer word for word. $x_n \to x$ means $d(x_n, x) \to 0$; a sequence is Cauchy when $d(x_m, x_n) < \varepsilon$ for $m, n \ge N$; and $X$ is complete when every Cauchy sequence converges to a point of $X$. $\mathbb{R}$ and $\mathbb{R}^{n}$ are complete; $\mathbb{Q}$ is not, since rational approximations of $\sqrt{2}$ form a Cauchy sequence with no rational limit. The space of continuous functions on $[a, b]$ with the sup norm distance $d(f, g) = \|f - g\|$ is complete too; the proof combines completeness of $\mathbb{R}$ with the fact that uniform limits of continuous functions are continuous.

The open ball of radius $r$ around $p$ is a diamond for $d_1$, a disk for $d_2$ and a square for $d_\infty$. Drag $q$ to see its three distances and which balls contain it.

Worked examples

Worked example: Three distances

Find $d_1$, $d_2$ and $d_\infty$ between $P = (1, 0)$ and $Q = (-4, 1)$.
  1. The coordinate differences are $5$ and $1$.
  2. $d_1 = 6$, $d_2 = \sqrt{26}$, $d_\infty = 5$.

Answer: $6$, $\sqrt{26} \approx 5.10$, $5$. In general $d_\infty \le d_2 \le d_1$.

Worked example: Not a metric

Is $d(x, y) = (x - y)^{2}$ a metric on $\mathbb{R}$?
  1. Properties (1) and (2) hold.
  2. Try $x = 0$, $y = 3$, $z = 6$: $d(0, 6) = 36$, but $d(0, 3) + d(3, 6) = 9 + 9 = 18$.

Answer: No: the triangle inequality fails.

Worked example: The discrete metric

On any set, let $d(x, y) = 1$ if $x \ne y$ and $d(x, x) = 0$. Is it a metric, and which sequences converge?
  1. For the triangle inequality: if $x \ne z$, then $y$ differs from at least one of them, so the right side is at least $1$.
  2. $d(x_n, x) < \frac{1}{2}$ forces $x_n = x$.

Answer: Yes. A sequence converges exactly when it is eventually constant.

Common mistake

Skipping the triangle inequality. Positivity and symmetry are easy to see, and many students stop there. A squared distance, or $|x^{2} - y^{2}|$ (which is $0$ for $x = 1$, $y = -1$), shows that each property must be checked. To refute a property, a single specific triple of points is enough; to prove one, you need an argument for all points.

Practice

Pass with 3 right answers, the last 2 in a row. Each right answer earns 2 XP.

Loading practice…

Builds on

Leads to

Sources and further reading

  • Jiří Lebl, Basic Analysis I: Introduction to Real Analysis, section 7.1 (metric spaces)
  • MIT OpenCourseWare 18.100B Real Analysis, lecture notes on metric spaces
@teddyrookbook GitHub