In mathematics a metric or distance function is a function which defines a distance between elements of a set. A set with a metric is called a metric space. A metric induces a topology on a set but not all topologies can be generated by a metric. When a topology can be described by a metric we call the space metrisable.
A metric on a set X is a function (called the distance function or simply distance)
d : X × X → R
(where R is the set of real numbers). For all x, y, z in X, this function is required to satisfy the following conditions:
- d(x, y) ≥ 0 (non-negativity)
- d(x, y) = 0 if and only if x = y (identity of indiscernibles)
- d(x, y) = d(y, x) (symmetry)
- d(x, z) ≤ d(x, y) + d(y, z) (triangle inequality).
For sets on which an addition + : X × X → X is defined, we call d a translation invariant metric if
- d(x, y)=d(x + a, y + a)
for all x,y and a in X.
If the triangular inequality is strengthened to
- d(x, z) ≤ max( d(x, y), d(y, z) )
the metric is called ultrametric, see below.
These conditions express intuitive notions about the concept of distance. For example, that the distance between distinct points is positive and the distance from x to y is the same as the distance from y to x. The triangle inequality means that the distance traversed directly between x and z, is not larger than the distance to traverse in going first from x to y, and then from y to z. Euclid in his work proved that the shortest distance between two points is a line; that was the triangle inequality for his geometry.
Property 1 (d(x, y) ≥ 0) follows from properties 2 and 4 and does not have to be required separately.
- The discrete metric: if x = y then d(x,y) = 0. Otherwise, d(x,y) = 1.
- The Euclidean metric is translation invariant.
- More generally, any metric induced by a norm (see below) is translation invariant.
- If (pn)n∈N is a sequence of seminorms defining a (locally convex) topological vector space E, then
- is a metric defining the same topology. (One can replace by any summable sequence of strictly positive numbers.)
Equivalence of metrics
For a given set X two metrics d1 and d2 are called topological equivalent (uniformly equivalent) if the identity mapping
- id: (X,d1) → (X,d2)
Relation of norms and metrics
Given a normed vector space (X,||.||) we can define a metric on X by
The metric d is called induced by ||.||.
Conversely if a metric d on a vector space X satisfies the properties
- d(x,y) = d(x+a,y+a) (translation invariance)
- d(αx,αy) = |α|d(x,y) (homogenity)
then we can define a norm on X by
Similarly, a seminorm induces a pseudometric and a homogenous, translation invariant pseudometric induces a seminorm.
Related concepts and alternative axiom systems
Some authors use the extended real number line and allow the distance function d to attain the value ∞. Such a metric is called an extended metric. Every extended metric can be rescaled to a finite metric (using d'(x, y) = d(x, y) / (1 + d(x, y)) or d''(x, y) = min(1, d(x, y))) and the two concepts of metric space are therefore equivalent as far as notions of topology (such as continuity or convergence) are concerned.
A metric is called an ultrametric if it satisfies the following stronger version of the triangle inequality:
- For all x, y, z in M, d(x, z) ≤ max(d(x, y), d(y, z))
If one drops property 2, one obtains pseudometric spaces. Dropping property 3 instead, one obtains quasimetric spaces. However, losing symmetry in this case, one usually changes property 2 such that both d(x,y)=0 and d(y,x)=0 are needed for x and y to be identified. Dropping property 4 one obtains semimetric spaces. All combinations of the above are possible and are referred to by their according names (such as quasi-pseudo-ultrametric).
From the categorical point of view, the extended pseudometric and the extended pseudoquasimetric spaces, along with their corresponding nonexpansive maps, are the best behaved of the metric space categories. One can take arbitrary products and coproducts and form quotient objects within the given category. If one drops "extended", one can only take finite products and coproducts. If one drops "pseudo", one cannot take quotients. Approach spaces are a generalization of metric spaces that maintain these good categorical properties.
The requirement that the metric takes values in [0,∞) can also be relaxed to consider metrics with values in other directed sets. The reformulation of the axioms in this case leads to the construction of uniform spaces: topological spaces with an abstract structure enabling one to compare the local topologies of different points.
In differential geometry, one considers metric tensors, which can be thought of as "infinitesimal" metric functions, and are defined as inner products on the tangent space with an appropriate differentiability requirement. While these are not metric functions as defined in this article, they induce metric functions by integration. A manifold with a metric tensor is called a Riemannian manifold. If one drops the positive definiteness requirement of inner product spaces, then one obtains a Pseudo-Riemannian metric tensor, which integrates to a pseudometric. These are used in the geometric study of the theory of relativity, where the tensor is also called the "invariant distance".