Metric (mathematics) An illustration comparing the taxicab metric versus the Euclidean metric on the plane: In the taxicab metric all three pictured lines (red, yellow, and blue) have the same length (12) for the same route. In the Euclidean metric, the green line has length $6{\sqrt {2}}\approx 8.49$ , and is the unique shortest path.

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), and for all x, y, z in X, the following conditions are satisfied:

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 define a Positive-definite function. 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:

d(x, z) ≤ max(d(x, y), d(y, z))

for all x, y, z in X.

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.