# Metric (mathematics)

In mathematics, a metric or distance function is a function that 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. A topological space whose topology can be described by a metric is called metrizable.

In differential geometry, the word "metric" may refer to a bilinear form that may be defined from the tangent vectors of a differentiable manifold onto a scalar, allowing distances along curves to be determined through integration. It is more properly termed a metric tensor.

## Definition

A metric on a set X is a function (called the distance function or simply distance)

d : X × XR

(where R is the set of real numbers). For all x, y, z in X, this function is required to satisfy the following conditions:

1. d(x, y) ≥ 0     (non-negativity, or separation axiom)
2. d(x, y) = 0   if and only if   x = y     (identity of indiscernibles, or coincidence axiom)
3. d(x, y) = d(y, x)     (symmetry)
4. d(x, z) ≤ d(x, y) + d(y, z)     (subadditivity / triangle inequality).

Conditions 1 and 2 together produce positive definiteness. 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 X, 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 × XX 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.

## Notes

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 from x to z via y is at least as great as from x to z directly. Euclid in his work stated that the shortest distance between two points is a line; that was the triangle inequality for his geometry.

If a modification of the triangle inequality

4*. d(x, z) ≤ d(z, y) + d(y, x)

is used in the definition then property 1 follows straight from property 4*. Properties 2 and 4* give property 3 which in turn gives property 4.

## Examples

$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.)

## 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)

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

## 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, \|\cdot\|)$ we can define a metric on X by

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

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

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

• $d(x,y) = d(x+a,y+a)$ (translation invariance)
• $d(\alpha x, \alpha y) = |\alpha| d(x,y)$ (homogeneity)

then we can define a norm on X by

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

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

## Metrics on multisets

We can generalize the notion of a metric from a distance between two elements to a distance between two nonempty finite multisets of elements. A multiset is a generalization of the notion of a set such that an element can occur more than once. Define $Z=XY$ if $Z$ is the multiset consisting of the elements of the multisets $X$ and $Y$, that is, if $x$ occurs once in $X$ and once in $Y$ then it occurs twice in $Z$. A distance function $d$ on the set of nonempty finite multisets is a metric[1] if

1. $d(X)=0$ if all elements of $X$ are equal and $d(X) > 0$ otherwise (positive definiteness), that is, (non-negativity plus identity of indiscernibles)
2. $d(X)$ is invariant under all permutations of $X$ (symmetry)
3. $d(XY) \leq d(XZ)+d(ZY)$ (triangle inequality)

Note that the familiar metric between two elements results if the multiset $X$ has two elements in 1 and 2 and the multisets $X,Y,Z$ have one element each in 3. For instance if $X$ consists of two occurrences of $x$, then $d(X)=0$ accordng to 1.

A simple example is the set of all nonempty finite multisets $X$ of integers with $d(X)=\max\{x: x \in X\}- \min\{x:x \in X\}$. More complex examples are information distance in multisets;[1] and Normalized Compression Distance (NCD) in multisets.[2]

## 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 monotonically 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 × XR 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
2. d(x, x) = 0 (but possibly $d(x,y)=0$ for some distinct values $x\ne y$.)
3. d(x, y) = d(y, x)
4. d(x, z) ≤ d(x, y) + d(y, z).

This is the most common generalization of metrics.[citation needed] In some contexts, pseudometrics are referred to as semimetrics because of their relation to seminorms.

### Quasimetrics

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

1. d(x, y) ≥ 0 (positivity)
2. d(x, y) = 0   if and only if   x = y (positive definiteness)
3. d(x, y) = d(y, x) (symmetry, dropped)
4. d(x, z) ≤ d(x, y) + d(y, z) (triangle inequality)

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 because travel up hill takes longer than travel down hill. 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.[5]

A quasimetric on the reals can be defined by setting

d(x, y) = xy if xy, and
d(x, y) = 1 otherwise. The 1 may be replaced by infinity or by 1+10(y-x).

The topological space underlying this quasimetric space is the Sorgenfrey line. This space describes the process of filing down a metal stick: it is easy to reduce its size, but it is difficult or impossible to grow it.

If d is a quasimetric on X, a metric d' on X can be formed by taking

d'(x, y) = 12(d(x, y) + d(y, x)).

#### Non-positive quasimetrics

A non-positive quasimetric may be defined[citation needed] as a function $d:X\times X\to(-\infty,+\infty]$ satisfying:

1. For each x in X, $d(x,x)\leq 0$.
2. For each x, y and z in X, $d(x,z)\leq d(x,y)+d(y,z)$.

This kind of function may arise in the following situation: Let $X$ be the space of possible states of a certain machine (for example, if the machine is an elevator in a building with $n$ floors, then $X=\{0,\dots,n-1\}$). For $x,y\in X$, let $d(x,y)$ be the infimum energy needed to take the machine from state $x$ to state $y$. (Here the term "energy" means useful energy, so heat doesn't count.) This function satisfies the triangle inequality (because two operations may be concatenated, adding their costs) and the first axiom (because one can go from a state to itself by doing nothing). But it is generally non-symmetric: rising the elevator always costs a lot of energy, but lowering it should cost less, perhaps zero, or it may even be possible to obtain energy from that operation. The important fact is that we can't obtain energy from performing a closed cycle, so the relevant positivity condition is $d(x,x)\geq 0$, which in fact can be obtained from the triangle inequality by setting $x=y=z$.

It is easy to remember that a quasimetric is a metric that is possibly asymmetric. If a quasimetric is in fact symmetric, then it can be proved that the relaxed positivity condition $d(x,x)\geq 0$ implies the full positivity $d(x,y)\geq 0$ in the following way:

$d(x,y) =\frac{d(x,y)+d(y,x)}2 \geq\frac{d(x,x)}2 \geq 0.$

Perhaps the notion described here should be called non-positive pseudoquasimetric, since positive-definiteness was dropped along with positivity. Positive-definiteness may be recovered by introducing the axiom

$d(x,y)+d(y,x)> 0$ whenever $x\neq y$,

which is equivalent to the usual positive definiteness if the quasimetric is symmetric.

### Semimetrics

A semimetric on X is a function d : X × XR 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)

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",[6] "nearmetrics"[7] or inframetrics.[8]

The ρ-inframetric inequalities were introduced to model round-trip delay times in the internet.[8] 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

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

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

Br(p) = { x | d(x, p) < r }.

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) = infxA, yB 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) = { x | d(x, A) = 0 }.

### Pseudoquasimetrics

The presyllables pseudo-, quasi- and semi- can also be combined, e.g., a pseudoquasimetric (sometimes 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".[12][13] 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 pseudo-Riemannian 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".

## Notes

1. ^ a b P.M.B. Vitanyi, Information distance in multiples, IEEE Trans. Inform. Theory, 57:4(2011), 2451-2456
2. ^ A.R.Cohen and P.M.B. Vitanyi, Normalized compression distance of multisets with applications, arXiv:1212.5711
3. ^ E.g. Steen & Seebach (1995).
4. ^ Smyth, M. (1987). M.Main, A.Melton, M.Mislove and D.Schmidt, ed. "Quasi uniformities: reconciling domains with metric spaces". 3rd Conference on Mathematical Foundations of Programming Language Semantics. Springer-Verlag, Lecture Notes in Computer Science 298. pp. 236–253.
5. ^ Rolewicz, Stefan (1987), Functional Analysis and Control Theory: Linear Systems, Springer, ISBN 90-277-2186-6, OCLC 13064804 This book calls them "semimetrics", which is unfortunate because the same term is frequently used for two other generalizations of metrics.
6. ^ Xia, Q. (2009), "The Geodesic Problem in Quasimetric Spaces", Journal of Geometric Analysis 19 (2): 452–479, doi:10.1007/s12220-008-9065-4
7. ^ Qinglan Xia (2008), "The geodesic problem in nearmetric spaces", Journal of Geometric Analysis: Volume , Issue (009), Page 19 (2): 452–479, arXiv:0807.3377.
8. ^ a b * Fraigniaud, P.; Lebhar, E.; Viennot, L. (2008), The Inframetric Model for the Internet, "2008 IEEE INFOCOM - The 27th Conference on Computer Communications", IEEE INFOCOM 2008. the 27th Conference on Computer Communications: 1085–1093, doi:10.1109/INFOCOM.2008.163, ISBN 978-1-4244-2026-1, retrieved 2009-04-17.
9. ^ Buldygin, V.V.; Kozachenko, I.U.V. (2000), Metric characterization of random variables and random processes.
10. ^ Khelemskiĭ (2006), Lectures and exercises on functional analysis.
11. ^ Arkhangel'skii & Pontryagin (1990). Aldrovandi, R.; Pereira, J.G. (1995), An introduction to geometrical physics.
12. ^ Lawvere, F.W. (2002) [1973], Metric spaces, generalised logic, and closed categories, Reprints in Theory and Applications of Categories 1, pp. 1–37.
13. ^ Vickers, Steven (2005), "Localic completion of generalized metric spaces I", Theory and Applications of Categories 14: 328–356

## References

• Arkhangel'skii, A.V.; Pontryagin, L.S. (1990), General Topology I: Basic Concepts and Constructions Dimension Theory, Encyclopaedia of Mathematical Sciences, Springer, ISBN 3-540-18178-4

• Rachev, Svetlozar T.; Stoyan V. Stoyanov, Advanced Stochastic Models, Risk Assessment, and Portfolio Optimization: The Ideal Risk, Uncertainty, and Performance Measures, ISBN 978-0-470-05316-4 Unknown parameter |unused_data= ignored (help) pages 91–94 explain the use of quasimetrics in finance.