Metric and metric space

A distance function satisfying positivity, symmetry, and the triangle inequality
Metric and metric space

Let XX be a nonempty set. A function d:X×XRd:X\times X\to\mathbb{R} is a metric on XX if for all x,y,zXx,y,z\in X:

  1. d(x,y)0d(x,y)\ge 0, and d(x,y)=0d(x,y)=0 if and only if x=yx=y.
  2. d(x,y)=d(y,x)d(x,y)=d(y,x).
  3. d(x,z)d(x,y)+d(y,z)d(x,z)\le d(x,y)+d(y,z) (triangle inequality).

The pair (X,d)(X,d) is called a metric space.

Metrics allow one to define , , and notions of and completeness.

Examples:

  • On Rn\mathbb{R}^n, the Euclidean metric d(x,y)=xy2d(x,y)=\|x-y\|_2.
  • The discrete metric: d(x,y)=0d(x,y)=0 if x=yx=y and d(x,y)=1d(x,y)=1 otherwise.
  • On a normed vector space (X,)(X,\|\cdot\|), d(x,y)=xyd(x,y)=\|x-y\| is a metric.