Skip to main content

Section D.2 Metrics

Let \(X\) be a set. A function \(d:X\times X\to\R\) is called a metric on \(X\) if, for all \(x,y,z\in X\text{,}\) the following hold:
  1. \(d(x,y)\ge 0\text{.}\)
  2. \(d(x,y)=0\) if and only if \(x=y\text{.}\)
  3. \(d(x,y)=d(y,x)\text{.}\)
  4. \(d(x,z)\le d(x,y)+d(y,z)\text{.}\)
For \(x,y\in\R^n\text{,}\) define the Euclidean distance by \(d(x,y)=\|x-y\|\text{.}\)

Proof.

Since norms are nonnegative, \(d(x,y)=\|x-y\|\ge0\text{.}\) Also \(d(x,y)=0\) if and only if \(\|x-y\|=0\text{,}\) which happens if and only if \(x-y=0\text{,}\) that is, \(x=y\text{.}\)
Symmetry follows from \(d(x,y)=\|x-y\|=\|-(y-x)\|=|-1|\,\|y-x\|=\|y-x\|=d(y,x)\text{.}\)
For the triangle inequality, \(d(x,z)=\|x-z\|=\|(x-y)+(y-z)\| \le \|x-y\|+\|y-z\| = d(x,y)+d(y,z),\) by Propositionย D.1.2. Therefore \(d\) is a metric.