TheInfoList

In
mathematics Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geometry), and quantities and their changes (cal ...
, the Euclidean distance between two points in
Euclidean space Euclidean space is the fundamental space of . Originally, it was the of , but in modern there are Euclidean spaces of any nonnegative integer , including the three-dimensional space and the ''Euclidean plane'' (dimension two). It was introduce ...
is the length of a
line segment 250px, The geometric definition of a closed line segment: the intersection of all points at or to the right of ''A'' with all points at or to the left of ''B'' In geometry Geometry (from the grc, γεωμετρία; ''wikt:γῆ, geo-'' ...

between the two points. It can be calculated from the
Cartesian coordinate A Cartesian coordinate system (, ) in a plane is a coordinate system In geometry Geometry (from the grc, γεωμετρία; ''wikt:γῆ, geo-'' "earth", ''wikt:μέτρον, -metron'' "measurement") is, with arithmetic, one of the o ...

s of the points using the
Pythagorean theorem In mathematics, the Pythagorean theorem, or Pythagoras' theorem, is a fundamental relation in Euclidean geometry among the three sides of a right triangle. It states that the area of the square whose side is the hypotenuse (the side opposite ...

, therefore occasionally being called the Pythagorean distance. These names come from the ancient Greek mathematicians
Euclid Euclid (; grc-gre, Εὐκλείδης Euclid (; grc, Εὐκλείδης – ''Eukleídēs'', ; fl. 300 BC), sometimes called Euclid of Alexandria to distinguish him from Euclid of Megara, was a Greek mathematician, often referre ...

and
Pythagoras Pythagoras of Samos, or simply ; in Ionian Greek () was an ancient Ionians, Ionian Ancient Greek philosophy, Greek philosopher and the eponymous founder of Pythagoreanism. His political and religious teachings were well known in Magna Graec ...

, although Euclid did not represent distances as numbers, and the connection from the Pythagorean theorem to distance calculation was not made until the 18th century. The distance between two objects that are not points is usually defined to be the smallest distance among pairs of points from the two objects. Formulas are known for computing distances between different types of objects, such as the
distance from a point to a line In Euclidean geometry Euclidean geometry is a mathematical system attributed to Alexandrian Greek mathematics , Greek mathematician Euclid, which he described in his textbook on geometry: the ''Euclid's Elements, Elements''. Euclid's method cons ...

. In advanced mathematics, the concept of distance has been generalized to abstract
metric space In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers ( and ), formulas and related structures (), shapes and spaces in which they are contained (), and quantities and their changes ( and ). There is no gene ...
s, and other distances than Euclidean have been studied. In some applications in
statistics Statistics is the discipline that concerns the collection, organization, analysis, interpretation, and presentation of data Data (; ) are individual facts, statistics, or items of information, often numeric. In a more technical sens ...

and
optimization File:Nelder-Mead Simionescu.gif, Nelder-Mead minimum search of Test functions for optimization, Simionescu's function. Simplex vertices are ordered by their values, with 1 having the lowest ( best) value., alt= Mathematical optimization (alter ...
, the square of the Euclidean distance is used instead of the distance itself.

# Distance formulas

## One dimension

The distance between any two points on the
real line In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geometry), and quantities and ...
is the
absolute value In , the absolute value or modulus of a  , denoted , is the value of  without regard to its . Namely, if is , and if is (in which case is positive), and . For example, the absolute value of 3 is 3, and the absolute value of − ...

of the numerical difference of their coordinates. Thus if $p$ and $q$ are two points on the real line, then the distance between them is given by: $d(p,q) = , p-q, .$ A more complicated formula, giving the same value, but generalizing more readily to higher dimensions, is: $d(p,q) = \sqrt.$ In this formula, squaring and then taking the
square root In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geometry), and quantities ...

leaves any positive number unchanged, but replaces any negative number by its absolute value.

## Two dimensions

In the
Euclidean plane In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers ( and ), formulas and related structures (), shapes and spaces in which they are contained (), and quantities and their changes ( and ). There is no g ...
, let point $p$ have
Cartesian coordinates A Cartesian coordinate system (, ) in a plane Plane or planes may refer to: * Airplane or aeroplane or informally plane, a powered, fixed-wing aircraft Arts, entertainment and media *Plane (Dungeons & Dragons), Plane (''Dungeons & Dragons'') ...

$\left(p_1,p_2\right)$ and let point $q$ have coordinates $\left(q_1,q_2\right)$. Then the distance between $p$ and $q$ is given by: $d(p,q) = \sqrt.$ This can be seen by applying the
Pythagorean theorem In mathematics, the Pythagorean theorem, or Pythagoras' theorem, is a fundamental relation in Euclidean geometry among the three sides of a right triangle. It states that the area of the square whose side is the hypotenuse (the side opposite ...

to a
right triangle A right triangle (American English American English (AmE, AE, AmEng, USEng, en-US), sometimes called United States English or U.S. English, is the set of varieties of the English language native to the United States. Currently, American Eng ...

with horizontal and vertical sides, having the line segment from $p$ to $q$ as its hypotenuse. The two squared formulas inside the square root give the areas of squares on the horizontal and vertical sides, and the outer square root converts the area of the square on the hypotenuse into the length of the hypotenuse. It is also possible to compute the distance for points given by
polar coordinates In mathematics Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathematical analysis, analysis). It ...

. If the polar coordinates of $p$ are $\left(r,\theta\right)$ and the polar coordinates of $q$ are $\left(s,\psi\right)$, then their distance is given by the
law of cosines In trigonometry Trigonometry (from Greek '' trigōnon'', "triangle" and '' metron'', "measure") is a branch of mathematics Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathem ...
: $d(p,q)=\sqrt.$ When $p$ and $q$ are expressed as
complex number In mathematics, a complex number is an element of a number system that contains the real numbers and a specific element denoted , called the imaginary unit, and satisfying the equation . Moreover, every complex number can be expressed in the for ...

s in the
complex plane In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers ( and ), formulas and related structures (), shapes and spaces in which they are contained (), and quantities and their changes ( and ). There is no ge ...
, the same formula for one-dimensional points expressed as real numbers can be used: $d(p,q)=, p-q, .$

## Higher dimensions

In three dimensions, for points given by their Cartesian coordinates, the distance is $d(p,q)=\sqrt.$ In general, for points given by Cartesian coordinates in $n$-dimensional Euclidean space, the distance is $d(p,q) = \sqrt.$

## Objects other than points

For pairs of objects that are not both points, the distance can most simply be defined as the smallest distance between any two points from the two objects, although more complicated generalizations from points to sets such as
Hausdorff distanceIn mathematics, the Hausdorff distance, or Hausdorff metric, also called Pompeiu–Hausdorff distance, measures how far two subsets of a metric space are from each other. It turns the set of non-empty set, non-empty compact space, compact subsets of ...
are also commonly used. Formulas for computing distances between different types of objects include: *The
distance from a point to a line In Euclidean geometry Euclidean geometry is a mathematical system attributed to Alexandrian Greek mathematics , Greek mathematician Euclid, which he described in his textbook on geometry: the ''Euclid's Elements, Elements''. Euclid's method cons ...

, in the Euclidean plane *The
distance from a point to a planeIn Euclidean space Euclidean space is the fundamental space of classical geometry. Originally it was the three-dimensional space of Euclidean geometry, but in modern mathematics there are Euclidean spaces of any nonnegative integer dimension (math ...
in three-dimensional Euclidean space *The
distance between two linesThe distance between two parallel lines in the plane is the minimum distance between any two points lying on the lines. It equals the perpendicular In elementary geometry, the property of being perpendicular (perpendicularity) is the relation ...

in three-dimensional Euclidean space

# Properties

The Euclidean distance is the prototypical example of the distance in a
metric space In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers ( and ), formulas and related structures (), shapes and spaces in which they are contained (), and quantities and their changes ( and ). There is no gene ...
, and obeys all the defining properties of a metric space: *It is ''symmetric'', meaning that for all points $p$ and $q$, $d\left(p,q\right)=d\left(q,p\right)$. That is (unlike road distance with one-way streets) the distance between two points does not depend on which of the two points is the start and which is the destination. *It is ''positive'', meaning that the distance between every two distinct points is a
positive number In mathematics Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathematical analysis, analysis). It ...
, while the distance from any point to itself is zero. *It obeys the : for every three points $p$, $q$, and $r$, $d\left(p,q\right)+d\left(q,r\right)\ge d\left(p,r\right)$. Intuitively, traveling from $p$ to $r$ via $q$ cannot be any shorter than traveling directly from $p$ to $r$. Another property, Ptolemy's inequality, concerns the Euclidean distances among four points $p$, $q$, $r$, and $s$. It states that $d(p,q)\cdot d(r,s)+d(q,r)\cdot d(p,s)\ge d(p,r)\cdot d(q,s).$ For points in the plane, this can be rephrased as stating that for every
quadrilateral A quadrilateral is a polygon in Euclidean geometry, Euclidean plane geometry with four Edge (geometry), edges (sides) and four Vertex (geometry), vertices (corners). Other names for quadrilateral include quadrangle (in analogy to triangle) and ...

, the products of opposite sides of the quadrilateral sum to at least as large a number as the product of its diagonals. However, Ptolemy's inequality applies more generally to points in Euclidean spaces of any dimension, no matter how they are arranged. Euclidean
distance geometryDistance geometry is the characterization Characterization or characterisation is the representation of persons (or other beings or creatures) in narrative and dramatic The arts, works. The term character development is sometimes used as a synonym ...
studies properties of Euclidean distance such as Ptolemy's inequality, and their application in testing whether given sets of distances come from points in a Euclidean space.

# Squared Euclidean distance

In many applications, and in particular when comparing distances, it may be more convenient to omit the final square root in the calculation of Euclidean distances. The value resulting from this omission is the
square In Euclidean geometry, a square is a regular The term regular can mean normal or in accordance with rules. It may refer to: People * Moses Regular (born 1971), America football player Arts, entertainment, and media Music * Regular (Badfinger ...
of the Euclidean distance, and is called the squared Euclidean distance. As an equation, it can be expressed as a sum of squares: $d^2(p,q) = (p_1 - q_1)^2 + (p_2 - q_2)^2+\cdots+(p_i - q_i)^2+\cdots+(p_n - q_n)^2.$ Beyond its application to distance comparison, squared Euclidean distance is of central importance in
statistics Statistics is the discipline that concerns the collection, organization, analysis, interpretation, and presentation of data Data (; ) are individual facts, statistics, or items of information, often numeric. In a more technical sens ...

, where it is used in the method of
least squares The method of least squares is a standard approach in regression analysis to approximate the solution of overdetermined systems (sets of equations in which there are more equations than unknowns) by minimizing the sum of the squares of the resid ...
, a standard method of fitting statistical estimates to data by minimizing the average of the squared distances between observed and estimated values. The addition of squared distances to each other, as is done in least squares fitting, corresponds to an operation on (unsquared) distances called Pythagorean addition. In
cluster analysis Cluster analysis or clustering is the task of grouping a set of objects in such a way that objects in the same group (called a cluster) are more similar (in some sense) to each other than to those in other groups (clusters). It is a main task of ...
, squared distances can be used to strengthen the effect of longer distances. Squared Euclidean distance does not form a metric space, as it does not satisfy the triangle inequality. However it is a smooth, strictly
convex function (in green) is a convex set File:Convex polygon illustration2.svg, Illustration of a non-convex set. Illustrated by the above line segment whereby it changes from the black color to the red color. Exemplifying why this above set, illustrated in gr ...

of the two points, unlike the distance, which is non-smooth (near pairs of equal points) and convex but not strictly convex. The squared distance is thus preferred in
optimization theory Nelder-Mead minimum search of Simionescu's function. Simplex vertices are ordered by their values, with 1 having the lowest ( best) value., alt= Mathematical optimization (alternatively spelled ''optimisation'') or mathematical programming i ...
, since it allows
convex analysis Convex analysis is the branch of mathematics Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathemat ...
to be used. Since squaring is a
monotonic function In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geometry), and quantities a ...
of non-negative values, minimizing squared distance is equivalent to minimizing the Euclidean distance, so the optimization problem is equivalent in terms of either, but easier to solve using squared distance. The collection of all squared distances between pairs of points from a finite set may be stored in a Euclidean distance matrix, and is used in this form in distance geometry.

# Generalizations

In more advanced areas of mathematics, when viewing Euclidean space as a
vector space In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geometry), and quantities a ...
, its distance is associated with a
norm Norm, the Norm or NORM may refer to: In academic disciplines * Norm (geology), an estimate of the idealised mineral content of a rock * Norm (philosophy) Norms are concepts ( sentences) of practical import, oriented to effecting an action, rat ...
called the
Euclidean norm Euclidean space is the fundamental space of classical geometry. Originally it was the three-dimensional space Three-dimensional space (also: 3-space or, rarely, tri-dimensional space) is a geometric setting in which three values (called pa ...
, defined as the distance of each vector from the
origin Origin(s) or The Origin may refer to: Arts, entertainment, and media Comics and manga * Origin (comics), ''Origin'' (comics), a Wolverine comic book mini-series published by Marvel Comics in 2002 * The Origin (Buffy comic), ''The Origin'' (Bu ...
. One of the important properties of this norm, relative to other norms, is that it remains unchanged under arbitrary rotations of space around the origin. By
Dvoretzky's theoremIn mathematics, Dvoretzky's theorem is an important structural theorem about normed vector spaces proved by Aryeh Dvoretzky in the early 1960s, answering a question of Alexander Grothendieck. In essence, it says that every sufficiently high-dimension ...
, every finite-dimensional
normed vector space In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers ( and ), formulas and related structures (), shapes and spaces in which they are contained (), and quantities and their changes ( and ). There is no g ...
has a high-dimensional subspace on which the norm is approximately Euclidean; the Euclidean norm is the only norm with this property. It can be extended to infinite-dimensional vector spaces as the L2 norm or L2 distance. Other common distances on Euclidean spaces and low-dimensional vector spaces include: *
Chebyshev distance In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geometry), and quantities and ...
, which measures distance assuming only the most significant dimension is relevant. *
Manhattan distance A taxicab geometry is a form of geometry in which the usual distance function or Metric (mathematics), metric of Euclidean geometry is replaced by a new metric in which the distance between two points is the sum of the absolute differences of thei ...

, which measures distance following only axis-aligned directions. *
Minkowski distance The Minkowski distance or Minkowski metric is a metric METRIC (Mapping EvapoTranspiration at high Resolution with Internalized Calibration) is a computer model Computer simulation is the process of mathematical modelling, performed on a comp ...
, a generalization that unifies Euclidean distance, Manhattan distance, and Chebyshev distance. For points on surfaces in three dimensions, the Euclidean distance should be distinguished from the
geodesic In geometry Geometry (from the grc, γεωμετρία; ' "earth", ' "measurement") is, with , one of the oldest branches of . It is concerned with properties of space that are related with distance, shape, size, and relative position o ...

distance, the length of a shortest curve that belongs to the surface. In particular, for measuring great-circle distances on the earth or other spherical or near-spherical surfaces, distances that have been used include the haversine distance giving great-circle distances between two points on a sphere from their longitudes and latitudes, and
Vincenty's formulae Vincenty's formulae are two related iterative method In computational mathematics, an iterative method is a Algorithm, mathematical procedure that uses an initial value to generate a sequence of improving approximate solutions for a class of problem ...
also known as "Vincent distance" for distance on a spheroid.

# History

Euclidean distance is the distance in
Euclidean space Euclidean space is the fundamental space of . Originally, it was the of , but in modern there are Euclidean spaces of any nonnegative integer , including the three-dimensional space and the ''Euclidean plane'' (dimension two). It was introduce ...
; both concepts are named after ancient Greek mathematician
Euclid Euclid (; grc-gre, Εὐκλείδης Euclid (; grc, Εὐκλείδης – ''Eukleídēs'', ; fl. 300 BC), sometimes called Euclid of Alexandria to distinguish him from Euclid of Megara, was a Greek mathematician, often referre ...

, whose ''Elements'' became a standard textbook in geometry for many centuries. Concepts of
length Length is a measure of distance Distance is a numerical measurement ' Measurement is the number, numerical quantification (science), quantification of the variable and attribute (research), attributes of an object or event, which can be us ...

and
distance Distance is a numerical measurement ' Measurement is the number, numerical quantification (science), quantification of the variable and attribute (research), attributes of an object or event, which can be used to compare with other objects or eve ...

are widespread across cultures, can be dated to the earliest surviving "protoliterate" bureaucratic documents from
Sumer Sumer ()The name is from Akkadian language, Akkadian '; Sumerian language, Sumerian ''kig̃ir'', written and ,approximately "land of the civilized kings" or "native land". means "native, local", iĝir NATIVE (7x: Old Babylonian)from ''The ...

in the fourth millennium BC (far before Euclid), and have been hypothesized to develop in children earlier than the related concepts of speed and time. But the notion of a distance, as a number defined from two points, does not actually appear in Euclid's ''Elements''. Instead, Euclid approaches this concept implicitly, through the
congruence Congruence may refer to: Mathematics * Congruence (geometry), being the same size and shape * Congruence or congruence relation, in abstract algebra, an equivalence relation on an algebraic structure that is compatible with the structure * In modu ...
of line segments, through the comparison of lengths of line segments, and through the concept of proportionality. The
Pythagorean theorem In mathematics, the Pythagorean theorem, or Pythagoras' theorem, is a fundamental relation in Euclidean geometry among the three sides of a right triangle. It states that the area of the square whose side is the hypotenuse (the side opposite ...

is also ancient, but it could only take its central role in the measurement of distances after the invention of
Cartesian coordinates A Cartesian coordinate system (, ) in a plane Plane or planes may refer to: * Airplane or aeroplane or informally plane, a powered, fixed-wing aircraft Arts, entertainment and media *Plane (Dungeons & Dragons), Plane (''Dungeons & Dragons'') ...

by
René Descartes René Descartes ( or ; ; Latinized Latinisation or Latinization can refer to: * Latinisation of names, the practice of rendering a non-Latin name in a Latin style * Latinisation in the Soviet Union, the campaign in the USSR during the 1920s ...

in 1637. The distance formula itself was first published in 1731 by
Alexis Clairaut Alexis Claude Clairaut (; 13 May 1713 – 17 May 1765) was a French mathematician, astronomer, and geophysicist. He was a prominent Newtonian whose work helped to establish the validity of the principles and results that Sir Isaac Newton ...
. Because of this formula, Euclidean distance is also sometimes called Pythagorean distance. Although accurate measurements of long distances on the earth's surface, which are not Euclidean, had again been studied in many cultures since ancient times (see
history of geodesy History (from Greek Greek may refer to: Greece Anything of, from, or related to Greece Greece ( el, Ελλάδα, , ), officially the Hellenic Republic, is a country located in Southeast Europe. Its population is approximately 10.7 millio ...
), the idea that Euclidean distance might not be the only way of measuring distances between points in mathematical spaces came even later, with the 19th-century formulation of
non-Euclidean geometry In mathematics, non-Euclidean geometry consists of two geometries based on axioms closely related to those that specify Euclidean geometry. As Euclidean geometry lies at the intersection of metric geometry and affine geometry, non-Euclidean geome ...
. The definition of the Euclidean norm and Euclidean distance for geometries of more than three dimensions also first appeared in the 19th century, in the work of
Augustin-Louis Cauchy Baron Baron is a rank of nobility or title of honour, often hereditary, in various European countries, either current or historical. The female equivalent is baroness. Typically, the title denotes an aristocrat who ranks higher than a lord ...

.