Euclidean distance
conventional distance in mathematics and physics
≈ 7 min read
Euclidean distance. encyclopegia.org, snapshot euclidean-distance-097431-dec7d80bea0ef85b. /a/euclidean-distance
Names in other languages
- Portuguêsdistância euclidiana
- EnglishEuclidean distance
- РусскийЕвклидова метрика
- eoEŭklida distanco
- 한국어유클리드 거리
- 简体中文欧几里得度量
- 繁體中文歐幾里得度量
- 中文歐幾里得度量
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
In mathematics, the Euclidean distance between two points in a Euclidean space is the length of the line segment between them. It can be calculated from the Cartesian coordinates of the points using the Pythagorean theorem, and therefore is occasionally called the Pythagorean distance. These names come from the ancient Greek mathematicians Euclid and Pythagoras.
In the Greek deductive geometry exemplified by Euclid's Elements, distances were not represented as numbers but line segments of the same length, which were considered "equal". The notion of distance is inherent in the compass tool used to draw a circle, whose points all have the same distance from a common center point.
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 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. 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{(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. d(p,q) = \sqrt{(p_1-q_1)^2 + (p_2-q_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 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.
In terms of the Pythagorean addition operation \oplus , available in many software libraries as hypot , the same formula can be expressed as: d(p,q) = (p_1-q_1) \oplus (p_2-q_2) = \mathsf{hypot}(p_1-q_1,p_2-q_2). It is also possible to compute the distance for points given by polar coordinates.
If the polar coordinates of p are (r,\theta) and the polar coordinates of q are (s,\psi) , then their distance is given by the law of cosines: d(p,q)=\sqrt{r^2 + s^2 - 2rs\cos(\theta-\psi)}. When p and q are expressed as complex numbers in the complex plane, the same formula for one-dimensional points expressed as real numbers can be used, although here the absolute value sign indicates the complex norm: d(p,q)=|p-q|. 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 n -dimensional Euclidean space, the distance is d(p,q) = \sqrt{(p_1- q_1)^2 + (p_2 - q_2)^2+\cdots+(p_n - q_n)^2}. The Euclidean distance may also be expressed more compactly in terms of the Euclidean norm of the Euclidean vector difference: d(p,q) = \| p - q \|.
It is symmetric, meaning that for all points p and q , 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. 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.
It obeys the triangle inequality: for every three points p , q , and r , d(p,q)+d(q,r)\ge d(p,r) . 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, 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.
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.
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. d^2(p,q) = (p_1 - q_1)^2 + (p_2 - q_2)^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, and as the simplest form of divergence to compare probability distributions.
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, 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 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. 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.
Text derived from https://en.wikipedia.org/w/index.php?oldid=1376234643 under CC BY-SA 4.0; modifications have been made.