Distance (metric)

A function d(x,y) satisfying positivity, symmetry, and the triangle inequality.
Distance (metric)

Let XX be a . A metric (or distance function) on XX is a function

d:X×X[0,)d:X\times X\to[0,\infty)

such that for all x,y,zXx,y,z\in X:

  • (Positive definiteness) d(x,y)=0d(x,y)=0 iff x=yx=y.
  • (Symmetry) d(x,y)=d(y,x)d(x,y)=d(y,x).
  • (Triangle inequality) d(x,z)d(x,y)+d(y,z)d(x,z)\le d(x,y)+d(y,z).

Metrics quantify “closeness” abstractly. Most of analysis can be formulated in terms of a metric, including , , , and .

Examples:

  • On R\mathbb{R}, d(x,y)=xyd(x,y)=|x-y| is a metric.
  • On Rk\mathbb{R}^k, d(x,y)=xy2d(x,y)=\|x-y\|_2 (Euclidean distance) is a metric.
  • On any set XX, the discrete metric d(x,y)=0d(x,y)=0 if x=yx=y and 11 otherwise is a metric.