Euclidean distance

In
These names come from the ancient
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 advanced mathematics, the concept of distance has been generalized to abstract metric spaces, and other distances than Euclidean have been studied. In some applications in statistics and optimization, 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
A more complicated formula, giving the same value, but generalizing more readily to higher dimensions, is:[1]
In this formula, squaring and then taking the square root leaves any positive number unchanged, but replaces any negative number by its absolute value.[1]
Two dimensions
In the Euclidean plane, let point have
This can be seen by applying the Pythagorean theorem to a right triangle with horizontal and vertical sides, having the line segment from to 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.[3] In terms of the Pythagorean addition operation , available in many
hypot
, the same formula can be expressed as:[4]
It is also possible to compute the distance for points given by polar coordinates. If the polar coordinates of are and the polar coordinates of are , then their distance is[2] given by the law of cosines:
When and are expressed as
Higher dimensions

In three dimensions, for points given by their Cartesian coordinates, the distance is
In general, for points given by Cartesian coordinates in -dimensional Euclidean space, the distance is[6]
The Euclidean distance may also be expressed more compactly in terms of the
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 distance are also commonly used.[7] Formulas for computing distances between different types of objects include:
- The distance from a point to a line, in the Euclidean plane[8]
- The distance from a point to a plane in three-dimensional Euclidean space[8]
- The distance between two lines in three-dimensional Euclidean space[9]
The distance from a point to a curve can be used to define its parallel curve, another curve all of whose points have the same distance to the given curve.[10]
Properties
The Euclidean distance is the prototypical example of the distance in a metric space,[11] and obeys all the defining properties of a metric space:[12]
- It is symmetric, meaning that for all points and , . 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.[12]
- It is positive, meaning that the distance between every two distinct points is a positive number, while the distance from any point to itself is zero.[12]
- It obeys the triangle inequality: for every three points , , and , . Intuitively, traveling from to via cannot be any shorter than traveling directly from to .[12]
Another property, Ptolemy's inequality, concerns the Euclidean distances among four points , , , and . It states that
For points in the plane, this can be rephrased as stating that for every quadrilateral, 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.[13] For points in metric spaces that are not Euclidean spaces, this inequality may not be true. Euclidean distance geometry 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.[14]
According to the Beckman–Quarles theorem, any transformation of the Euclidean plane or of a higher-dimensional Euclidean space that preserves unit distances must be an isometry, preserving all distances.[15]
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, as the square root does not change the order ( if and only if ). The value resulting from this omission is the square of the Euclidean distance, and is called the squared Euclidean distance.[16] For instance, the Euclidean minimum spanning tree can be determined using only the ordering between distances, and not their numeric values. Comparing squared distances produces the same result but avoids an unnecessary square-root calculation and sidesteps issues of numerical precision.[17] As an equation, the squared distance can be expressed as a sum of squares:
Beyond its application to distance comparison, squared Euclidean distance is of central importance in statistics, where it is used in the method of least squares, a standard method of fitting statistical estimates to data by minimizing the average of the squared distances between observed and estimated values,[18] and as the simplest form of divergence to compare probability distributions.[19] 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.[20] In cluster analysis, squared distances can be used to strengthen the effect of longer distances.[16]
Squared Euclidean distance does not form a metric space, as it does not satisfy the triangle inequality.
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.[23]
Generalizations
In more advanced areas of mathematics, when viewing Euclidean space as a vector space, its distance is associated with a norm called the Euclidean norm, defined as the distance of each vector from the origin. 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.[24] By Dvoretzky's theorem, every finite-dimensional normed vector space has a high-dimensional subspace on which the norm is approximately Euclidean; the Euclidean norm is the
only norm with this property.

Other common distances in real coordinate spaces and function spaces:[28]
- Chebyshev distance (L∞ distance), which measures distance as the maximum of the distances in each coordinate.
- Taxicab distance(L1 distance), also called Manhattan distance, which measures distance as the sum of the distances in each coordinate.
- Minkowski distance (Lp distance), a generalization that unifies Euclidean distance, taxicab distance, and Chebyshev distance.
For points on surfaces in three dimensions, the Euclidean distance should be distinguished from the
History
Euclidean distance is the distance in Euclidean space. Both concepts are named after ancient Greek mathematician Euclid, whose Elements became a standard textbook in geometry for many centuries.[30] Concepts of length and distance are widespread across cultures, can be dated to the earliest surviving "protoliterate" bureaucratic documents from Sumer in the fourth millennium BC (far before Euclid),[31] and have been hypothesized to develop in children earlier than the related concepts of speed and time.[32] 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 of line segments, through the comparison of lengths of line segments, and through the concept of proportionality.[33]
The
References
- ^ ISBN 978-0-7637-5177-7
- ^ ISBN 978-0-534-40212-9
- ISBN 978-1-111-80864-8
- ISBN 9789367840320
- ISBN 978-0-8176-8415-0
- ISBN 978-0-8160-6876-0
- ISBN 978-1-84628-627-8
- ^ JSTOR 2306514
- ^ Bell, Robert J. T. (1914), "49. The shortest distance between two lines", An Elementary Treatise on Coordinate Geometry of Three Dimensions (2nd ed.), Macmillan, pp. 57–61
- ISBN 978-1-4612-0553-1
- ^ ISBN 978-0-7637-1497-0
- ISBN 978-1-4008-8540-4
- ISBN 978-3-319-60792-4
- MR 0058193
- ^ ISBN 978-1-4665-8479-2
- MR 0677663
- ISBN 978-0-19-976404-4
- MR 0365798
- ISBN 978-1-4419-4974-5
- ISBN 978-1-118-03104-9
- ISBN 978-3-319-97846-8
- ISBN 978-3-527-63457-6
- ISBN 978-0-387-95373-1
- ISBN 978-1-61197-258-0
- ISBN 978-3-11-068657-9
- ISBN 978-1-4822-2314-9
- ISBN 978-3-540-75148-9
- ^ Høyrup, Jens (2018), "Mesopotamian mathematics" (PDF), in Jones, Alexander; Taub, Liba (eds.), The Cambridge History of Science, Volume 1: Ancient Science, Cambridge University Press, pp. 58–72, archived from the original (PDF) on May 17, 2021, retrieved October 21, 2020
- ISBN 978-0-691-19688-6
- MR 0634431
- ISBN 978-3-030-31597-9