Skip to main content
\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)
Mathematics LibreTexts

1.3: Metric spaces

  • Page ID
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)

    The notion of metric space provides a rigorous way to say: “we can mea- sure distances between points”. That is, instead of (i) on Section 1.1, we can say “Euclidean plane is a metric space”.


    Let \(\mathcal{X}\) be a nonempty set and \(d\) be a function which returns a real number \(d(A, B)\) for any pair \(A, B \in \mathcal{X}\). Then \(d\) is called metric on \(\mathcal{X}\) if for any \(A, B, C \in \mathcal{X}\), the following conditions are satisfied:

    (a) Positiveness:

    \[d(A, B) \ge 0.\]

    (b) \(A = B\) if and only if

    \[d(A, B) = 0.\]

    (c) Symmetry:

    \[d(A, B) = d(B, A)\]

    (d) Triangle inequality:

    \[d(A, C) \le d(A, B) + d(B, C).\]

    A metric space is a set with a metric on it. More formally, a metric space is a pair \((\mathcal{X}, d)\) where \(\mathcal{X}\) is a set and \(d\) is a metric on \(\mathcal{X}\).

    The elements of \(\mathcal{X}\) are called points of the metric space. Given two points \(A, B \in \mathcal{X}\), the value \(d(A, B)\) is called distance from \(A\) to \(B\).

    Example \(\PageIndex{1}\) Discrete metric

    Let \(\mathcal{X}\) be an arbitrary set. For any \(A, B \in \mathcal{X}\), set \(d(A, B) = 0\) if \(A = B\) and \(d(A, B) = 1\) otherwise. The metric \(d\) is called discrete metric on \(\mathcal{X}\).

    Example \(\PageIndex{2}\) Real line

    Set of all real numbers (\(\mathbb{R}\)) with metric \(d\) defined by

    \[d(A, B) := |A - B|.\]

    Exercise \(\PageIndex{1}\)

    Show that \(d(A, B) = |A - B|^2\) is not a metric on \(\mathbb{R}\). 

    Metrics on the plane. Suppose that \(\mathbb{R}^2\) denotes the set of all pairs \((x, y)\) of real numbers. Assume \(A = (x_A, y_A)\) and \(B = (x_B, y_B)\). Consider the following metrics on \(\mathbb{R}^2\):

    • Euclidean metric, denoted by \(d_2\), and defined as
      \[d_2(A, B) = \sqrt{(x_A - x_B)^2 + (y_A - y_B)^2}.\]
    • Manhattan metric, denoted by \(d_1\) and defined as
      \[d_1(A, B) = |x_A - x_B| + |y_A - y_B|.\]
    • Maximum metric, denoted by \(d_{\infty}\) and defined as
      \[d_{\infty}(A, B) = \max \{|x_A - x_B|, |y_A - y_B|\}.\]

    Check the triangle inequality for \(A = 0\), \(B = 1\) and \(C = 2\).

    Exercise \(\PageIndex{2}\)

    Prove that the following functions are metrics on \(\mathbb{R}^2\):

    (a) \(d_1\);
    (b) \(d_2\);
    (c) \(d_{\infty}\).


    Only the triangle inequality requires a proof — the rest of conditions in Definition 1.1 are evident. Let \(A = x_A, y_A)\), \(B = (x_B, y_B)\), and \(C = (x_C, y_C)\). Set 

    \(x_1 = x_B - x_A\),                     \(y_1 = y_B - y_A\),
    \(x_2 = x_C - x_B\),                     \(y_2 = y_C - y_B\).

    (a). The inequality

    \[d_1(A, C) \le d_1(A, B) + d_1(B, C)\]

    can be written as

    \[|x_1 + x_2| + |y_1 + y_2| \le |x_1| + |y_1| + |x_2| + |y_2|.\]

    The latter follows since \(|x_1 + x_2| \le |x_1| + |x_2|\) and \(|y_1 + y_2| \le |y_1| + |y_2|\).

    (b). The inequality

    \[d_2(A, C) \le d_2 (A, B) + d_2(B, C)\]

    can be written as

    \[\sqrt{(x_1 + x_2)^2 + (y_1 + y_2)^2} \le \sqrt{x_1^2 + y_1^2} + \sqrt{x_2^2 + y_2^2}.\]

    Take the square of the left and the right hand sides, simplify, take the square again and simplify again. You should get the following inequality

    \[0 \le (x_1 \cdot y_2 - x_2 \cdot y_1)^2,\]

    which is equivalent to 1.3.9 and evidently true.

    (c). The inequality

    \[d_{\infty} (A, C) \le d_{\infty} (A, B) + d_{\infty} (B, C)\]

    can be written as

    \[\max \{|x_1 + x_2|, |y_1 + y_2|\} \le \max \{|x_1|, |y_1|\} + \max \{|x_2|, |y_2|\}.\]

    Without loss of generality, we may assume that

    \[\max \{|x_1 + x_2|, |y_1 + y_2|\} = |x_1 + x_2|.\]


    \[|x_1 + x_2| \le |x_1| + |x_2| \le \max \{|x_1|, |y_1|\} + \max \{|x_2|, |y_2|\}.\]

    Hence 1.3.13 follows.