In mathematics, a **metric** or **distance function** is a function that defines a distance between each pair of elements of a set. A set with a metric is called a metric space.^{[1]} 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.

An important source of metrics in differential geometry are metric tensors, bilinear forms that may be defined from the tangent vectors of a differentiable manifold onto a scalar. A metric tensor allows distances along curves to be determined through integration, and thus determines a metric. However, not every metric comes from a metric tensor in this way.

# Definition

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

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:

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* × *X* → *X* is defined,
d is called a **translation invariant metric** if

for all x, y, and a in X.