Metric (mathematics)

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 topological space has a topology that can be described by a metric, we say that the topological space is metrizable.

In differential geometry, the word "metric" is also used to refer to a structure defined only on a vector space which is more properly termed a metric tensor (or Riemannian or pseudo-Riemannian metric).

Definition
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)\geq 0$$ (non-negativity)
 * $$d(x, y) = 0\,$$ if and only if x = y (identity of indiscernibles. Note that condition 1 and 2 together produce positive definiteness)
 * $$d(x, y) = d(y, x)\,$$ (symmetry)
 * $$d(x, z)\leq d(x, y) + d(y, z)\,$$ (subadditivity / triangle inequality).

The first condition is implied by the others.

A metric is called an ultrametric if it satisfies the following stronger version of the triangle inequality where points can never fall 'between' other points:
 * For all x, y, z in M, d(x, z) ≤ max(d(x, y), d(y, z))

A metric d on X is called intrinsic if any two points x and y in X can be joined by a curve with length arbitrarily close to d(x, y).

For sets on which an addition + : X &times; X → X is defined, d is called a translation invariant metric if
 * $$d(x, y) = d(x + a, y + a)\,$$

for all x, y and a in X.

Examples

 * The discrete metric: if x = y then d(x,y) = 0. Otherwise, d(x,y) = 1.
 * The Euclidean metric is translation and rotation invariant.
 * The taxicab metric is translation invariant.
 * More generally, any metric induced by a norm is translation invariant.
 * If $$(p_n)_{n\in N}\,$$ is a sequence of seminorms defining a (locally convex) topological vector space E, then
 * $$d(x,y)=\sum_{n=1}^\infty \frac{1}{2^n} \frac{p_n(x-y)}{1+p_n(x-y)}$$
 * is a metric defining the same topology. (One can replace $$\frac{1}{2^n}$$ by any summable sequence $$(a_n)$$ of strictly positive numbers.)


 * Graph metric, a metric defined in terms of distances in a certain graph.
 * The Hamming distance in coding theory.
 * The Fubini–Study metric on complex projective space.

Equivalence of metrics
For a given set X, two metrics d1 and d2 are called topologically equivalent (uniformly equivalent) if the identity mapping
 * id: (X,d1) → (X,d2)

is a homeomorphism (uniform isomorphism).

For example, if $$d$$ is a metric, then $$\min (d, 1)$$ and $${d \over 1+d}$$ are metrics equivalent to $$d.$$

See also.

Metrics on vector spaces
Norms on vector spaces are equivalent to certain metrics, namely homogeneous, translation invariant ones. In other words, every norm determines a metric, and some metrics determine a norm.

Given a normed vector space (X,||.||) we can define a metric on X by


 * $$d(x,y) := \| x-y\|$$.

The metric d is said to be induced by the norm ||.||.

Conversely if a metric d on a vector space X satisfies the properties

then we can define a norm on X by
 * $$d(x,y) = d(x+a,y+a)\,$$ (translation invariance)
 * $$d(\alpha x, \alpha y) = |\alpha| d(x,y)\,$$ (homogeneity)


 * $$\|x\| := d(x,0)$$

Similarly, a seminorm induces a pseudometric (see below), and a homogeneous, translation invariant pseudometric induces a seminorm.

Generalized metrics
There are numerous ways of relaxing the axioms of metrics, giving rise to various notions of generalized metric spaces. These generalizations can also be combined. The terminology used to describe them is not completely standardized. Most notably, in functional analysis pseudometrics often come from seminorms on vector spaces, and so it is natural to call them "semimetrics". This conflicts with the use of the term in topology.

Extended metrics
Some authors allow the distance function d to attain the value ∞, i.e. distances are non-negative numbers on the extended real number line. Such a function is called an extended metric. Every extended metric can be transformed to a finite metric such that the metric spaces are equivalent as far as notions of topology (such as continuity or convergence) are concerned. This can be done using a subadditive monotically increasing bounded function which is zero at zero, e.g. d'(x, y) = d(x, y) / (1 + d(x, y)) or d  (x, y) = min(1, d(x, y''))).

The requirement that the metric take values in [0,∞) can even 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.

Pseudometrics
A pseudometric on X is a function d : X × X → R which satisfies the axioms for a metric, except that instead of the second (identity of indiscernibles) only d(x,x)=0 for all x is required. In other words, the axioms for a pseudometric are:


 * 1) d(x, y) ≥ 0


 * 1) d(x, x) = 0 (but $$d(x,y)=0$$ for some distinct values $$x\ne y$$.)
 * 2) d(x, y) = d(y, x)
 * 3) d(x, z) ≤ d(x, y) + d(y, z).

This is the most common generalization of metrics. In some context, pseudometrics is referred to as semimetrics.

Quasimetrics
Occasionally, a quasimetric is defined as a function that satisfies all axioms for a metric with the possible exception of symmetry:


 * 1) d(x, y) ≥ 0
 * 2) d(x, y) = 0   if and only if   x = y
 * 3) (dropped)
 * 4) d(x, z) ≤ d(x, y) + d(y, z).

If d is a quasimetric on X, a metric d '  on X can be formed by taking
 * d ' (x, y) = $1/undefined$(d(x, y) + d(y, x)).

Quasimetrics are common in real life. For example, given a set X of mountain villages, the typical walking times between elements of X form a quasimetric. Another example is a taxicab geometry topology having one-way streets, where a path from point A to point B comprises a different set of streets than a path from B to A. Nevertheless, this notion is rarely used in mathematics, and its name is not entirely standardized.

A quasimetric on the reals can be defined by setting
 * d(x, y) = y - x if y ≥ x, and
 * d(x, y) = 1 otherwise.

The topological space underlying this quasimetric space is the Sorgenfrey line.

Semimetrics

 * ''This section is about generalized metrics without the triangle inequality. For generalized metrics that arise from seminorms see Pseudometrics.

In topology, a semimetric on X is a function d : X × X → R that satisfies the first three axioms, but not necessarily the triangle inequality:


 * 1) d(x, y) ≥ 0
 * 2) d(x, y) = 0   if and only if   x = y
 * 3) d(x, y) = d(y, x)
 * 4) (dropped)

In translations of Russian texts, semimetrics are sometimes called symmetrics. Some authors work with a weaker form of the triangle inequality, such as:
 * d(x, z) ≤ ϝ (d(x, y) + d(y, z))    (ϝ-relaxed triangle inequality)
 * d(x, z) ≤ ϝ max(d(x, y), d(y, z))    (ϝ-inframetric inequality).

The ϝ-inframetric inequality implies the ϝ-relaxed triangle inequality (assuming the first axiom), and the ϝ-relaxed triangle inequality implies the 2ϝ-inframetric inequality. Semimetrics satisfying these equivalent conditions have sometimes been referred to as "quasimetrics", "nearmetrics" or inframetrics.

The ϝ-inframetric inequalities were introduced to model round-trip delay times in the internet. The triangle inequality implies the 2-inframetric inequality, and the ultrametric inequality is exactly the 1-inframetric inequality.

Premetrics
Relaxing the last three axioms leads to the notion of a premetric, i.e. a function satisfying the following conditions:


 * 1) d(x, y) ≥ 0
 * 2) d(x, x) = 0
 * 3) (dropped)
 * 4) (dropped).

This is not a standard term. Sometimes it is used to refer to other generalizations of metrics such as pseudosemimetrics or pseudometrics ; in translations of Russian books it sometimes appears as "prametric".

Any premetric gives rise to a topology as follows. For a positive real r, the open r-ball centred at a point p is defined as
 * $$B_r(p) = \left\{x|d(x, p)<r\right\}\,$$

A set is open if for any point p in the set there is an r-ball centred at p which is contained in the set. In general, the open r-balls themselves need not be open sets with respect to this topology. In fact, the interior of an r-ball may be empty. Thus every premetric space is a topological space, and in fact a sequential space.

As for metrics, the distance between two sets A and B, is defined as


 * $$d(A, B) = inf_{x\in A, y\in B}~d(x, y)\,$$

This defines a premetric on the power set of a premetric space. If we start with a (pseudosemi-)metric space, we get a pseudosemimetric, i.e. a symmetric premetric. Any premetric gives rise to a preclosure operator cl as follows:


 * $$cl(A) = \left\{x|d(x, A)=0\right\}$$

Pseudoquasimetrics
The presyllables pseudo-, quasi- and semi- can also be combined, e.g., a pseudoquasimetric (sometimes called called hemimetric) relaxes both the indiscernibility axiom and the symmetry axiom and is simply a premetric satisfying the triangle inequality. For pseudoquasimetric spaces the open r-balls form a basis of open sets. A very basic example of a pseudoquasimetric space is the set {0,1} with the premetric given by d(0,1) = 1 and d(1,0) = 0. The associated topological space is the Sierpiński space.

Sets equipped with an extended pseudoquasimetric were studied by William Lawvere as "generalized metric spaces". From a categorical point of view, the extended pseudometric spaces 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 maintains these good categorical properties.

Important cases of generalized metrics
In differential geometry, one considers metric tensors, which can be thought of as "infinitesimal" metric functions. They 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 metric tensor, which integrates to a pseudo-semimetric. These are used in the geometric study of the theory of relativity, where the tensor is also called the "invariant distance".