# Euclidean distance

Last updated

In mathematics, the Euclidean distance between two points in Euclidean space is the length of a line segment between the two points. It can be calculated from the Cartesian coordinates of the points using the Pythagorean theorem, therefore occasionally being called the Pythagorean distance. These names come from the ancient Greek mathematicians Euclid and Pythagoras, 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.

## Contents

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 real line is the absolute value of the numerical difference of their coordinates. Thus if ${\displaystyle p}$ and ${\displaystyle q}$ are two points on the real line, then the distance between them is given by: [1]

${\displaystyle d(p,q)=|p-q|.}$

A more complicated formula, giving the same value, but generalizing more readily to higher dimensions, is: [1]

${\displaystyle d(p,q)={\sqrt {(p-q)^{2}}}.}$

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 ${\displaystyle p}$ have Cartesian coordinates ${\displaystyle (p_{1},p_{2})}$ and let point ${\displaystyle q}$ have coordinates ${\displaystyle (q_{1},q_{2})}$. Then the distance between ${\displaystyle p}$ and ${\displaystyle q}$ is given by: [2]

${\displaystyle d(p,q)={\sqrt {(q_{1}-p_{1})^{2}+(q_{2}-p_{2})^{2}}}.}$

This can be seen by applying the Pythagorean theorem to a right triangle with horizontal and vertical sides, having the line segment from ${\displaystyle p}$ to ${\displaystyle 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. [3]

It is also possible to compute the distance for points given by polar coordinates. If the polar coordinates of ${\displaystyle p}$ are ${\displaystyle (r,\theta )}$ and the polar coordinates of ${\displaystyle q}$ are ${\displaystyle (s,\psi )}$, then their distance is [2] given by Law of cosines:

${\displaystyle d(p,q)={\sqrt {r^{2}+s^{2}-2rs\cos(\theta -\psi )}}.}$

When ${\displaystyle p}$ and ${\displaystyle q}$ are expressed as complex numbers in the complex plane, the same formula for one-dimensional points expressed as real numbers can be used: [4]

${\displaystyle d(p,q)=|p-q|.}$

### Higher dimensions

In three dimensions, for points given by their Cartesian coordinates, the distance is

${\displaystyle d(p,q)={\sqrt {(p_{1}-q_{1})^{2}+(p_{2}-q_{2})^{2}+(p_{3}-q_{3})^{2}}}.}$

In general, for points given by Cartesian coordinates in ${\displaystyle n}$-dimensional Euclidean space, the distance is [5]

${\displaystyle d(p,q)={\sqrt {(p_{1}-q_{1})^{2}+(p_{2}-q_{2})^{2}+\cdots +(p_{i}-q_{i})^{2}+\cdots +(p_{n}-q_{n})^{2}}}.}$

### 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. [6] Formulas for computing distances between different types of objects include:

## Properties

The Euclidean distance is the prototypical example of the distance in a metric space, [9] and obeys all the defining properties of a metric space: [10]

• It is symmetric, meaning that for all points ${\displaystyle p}$ and ${\displaystyle q}$, ${\displaystyle d(p,q)=d(q,p)}$. 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. [10]
• 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. [10]
• It obeys the triangle inequality: for every three points ${\displaystyle p}$, ${\displaystyle q}$, and ${\displaystyle r}$, ${\displaystyle d(p,q)+d(q,r)\geq d(p,r)}$. Intuitively, traveling from ${\displaystyle p}$ to ${\displaystyle r}$ via ${\displaystyle q}$ cannot be any shorter than traveling directly from ${\displaystyle p}$ to ${\displaystyle r}$. [10]

Another property, Ptolemy's inequality, concerns the Euclidean distances among four points ${\displaystyle p}$, ${\displaystyle q}$, ${\displaystyle r}$, and ${\displaystyle s}$. It states that

${\displaystyle d(p,q)\cdot d(r,s)+d(q,r)\cdot d(p,s)\geq d(p,r)\cdot d(q,s).}$

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. [11] 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. [12]

## Squared Euclidean distance

A cone, the graph of Euclidean distance from the origin in the plane
A paraboloid, the graph of squared Euclidean distance from the origin

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 of the Euclidean distance, and is called the squared Euclidean distance. [13] As an equation, it can be expressed as a sum of squares:

${\displaystyle 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, 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. [14] 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. [15] In cluster analysis, squared distances can be used to strengthen the effect of longer distances. [13]

Squared Euclidean distance does not form a metric space, as it does not satisfy the triangle inequality. [16] However it is a smooth, strictly convex function 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, since it allows convex analysis to be used. Since squaring is a monotonic function 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. [17]

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. [18]

## 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. [19] 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. [20] It can be extended to infinite-dimensional vector spaces as the L2 norm or L2 distance. [21]

Other common distances on Euclidean spaces and low-dimensional vector spaces include: [22]

• Chebyshev distance, which measures distance assuming only the most significant dimension is relevant.
• Manhattan distance, which measures distance following only axis-aligned directions.
• Minkowski distance, 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 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 also known as "Vincent distance" for distance on a spheroid. [23]

## 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. [24] 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), [25] and have been hypothesized to develop in children earlier than the related concepts of speed and time. [26] 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. [27]

The Pythagorean theorem is also ancient, but it could only take its central role in the measurement of distances after the invention of Cartesian coordinates by René Descartes in 1637. The distance formula itself was first published in 1731 by Alexis Clairaut. [28] Because of this formula, Euclidean distance is also sometimes called Pythagorean distance. [29] 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), 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. [30] 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. [31]

## Related Research Articles

In classical mathematics, analytic geometry, also known as coordinate geometry or Cartesian geometry, is the study of geometry using a coordinate system. This contrasts with synthetic geometry.

A Cartesian coordinate system in a plane is a coordinate system that specifies each point uniquely by a pair of numerical coordinates, which are the signed distances to the point from two fixed perpendicular oriented lines, measured in the same unit of length. Each reference line is called a coordinate axis or just axis of the system, and the point where they meet is its origin, at ordered pair (0, 0). The coordinates can also be defined as the positions of the perpendicular projections of the point onto the two axes, expressed as signed distances from the origin.

Euclidean geometry is a mathematical system attributed to Alexandrian Greek mathematician Euclid, which he described in his textbook on geometry: the Elements. Euclid's method consists in assuming a small set of intuitively appealing axioms, and deducing many other propositions (theorems) from these. Although many of Euclid's results had been stated by earlier mathematicians, Euclid was the first to show how these propositions could fit into a comprehensive deductive and logical system. The Elements begins with plane geometry, still taught in secondary school as the first axiomatic system and the first examples of mathematical proofs. It goes on to the solid geometry of three dimensions. Much of the Elements states results of what are now called algebra and number theory, explained in geometrical language.

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, including the three-dimensional space and the Euclidean plane. It was introduced by the Ancient Greek mathematician Euclid of Alexandria, and the qualifier Euclidean is used to distinguish it from other spaces that were later discovered in physics and modern mathematics.

In Euclidean geometry, two objects are similar if they have the same shape, or one has the same shape as the mirror image of the other. More precisely, one can be obtained from the other by uniformly scaling, possibly with additional translation, rotation and reflection. This means that either object can be rescaled, repositioned, and reflected, so as to coincide precisely with the other object. If two objects are similar, each is congruent to the result of a particular uniform scaling of the other.

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 degenerate triangles, but some authors, especially those writing about elementary geometry, will exclude this possibility, thus leaving out the possibility of equality. If x, y, and z are the lengths of the sides of the triangle, with no side being greater than z, then the triangle inequality states that

In mathematics, a ball is the volume space bounded by a sphere; it is also called a solid sphere. It may be a closed ball or an open ball.

Elliptic geometry is an example of a geometry in which Euclid's parallel postulate does not hold. Instead, as in spherical geometry, there are no parallel lines since any two lines must intersect. However, unlike in spherical geometry, two lines are usually assumed to intersect at a single point. Because of this, the elliptic geometry described in this article is sometimes referred to as single elliptic geometry whereas spherical geometry is sometimes referred to as double elliptic geometry.

In mathematics, hyperbolic geometry is a non-Euclidean geometry. The parallel postulate of Euclidean geometry is replaced with:

In mathematics, a reflection is a mapping from a Euclidean space to itself that is an isometry with a hyperplane as a set of fixed points; this set is called the axis or plane of reflection. The image of a figure by a reflection is its mirror image in the axis or plane of reflection. For example the mirror image of the small Latin letter p for a reflection with respect to a vertical axis would look like q. Its image by reflection in a horizontal axis would look like b. A reflection is an involution: when applied twice in succession, every point returns to its original location, and every geometrical object is restored to its original state.

In mathematics, a hyperbolic space is a homogeneous space that has a constant negative curvature, where in this case the curvature is the sectional curvature. It is hyperbolic geometry in more than 2 dimensions, and is distinguished from Euclidean spaces with zero curvature that define the Euclidean geometry, and elliptic geometry that have a constant positive curvature.

A taxicab geometry is a form of geometry in which the usual distance function or 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 their Cartesian coordinates. The taxicab metric is also known as rectilinear distance, L1 distance, L1 distance or norm, snake distance, city block distance, Manhattan distance or Manhattan length, with corresponding variations in the name of the geometry. The latter names allude to the grid layout of most streets on the island of Manhattan, which causes the shortest path a car could take between two intersections in the borough to have length equal to the intersections' distance in taxicab geometry.

In mathematics, the magnitude or size of a mathematical object is a property which determines whether the object is larger or smaller than other objects of the same kind. More formally, an object's magnitude is the displayed result of an ordering —of the class of objects to which it belongs.

In mathematics, a norm is a function from a real or complex vector space to the nonnegative real numbers that behaves in certain ways like the distance from the origin: it commutes with scaling, obeys a form of the triangle inequality, and is zero only at the origin. In particular, the Euclidean distance of a vector from the origin is a norm, called the Euclidean norm, or 2-norm, which may also be defined as the square root of the inner product of a vector with itself.

In mathematics, a real coordinate space of dimension n, written Rn or , is a coordinate space over the real numbers. This means that it is the set of the n-tuples of real numbers. With component-wise addition and scalar multiplication, it is a real vector space.

Three-dimensional space is a geometric setting in which three values are required to determine the position of an element. This is the informal meaning of the term dimension.

Two-dimensional space is a geometric setting in which two values are required to determine the position of an element. The set 2 of pairs of real numbers with appropriate structure often serves as the canonical example of a two-dimensional Euclidean space. For a generalization of the concept, see dimension.

Geometry is, with arithmetic, one of the oldest branches of mathematics. It is concerned with properties of space that are related with distance, shape, size, and relative position of figures. A mathematician who works in the field of geometry is called a geometer.

In mathematics, the Pythagorean theorem, or Pythagoras's 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 is equal to the sum of the areas of the squares on the other two sides. This theorem can be written as an equation relating the lengths of the sides a, b and c, often called the Pythagorean equation:

In geometry, the Poincaré disk model, also called the conformal disk model, is a model of 2-dimensional hyperbolic geometry in which the points of the geometry are inside the unit disk, and the straight lines consist of all circular arcs contained within that disk that are orthogonal to the boundary of the disk, plus all diameters of the disk.

## References

1. Smith, Karl (2013), Precalculus: A Functional Approach to Graphing and Problem Solving, Jones & Bartlett Publishers, p. 8, ISBN   978-0-7637-5177-7
2. Cohen, David (2004), Precalculus: A Problems-Oriented Approach (6th ed.), Cengage Learning, p. 698, ISBN   978-0-534-40212-9
3. Aufmann, Richard N.; Barker, Vernon C.; Nation, Richard D. (2007), College Trigonometry (6th ed.), Cengage Learning, p. 17, ISBN   978-1-111-80864-8
4. Andreescu, Titu; Andrica, Dorin (2014), "3.1.1 The Distance Between Two Points", Complex Numbers from A to ... Z (2nd ed.), Birkhäuser, pp. 57–58, ISBN   978-0-8176-8415-0
5. Tabak, John (2014), Geometry: The Language of Space and Form, Facts on File math library, Infobase Publishing, p. 150, ISBN   978-0-8160-6876-0
6. Ó Searcóid, Mícheál (2006), "2.7 Distances from Sets to Sets", Metric Spaces, Springer Undergraduate Mathematics Series, Springer, pp. 29–30, ISBN   978-1-84628-627-8
7. Ballantine, J. P.; Jerbert, A. R. (April 1952), "Distance from a line, or plane, to a point", Classroom notes, American Mathematical Monthly , 59 (4): 242–243, doi:10.2307/2306514, JSTOR   2306514
8. 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
9. Ivanov, Oleg A. (2013), Easy as π?: An Introduction to Higher Mathematics, Springer, p. 140, ISBN   978-1-4612-0553-1
10. Strichartz, Robert S. (2000), The Way of Analysis, Jones & Bartlett Learning, p. 357, ISBN   978-0-7637-1497-0
11. Adam, John A. (2017), "Chapter 2. Introduction to the "Physics" of Rays", Rays, Waves, and Scattering: Topics in Classical Mathematical Physics, Princeton Series in Applied Mathematics, Princeton University Press, pp. 26–27, doi:10.1515/9781400885404-004, ISBN   978-1-4008-8540-4
12. Liberti, Leo; Lavor, Carlile (2017), Euclidean Distance Geometry: An Introduction, Springer Undergraduate Texts in Mathematics and Technology, Springer, p. xi, ISBN   978-3-319-60792-4
13. Spencer, Neil H. (2013), "5.4.5 Squared Euclidean Distances", Essentials of Multivariate Data Analysis, CRC Press, p. 95, ISBN   978-1-4665-8479-2
14. Randolph, Karen A.; Myers, Laura L. (2013), Basic Statistics in Multivariate Analysis, Pocket Guide to Social Work Research Methods, Oxford University Press, p. 116, ISBN   978-0-19-976404-4
15. Moler, Cleve and Donald Morrison (1983), "Replacing Square Roots by Pythagorean Sums" (PDF), IBM Journal of Research and Development, 27 (6): 577–581, CiteSeerX  , doi:10.1147/rd.276.0577
16. Mielke, Paul W.; Berry, Kenneth J. (2000), "Euclidean distance based permutation methods in atmospheric science", in Brown, Timothy J.; Mielke, Paul W. Jr. (eds.), Statistical Mining and Data Visualization in Atmospheric Sciences, Springer, pp. 7–27, doi:10.1007/978-1-4757-6581-6_2
17. Kaplan, Wilfred (2011), Maxima and Minima with Applications: Practical Optimization and Duality, Wiley Series in Discrete Mathematics and Optimization, 51, John Wiley & Sons, p. 61, ISBN   978-1-118-03104-9
18. Alfakih, Abdo Y. (2018), Euclidean Distance Matrices and Their Applications in Rigidity Theory, Springer, p. 51, ISBN   978-3-319-97846-8
19. Kopeikin, Sergei; Efroimsky, Michael; Kaplan, George (2011), Relativistic Celestial Mechanics of the Solar System, John Wiley & Sons, p. 106, ISBN   978-3-527-63457-6
20. Matoušek, Jiří (2002), Lectures on Discrete Geometry, Graduate Texts in Mathematics, Springer, p. 349, ISBN   978-0-387-95373-1
21. Ciarlet, Philippe G. (2013), Linear and Nonlinear Functional Analysis with Applications, Society for Industrial and Applied Mathematics, p. 173, ISBN   978-1-61197-258-0
22. Klamroth, Kathrin (2002), "Section 1.1: Norms and Metrics", Single-Facility Location Problems with Barriers, Springer Series in Operations Research, Springer, pp. 4–6, doi:10.1007/0-387-22707-5_1
23. Panigrahi, Narayan (2014), "12.2.4 Haversine Formula and 12.2.5 Vincenty's Formula", Computing in Geographic Information Systems, CRC Press, pp. 212–214, ISBN   978-1-4822-2314-9
24. Zhang, Jin (2007), Visualization for Information Retrieval, Springer, ISBN   978-3-540-75148-9
25. 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
26. Acredolo, Curt; Schmid, Jeannine (1981), "The understanding of relative speeds, distances, and durations of movement", Developmental Psychology , 17 (4): 490–493, doi:10.1037/0012-1649.17.4.490
27. Maor, Eli (2019), The Pythagorean Theorem: A 4,000-Year History, Princeton University Press, pp. 133–134, ISBN   978-0-691-19688-6
28. Rankin, William C.; Markley, Robert P.; Evans, Selby H. (March 1970), "Pythagorean distance and the judged similarity of schematic stimuli", Perception & Psychophysics , 7 (2): 103–107, doi:, S2CID   144797925
29. Milnor, John (1982), "Hyperbolic geometry: the first 150 years", Bulletin of the American Mathematical Society , 6 (1): 9–24, doi:, MR   0634431
30. Ratcliffe, John G. (2019), Foundations of Hyperbolic Manifolds, Graduate Texts in Mathematics, 149 (3rd ed.), Springer, p. 32, ISBN   978-3-030-31597-9