
In
mathematics
Mathematics is a field of study that discovers and organizes methods, Mathematical theory, theories and theorems that are developed and Mathematical proof, proved for the needs of empirical sciences and mathematics itself. There are many ar ...
, a metric space is a
set together with a notion of ''
distance
Distance is a numerical or occasionally qualitative measurement of how far apart objects, points, people, or ideas are. In physics or everyday usage, distance may refer to a physical length or an estimation based on other criteria (e.g. "two co ...
'' between its
elements, usually called
points. The distance is measured by a
function called a metric or distance function. Metric spaces are a general setting for studying many of the concepts of
mathematical analysis
Analysis is the branch of mathematics dealing with continuous functions, limit (mathematics), limits, and related theories, such as Derivative, differentiation, Integral, integration, measure (mathematics), measure, infinite sequences, series ( ...
and
geometry
Geometry (; ) is a branch of mathematics concerned with properties of space such as the distance, shape, size, and relative position of figures. Geometry is, along with arithmetic, one of the oldest branches of mathematics. A mathematician w ...
.
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
A sphere (from Ancient Greek, Greek , ) is a surface (mathematics), surface analogous to the circle, a curve. In solid geometry, a sphere is the Locus (mathematics), set of points that are all at the same distance from a given point in three ...
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
In information theory, the Hamming distance between two String (computer science), strings or vectors of equal length is the number of positions at which the corresponding symbols are different. In other words, it measures the minimum number ...
, 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 manifold
In differential geometry, a Riemannian manifold is a geometric space on which many geometric notions such as distance, angles, length, volume, and curvature are defined. Euclidean space, the N-sphere, n-sphere, hyperbolic space, and smooth surf ...
s,
normed vector spaces, and
graphs. In
abstract algebra
In mathematics, more specifically algebra, abstract algebra or modern algebra is the study of algebraic structures, which are set (mathematics), sets with specific operation (mathematics), operations acting on their elements. Algebraic structur ...
, the
''p''-adic numbers arise as elements of the
completion of a metric structure on the
rational numbers
In mathematics, a rational number is a number that can be expressed as the quotient or fraction (mathematics), fraction of two integers, a numerator and a non-zero denominator . For example, is a rational number, as is every integer (for examp ...
. 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
Analysis is the branch of mathematics dealing with continuous functions, limit (mathematics), limits, and related theories, such as Derivative, differentiation, Integral, integration, measure (mathematics), measure, infinite sequences, series ( ...
, including
balls,
completeness, as well as
uniform
A uniform is a variety of costume worn by members of an organization while usually participating in that organization's activity. Modern uniforms are most often worn by armed forces and paramilitary organizations such as police, emergency serv ...
,
Lipschitz, and
Hölder continuity, can be defined in the setting of metric spaces. Other notions, such as
continuity,
compactness, and
open and
closed set
In geometry, topology, and related branches of mathematics, a closed set is a Set (mathematics), set whose complement (set theory), complement is an open set. In a topological space, a closed set can be defined as a set which contains all its lim ...
s, can be defined for metric spaces, but also in the even more general setting of
topological space
In mathematics, a topological space is, roughly speaking, a Geometry, geometrical space in which Closeness (mathematics), closeness is defined but cannot necessarily be measured by a numeric Distance (mathematics), distance. More specifically, a to ...
s.
Definition and illustration
Motivation

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
Seismology (; from Ancient Greek σεισμός (''seismós'') meaning "earthquake" and -λογία (''-logía'') meaning "study of") is the scientific study of earthquakes (or generally, quakes) and the generation and propagation of elastic ...
, 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
In information theory, the Hamming distance between two String (computer science), strings or vectors of equal length is the number of positions at which the corresponding symbols are different. In other words, it measures the minimum number ...
between two strings of characters, or the
Gromov–Hausdorff distance between metric spaces themselves).
Definition
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
:
# The distance from a point to itself is zero:
# (Positivity) The distance between two distinct points is always positive:
# (
Symmetry
Symmetry () in everyday life refers to a sense of harmonious and beautiful proportion and balance. In mathematics, the term has a more precise definition and is usually used to refer to an object that is Invariant (mathematics), invariant und ...
) The distance from to is always the same as the distance from to :
# The
triangle inequality
In mathematics, the triangle inequality states that for any triangle, the sum of the lengths of any two sides must be greater than or equal to the length of the remaining side.
This statement permits the inclusion of Degeneracy (mathematics)#T ...
holds:
This is a natural property of both physical and metaphorical notions of distance: you can arrive at from by taking a detour through , but this will not make your journey any shorter than the direct path.
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
.
Simple examples
The real numbers
The
real number
In mathematics, a real number is a number that can be used to measure a continuous one- dimensional quantity such as a duration or temperature. Here, ''continuous'' means that pairs of values can have arbitrarily small differences. Every re ...
s with the distance function
given by the
absolute difference form a metric space. Many properties of metric spaces and functions between them are generalizations of concepts in
real analysis
In mathematics, the branch of real analysis studies the behavior of real numbers, sequences and series of real numbers, and real functions. Some particular properties of real-valued sequences and functions that real analysis studies include co ...
and coincide with those concepts when applied to the real line.
Metrics on Euclidean spaces

The Euclidean plane
can be equipped with many different metrics. The
Euclidean distance familiar from school mathematics can be defined by
The
''taxicab'' or ''Manhattan'' distance is defined by
and 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'',
, or ''
Chebyshev distance'' is defined by
This distance does not have an easy explanation in terms of paths in the plane, but it still satisfies the metric space axioms. It can be thought of similarly to the number of moves a
king
King is a royal title given to a male monarch. A king is an Absolute monarchy, absolute monarch if he holds unrestricted Government, governmental power or exercises full sovereignty over a nation. Conversely, he is a Constitutional monarchy, ...
would have to make on a
chess
Chess is a board game for two players. It is an abstract strategy game that involves Perfect information, no hidden information and no elements of game of chance, chance. It is played on a square chessboard, board consisting of 64 squares arran ...
board to travel from one point to another on the given space.
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 formula
which holds for every pair of points
.
A radically different distance can be defined by setting
Using
Iverson brackets,