In mathematics, a metric space is a set together with a notion of distance between its elements, usually called points. The distance is measured by a function called a metric or distance function. Metric spaces are the most general setting for studying many of the concepts of mathematical analysis and geometry.
The most familiar example of a metric space is 3-dimensional Euclidean space with its usual notion of distance. Other well-known examples are a sphere equipped with the angular distance and the hyperbolic plane. A metric may correspond to a metaphorical, rather than physical, notion of distance: for example, the set of 100-character Unicode strings can be equipped with the Hamming distance, which measures the number of characters that need to be changed to get from one string to another.
Since they are very general, metric spaces are a tool used in many different branches of mathematics. Many types of mathematical objects have a natural notion of distance and therefore admit the structure of a metric space, including Riemannian manifolds, normed vector spaces, and graphs. In abstract algebra, the p-adic numbers arise as elements of the completion of a metric structure on the rational numbers. Metric spaces are also studied in their own right in metric geometry and analysis on metric spaces.
Many of the basic notions of mathematical analysis, including balls, completeness, as well as uniform, Lipschitz, and Hölder continuity, can be defined in the setting of metric spaces. Other notions, such as continuity, compactness, and open and closed sets, can be defined for metric spaces, but also in the even more general setting of topological spaces.
To see the utility of different notions of distance, consider the surface of the Earth as a set of points. We can measure the distance between two such points by the length of the shortest path along the surface, "as the crow flies"; this is particularly useful for shipping and aviation. We can also measure the straight-line distance between two points through the Earth's interior; this notion is, for example, natural in seismology, since it roughly corresponds to the length of time it takes for seismic waves to travel between those two points.
The notion of distance encoded by the metric space axioms has relatively few requirements. This generality gives metric spaces a lot of flexibility. At the same time, the notion is strong enough to encode many intuitive facts about what distance means. This means that general results about metric spaces can be applied in many different contexts.
Like many fundamental mathematical concepts, the metric on a metric space can be interpreted in many different ways. A particular metric may not be best thought of as measuring physical distance, but, instead, as the cost of changing from one state to another (as with Wasserstein metrics on spaces of measures) or the degree of difference between two objects (for example, the Hamming distance between two strings of characters, or the Gromov–Hausdorff distance between metric spaces themselves).
Formally, a metric space is an ordered pair where is a set and is a metric on, i.e., a functionsatisfying the following axioms for all points
x,y,z\inM
If the metric is unambiguous, one often refers by abuse of notation to "the metric space ".
By taking all axioms except the second, one can show that distance is always non-negative:Therefore the second axiom can be weakened to and combined with the first to make .[1]
The real numbers with the distance function
d(x,y)=|y-x|
The Euclidean plane
\R2
The taxicab or Manhattan distance is defined byand can be thought of as the distance you need to travel along horizontal and vertical lines to get from one point to the other, as illustrated at the top of the article.
The maximum,
Linfty
In fact, these three distances, while they have distinct properties, are similar in some ways. Informally, points that are close in one are close in the others, too. This observation can be quantified with the formulawhich holds for every pair of points
p,q\in\R2
A radically different distance can be defined by settingUsing Iverson brackets,In this discrete metric, all distinct points are 1 unit apart: none of them are close to each other, and none of them are very far away from each other either. Intuitively, the discrete metric no longer remembers that the set is a plane, but treats it just as an undifferentiated set of points.
All of these metrics make sense on
\Rn
\R2
A\subseteqM
dA:A x A\to\R
\R3
\R3
The concept of metric spaces was an important development in mathematics in the early 20th century. It helped advance the study of analysis and topology. The French mathematician Maurice Fréchet first formalized this idea in 1906. He wanted to generalize the concept of distance in Euclidean spaces to more abstract settings. [2] Fréchet's work laid the foundation for understanding convergence, continuity, and other key concepts in non-geometric spaces. This allowed mathematicians to study functions and sequences in a broader and more flexible way. This was important for the growing field of functional analysis. Mathematicians like Felix Hausdorff and Stefan Banach further refined and expanded the framework of metric spaces.[3]
Hausdorff introduced topological spaces as a generalization of metric spaces. Banach's work in functional analysis heavily relied on the metric structure. Over time, metric spaces became a central part of modern mathematics. They have influenced various fields including topology, geometry, and applied mathematics. Metric spaces continue to play a crucial role in the study of abstract mathematical concepts.
A distance function is enough to define notions of closeness and convergence that were first developed in real analysis. Properties that depend on the structure of a metric space are referred to as metric properties. Every metric space is also a topological space, and some metric properties can also be rephrased without reference to distance in the language of topology; that is, they are really topological properties.
For any point in a metric space and any real number, the open ball of radius around is defined to be the set of points that are strictly less than distance from :This is a natural way to define a set of points that are relatively close to . Therefore, a set
N\subseteqM
An open set is a set which is a neighborhood of all its points. It follows that the open balls form a base for a topology on . In other words, the open sets of are exactly the unions of open balls. As in any topology, closed sets are the complements of open sets. Sets may be both open and closed as well as neither open nor closed.
This topology does not carry all the information about the metric space. For example, the distances,, and defined above all induce the same topology on
\R2
\R
Conversely, not every topological space can be given a metric. Topological spaces which are compatible with a metric are called metrizable and are particularly well-behaved in many ways: in particular, they are paracompact[4] Hausdorff spaces (hence normal) and first-countable. The Nagata–Smirnov metrization theorem gives a characterization of metrizability in terms of other topological properties, without reference to metrics.
Convergence of sequences in Euclidean space is defined as follows:
A sequence converges to a point if for every there is an integer such that for all, .Convergence of sequences in a topological space is defined as follows:
A sequence converges to a point if for every open set containing there is an integer such that for all,
xn\inU
See main article: Complete metric space. Informally, a metric space is complete if it has no "missing points": every sequence that looks like it should converge to something actually converges.
To make this precise: a sequence in a metric space is Cauchy if for every there is an integer such that for all, . By the triangle inequality, any convergent sequence is Cauchy: if and are both less than away from the limit, then they are less than away from each other. If the converse is true—every Cauchy sequence in converges—then is complete.
Euclidean spaces are complete, as is
\R2
\R
\R
\R
This notion of "missing points" can be made precise. In fact, every metric space has a unique completion, which is a complete space that contains the given space as a dense subset. For example, is the completion of, and the real numbers are the completion of the rationals.
Since complete spaces are generally easier to work with, completions are important throughout mathematics. For example, in abstract algebra, the p-adic numbers are defined as the completion of the rationals under a different metric. Completion is particularly common as a tool in functional analysis. Often one has a set of nice functions and a way of measuring distances between them. Taking the completion of this metric space gives a new set of functions which may be less nice, but nevertheless useful because they behave similarly to the original nice functions in important ways. For example, weak solutions to differential equations typically live in a completion (a Sobolev space) rather than the original space of nice functions for which the differential equation actually makes sense.
See also: Bounded set. A metric space is bounded if there is an such that no pair of points in is more than distance apart. The least such is called the of .
The space is called precompact or totally bounded if for every there is a finite cover of by open balls of radius . Every totally bounded space is bounded. To see this, start with a finite cover by -balls for some arbitrary . Since the subset of consisting of the centers of these balls is finite, it has finite diameter, say . By the triangle inequality, the diameter of the whole space is at most . The converse does not hold: an example of a metric space that is bounded but not totally bounded is
\R2
See main article: Compact space. Compactness is a topological property which generalizes the properties of a closed and bounded subset of Euclidean space. There are several equivalent definitions of compactness in metric spaces:
One example of a compact space is the closed interval .
Compactness is important for similar reasons to completeness: it makes it easy to find limits. Another important tool is Lebesgue's number lemma, which shows that for any open cover of a compact space, every point is relatively deep inside one of the sets of the cover.
Unlike in the case of topological spaces or algebraic structures such as groups or rings, there is no single "right" type of structure-preserving function between metric spaces. Instead, one works with different types of functions depending on one's goals. Throughout this section, suppose that
(M1,d1)
(M2,d2)
See main article: Isometry. One interpretation of a "structure-preserving" map is one that fully preserves the distance function:
A function
f:M1\toM2
2,d | |
f:(\R | |
1) |
\to
2,d | |
(\R | |
infty) |
If there is an isometry between the spaces and, they are said to be isometric. Metric spaces that are isometric are essentially identical.
On the other end of the spectrum, one can forget entirely about the metric structure and study continuous maps, which only preserve topological structure. There are several equivalent definitions of continuity for metric spaces. The most important are:
f\colonM1\toM2
f-1(U)
f\colonM1\toM2
f(x1),f(x2),\ldots
(These first two definitions are not equivalent for all topological spaces.)
f\colonM1\toM2
\R
See main article: Uniform continuity. A function
f\colonM1\toM2
d(x,y)<\delta
The only difference between this definition and the ε–δ definition of continuity is the order of quantifiers: the choice of δ must depend only on ε and not on the point . However, this subtle change makes a big difference. For example, uniformly continuous maps take Cauchy sequences in to Cauchy sequences in . In other words, uniform continuity preserves some metric properties which are not purely topological.
On the other hand, the Heine–Cantor theorem states that if is compact, then every continuous map is uniformly continuous. In other words, uniform continuity cannot distinguish any non-topological features of compact metric spaces.
See main article: Lipschitz continuity.
A Lipschitz map is one that stretches distances by at most a bounded factor. Formally, given a real number, the map
f\colonM1\toM2
A 1-Lipschitz map is sometimes called a nonexpanding or metric map. Metric maps are commonly taken to be the morphisms of the category of metric spaces.
A -Lipschitz map for is called a contraction. The Banach fixed-point theorem states that if is a complete metric space, then every contraction
f:M\toM
f:M\toM
See main article: Quasi-isometry. A quasi-isometry is a map that preserves the "large-scale structure" of a metric space. Quasi-isometries need not be continuous. For example,
\R2
\Z2
Formally, the map
f\colonM1\toM2
M2
f(M1)
See also: Equivalence of metrics. Given two metric spaces
(M1,d1)
(M2,d2)
M1=M2
d1
d2
See main article: Normed vector space. A normed vector space is a vector space equipped with a norm, which is a function that measures the length of vectors. The norm of a vector is typically denoted by
\lVertv\rVert
\lVert{ ⋅ }\rVert
d(x,y)=d(x+a,y+a)
d(\alphax,\alphay)=|\alpha|d(x,y)
Among examples of metrics induced by a norm are the metrics,, and on
\R2
Infinite-dimensional normed vector spaces, particularly spaces of functions, are studied in functional analysis. Completeness is particularly important in this context: a complete normed vector space is known as a Banach space. An unusual property of normed vector spaces is that linear transformations between them are continuous if and only if they are Lipschitz. Such transformations are known as bounded operators.
See main article: Intrinsic metric. A curve in a metric space is a continuous function
\gamma:[0,T]\toM
A geodesic metric space is a metric space which admits a geodesic between any two of its points. The spaces
2,d | |
(\R | |
1) |
2,d | |
(\R | |
2) |
2,d | |
(\R | |
2) |
2,d | |
(\R | |
1) |
The space is a length space (or the metric is intrinsic) if the distance between any two points and is the infimum of lengths of paths between them. Unlike in a geodesic metric space, the infimum does not have to be attained. An example of a length space which is not geodesic is the Euclidean plane minus the origin: the points and can be joined by paths of length arbitrarily close to 2, but not by a path of length 2. An example of a metric space which is not a length space is given by the straight-line metric on the sphere: the straight line between two points through the center of the Earth is shorter than any path along the surface.
Given any metric space, one can define a new, intrinsic distance function on by setting the distance between points and to be infimum of the -lengths of paths between them. For instance, if is the straight-line distance on the sphere, then is the great-circle distance. However, in some cases may have infinite values. For example, if is the Koch snowflake with the subspace metric induced from
\R2
See main article: Riemannian manifold. A Riemannian manifold is a space equipped with a Riemannian metric tensor, which determines lengths of tangent vectors at every point. This can be thought of defining a notion of distance infinitesimally. In particular, a differentiable path
\gamma:[0,T]\toM
The Riemannian metric is uniquely determined by the distance function; this means that in principle, all information about a Riemannian manifold can be recovered from its distance function. One direction in metric geometry is finding purely metric ("synthetic") formulations of properties of Riemannian manifolds. For example, a Riemannian manifold is a space (a synthetic condition which depends purely on the metric) if and only if its sectional curvature is bounded above by . Thus spaces generalize upper curvature bounds to general metric spaces.
Real analysis makes use of both the metric on
\Rn
One application of metric measure spaces is generalizing the notion of Ricci curvature beyond Riemannian manifolds. Just as and Alexandrov spaces generalize sectional curvature bounds, RCD spaces are a class of metric measure spaces which generalize lower bounds on Ricci curvature.[6]
A if its induced topology is the discrete topology. Although many concepts, such as completeness and compactness, are not interesting for such spaces, they are nevertheless an object of study in several branches of mathematics. In particular, (those having a finite number of points) are studied in combinatorics and theoretical computer science.[7] Embeddings in other metric spaces are particularly well-studied. For example, not every finite metric space can be isometrically embedded in a Euclidean space or in Hilbert space. On the other hand, in the worst case the required distortion (bilipschitz constant) is only logarithmic in the number of points.[8] [9]
For any undirected connected graph, the set of vertices of can be turned into a metric space by defining the distance between vertices and to be the length of the shortest edge path connecting them. This is also called shortest-path distance or geodesic distance. In geometric group theory this construction is applied to the Cayley graph of a (typically infinite) finitely-generated group, yielding the word metric. Up to a bilipschitz homeomorphism, the word metric depends only on the group and not on the chosen finite generating set.
In modern mathematics, one often studies spaces whose points are themselves mathematical objects. A distance function on such a space generally aims to measure the dissimilarity between two objects. Here are some examples:
f\colonX\toM
M
\Rn
d(A,B)=rank(B-A)
The idea of spaces of mathematical objects can also be applied to subsets of a metric space, as well as metric spaces themselves. Hausdorff and Gromov–Hausdorff distance define metrics on the set of compact subsets of a metric space and the set of compact metric spaces, respectively.
Suppose is a metric space, and let be a subset of . The distance from to a point of is, informally, the distance from to the closest point of . However, since there may not be a single closest point, it is defined via an infimum:In particular,
d(x,S)=0
dS:M\to\R
dS(x)=d(x,S)
Given two subsets and of, their Hausdorff distance isInformally, two sets and are close to each other in the Hausdorff distance if no element of is too far from and vice versa. For example, if is an open set in Euclidean space is an ε-net inside, then
dH(S,T)<\varepsilon
dH(S,T)
The Gromov–Hausdorff metric defines a distance between (isometry classes of) compact metric spaces. The Gromov–Hausdorff distance between compact spaces and is the infimum of the Hausdorff distance over all metric spaces that contain and as subspaces. While the exact value of the Gromov–Hausdorff distance is rarely useful to know, the resulting topology has found many applications.
f\colon[0,infty)\to[0,infty)
df(x,y)=f(d(x,y))
Z2
Z2
d(x,y)=\lVertx\rVert+\lVerty\rVert
x
y
d(x,x)=0
\lVert ⋅ \rVert
f
S
0
S
d(x,y)=f(x)+f(y)
x
y
See main article: Product metric. If
(M1,d1),\ldots,(Mn,dn)
Rn
l(M1 x … x Mn,d x r)
Similarly, a metric on the topological product of countably many metric spaces can be obtained using the metric
The topological product of uncountably many metric spaces need not be metrizable. For example, an uncountable product of copies of
R
If is a metric space with metric, and
\sim
M/\sim
[x]
[y]
(p1,p2,...,pn)
(q1,q2,...,qn)
p1\simx
qn\simy
qi\simpi+1,i=1,2,...,n-1
d'([x],[y])=0
[x]=[y]
d'
The quotient metric
d'
f\colon(M,d)\to(X,\delta)
x\simy
\overline{f}\colon{M/\sim}\toX
\overline{f}([x])=f(x)
\overline{f}\colon(M/\sim,d')\to(X,\delta).
The quotient metric does not always induce the quotient topology. For example, the topological quotient of the metric space
\N x [0,1]
(n,0)
A topological space is sequential if and only if it is a (topological) quotient of a metric space.[13]
There are several notions of spaces which have less structure than a metric space, but more than a topological space.
There are also numerous ways of relaxing the axioms for a metric, 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.
Some authors define metrics so as to allow the distance function to attain the value ∞, i.e. distances are non-negative numbers on the extended real number line. Such a function is also called an extended metric or "∞-metric". Every extended metric can be replaced by a real-valued metric that is topologically equivalent. 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))
d''(x,y)=min(1,d(x,y))
The requirement that the metric take values in
[0,infty)
These generalizations still induce a uniform structure on the space.
See main article: Pseudometric space. A pseudometric on
X
d:X x X\to\R
d(x,x)=0
x
d(x,y)\geq0
d(x,x)=0
d(x,y)=d(y,x)
d(x,z)\leqd(x,y)+d(y,z)
In some contexts, pseudometrics are referred to as semimetrics because of their relation to seminorms.
Occasionally, a quasimetric is defined as a function that satisfies all axioms for a metric with the possible exception of symmetry. The name of this generalisation is not entirely standardized.[14]
d(x,y)\geq0
d(x,y)=0\iffx=y
d(x,z)\leqd(x,y)+d(y,z)
Quasimetrics are common in real life. For example, given a set of mountain villages, the typical walking times between elements of form a quasimetric because travel uphill takes longer than travel downhill. Another example is the length of car rides in a city with one-way streets: here, a shortest path from point to point goes along a different set of streets than a shortest path from to and may have a different length.
A quasimetric on the reals can be defined by settingThe 1 may be replaced, for example, by infinity or by
1+\sqrt{y-x}
Given a quasimetric on, one can define an -ball around to be the set
\{y\inX|d(x,y)\leqR\}
In a metametric, all the axioms of a metric are satisfied except that the distance between identical points is not necessarily zero. In other words, the axioms for a metametric are:
d(x,y)\geq0
d(x,y)=0\impliesx=y
d(x,y)=d(y,x)
d(x,z)\leqd(x,y)+d(y,z).
Metametrics appear in the study of Gromov hyperbolic metric spaces and their boundaries. The visual metametric on such a space satisfies
d(x,x)=0
x
d(x,x)
x
A semimetric on
X
d:X x X\to\R
d(x,y)\geq0
d(x,y)=0\iffx=y
d(x,y)=d(y,x)
Some authors work with a weaker form of the triangle inequality, such as:
d(x,z)\leq\rho(d(x,y)+d(y,z)) | ρ-relaxed triangle inequality | |
d(x,z)\leq\rhomax\{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.
Relaxing the last three axioms leads to the notion of a premetric, i.e. a function satisfying the following conditions:
d(x,y)\geq0
d(x,x)=0
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". A premetric that satisfies symmetry, i.e. a pseudosemimetric, is also called a distance.
Any premetric gives rise to a topology as follows. For a positive real
r
p
Br(p)=\{x|d(x,p)<r\}.
p
p
A
B
d(A,B)=\underset{x\inA,y\inB}infd(x,y).
cl
cl(A)=\{x|d(x,A)=0\}.
The prefixes 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 form a basis of open sets. A very basic example of a pseudoquasimetric space is the set
\{0,1\}
d(0,1)=1
d(1,0)=0.
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.
Lawvere also gave an alternate definition of such spaces as enriched categories. The ordered set
(R,\geq)
a\tob
a\geqb
R*
(M,d)
M*
R*
d(x,y)<infty
d(x,y)
R*
d(x,x)=0
R*
The notion of a metric can be generalized from a distance between two elements to a number assigned to a multiset of elements. A multiset is a generalization of the notion of a set in which an element can occur more than once. Define the multiset union
U=XY
d(X)=0
d(X)>0
d(X)
d(XY)\leqd(XZ)+d(ZY)
A simple example is the set of all nonempty finite multisets
X
d(X)=max(X)-min(X)
\N x [0,1]/\N x \{0\}