Difference between revisions of "Distance Between Two Points"
m (Lila moved page Distance Between Two Points in the Real Numbers to Distance Between Two Points) |
|||
Line 1: | Line 1: | ||
[[File:Euclidean distance 2d.svg|thumb|upright=1.35|Using the Pythagorean theorem to compute two-dimensional Euclidean distance]] | [[File:Euclidean distance 2d.svg|thumb|upright=1.35|Using the Pythagorean theorem to compute two-dimensional Euclidean distance]] | ||
− | In | + | 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 | + | 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. |
− | 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 | + | 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 == | == Distance formulas == | ||
=== One dimension === | === One dimension === | ||
− | The distance between any two points on the | + | The distance between any two points on the real line is the absolute value of the numerical difference of their coordinates. Thus if <math>p</math> and <math>q</math> are two points on the real line, then the distance between them is given by: |
<math display=block>d(p,q) = |p-q|.</math> | <math display=block>d(p,q) = |p-q|.</math> | ||
A more complicated formula, giving the same value, but generalizing more readily to higher dimensions, is:<ref name=smith /> | A more complicated formula, giving the same value, but generalizing more readily to higher dimensions, is:<ref name=smith /> | ||
<math display=block>d(p,q) = \sqrt{(p-q)^2}.</math> | <math display=block>d(p,q) = \sqrt{(p-q)^2}.</math> | ||
− | In this formula, | + | In this formula, squaring and then taking the square root leaves any positive number unchanged, but replaces any negative number by its absolute value.<ref name=smith /> |
=== Two dimensions === | === Two dimensions === | ||
− | In the | + | In the Euclidean plane, let point <math>p</math> have Cartesian coordinates <math>(p_1,p_2)</math> and let point <math>q</math> have coordinates <math>(q_1,q_2)</math>. Then the distance between <math>p</math> and <math>q</math> is given by:<ref name=cohen>{{citation|title=Precalculus: A Problems-Oriented Approach|first=David|last=Cohen|edition=6th|publisher=Cengage Learning|year=2004|isbn=978-0-534-40212-9|page=698|url=https://books.google.com/books?id=_6ukev29gmgC&pg=PA698}}</ref> |
<math display=block>d(p,q) = \sqrt{(q_1-p_1)^2 + (q_2-p_2)^2}.</math> | <math display=block>d(p,q) = \sqrt{(q_1-p_1)^2 + (q_2-p_2)^2}.</math> | ||
− | This can be seen by applying the | + | This can be seen by applying the Pythagorean theorem to a right triangle with horizontal and vertical sides, having the line segment from <math>p</math> to <math>q</math> 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 | + | It is also possible to compute the distance for points given by polar coordinates. If the polar coordinates of <math>p</math> are <math>(r,\theta)</math> and the polar coordinates of <math>q</math> are <math>(s,\psi)</math>, then their distance is<ref name=cohen /> given by the law of cosines: |
<math display=block>d(p,q)=\sqrt{r^2 + s^2 - 2rs\cos(\theta-\psi)}.</math> | <math display=block>d(p,q)=\sqrt{r^2 + s^2 - 2rs\cos(\theta-\psi)}.</math> | ||
− | When <math>p</math> and <math>q</math> are expressed as | + | When <math>p</math> and <math>q</math> are expressed as complex numbers in the complex plane, the same formula for one-dimensional points expressed as real numbers can be used: |
<math display=block>d(p,q)=|p-q|.</math> | <math display=block>d(p,q)=|p-q|.</math> | ||
Line 33: | Line 33: | ||
=== Objects other than points === | === 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 | + | 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. Formulas for computing distances between different types of objects include: |
− | *The | + | *The distance from a point to a line, in the Euclidean plane |
− | *The | + | *The distance from a point to a plane in three-dimensional Euclidean space |
− | *The | + | *The distance between two lines in three-dimensional Euclidean space |
== Properties == | == Properties == | ||
− | The Euclidean distance is the prototypical example of the distance in a | + | The Euclidean distance is the prototypical example of the distance in a metric space, and obeys all the defining properties of a metric space: |
− | *It is ''symmetric'', meaning that for all points <math>p</math> and <math>q</math>, <math>d(p,q)=d(q,p)</math>. 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 ''symmetric'', meaning that for all points <math>p</math> and <math>q</math>, <math>d(p,q)=d(q,p)</math>. 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 | + | *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 | + | *It obeys the triangle inequality: for every three points <math>p</math>, <math>q</math>, and <math>r</math>, <math>d(p,q)+d(q,r)\ge d(p,r)</math>. Intuitively, traveling from <math>p</math> to <math>r</math> via <math>q</math> cannot be any shorter than traveling directly from <math>p</math> to <math>r</math>. |
− | Another property, | + | Another property, Ptolemy's inequality, concerns the Euclidean distances among four points <math>p</math>, <math>q</math>, <math>r</math>, and <math>s</math>. It states that |
<math display=block>d(p,q)\cdot d(r,s)+d(q,r)\cdot d(p,s)\ge d(p,r)\cdot d(q,s).</math> | <math display=block>d(p,q)\cdot d(r,s)+d(q,r)\cdot d(p,s)\ge d(p,r)\cdot d(q,s).</math> | ||
− | For points in the plane, this can be rephrased as stating that for every | + | 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. 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. |
== Squared Euclidean distance == | == Squared Euclidean distance == | ||
{{multiple image | {{multiple image | ||
|image1=3d-function-5.svg | |image1=3d-function-5.svg | ||
− | |caption1=A | + | |caption1=A cone, the graph of Euclidean distance from the origin in the plane |
|image2=3d-function-2.svg | |image2=3d-function-2.svg | ||
− | |caption2=A | + | |caption2=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 | + | 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'''.<ref name=spencer /> As an equation, it can be expressed as a sum of squares: |
<math display=block>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.</math> | <math display=block>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.</math> | ||
− | Beyond its application to distance comparison, squared Euclidean distance is of central importance in | + | 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. 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. | + | 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 | + | 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 == | == Generalizations == | ||
− | In more advanced areas of mathematics, when viewing Euclidean space as a | + | 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. 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. | + | only norm with this property. It can be extended to infinite-dimensional vector spaces as the L<sup>2</sup> norm or L<sup>2</sup> distance. |
− | Other common distances on Euclidean spaces and low-dimensional vector spaces include: | + | Other common distances on Euclidean spaces and low-dimensional vector spaces include: |
− | * | + | *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 | + | 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. |
==Licensing== | ==Licensing== | ||
Content obtained and/or adapted from: | Content obtained and/or adapted from: | ||
* [https://en.wikipedia.org/wiki/Euclidean_distance Euclidean distance, Wikipedia] under a CC BY-SA license | * [https://en.wikipedia.org/wiki/Euclidean_distance Euclidean distance, Wikipedia] under a CC BY-SA license |
Revision as of 13:26, 26 October 2021
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.
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.
Contents
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 and are two points on the real line, then the distance between them is given by:
Two dimensions
In the Euclidean plane, let point have Cartesian coordinates and let point have coordinates . Then the distance between and is given by:[2]
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 complex numbers in the complex plane, the same formula for one-dimensional points expressed as real numbers can be used:
Higher dimensions
In three dimensions, for points given by their Cartesian coordinates, the distance is
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. Formulas for computing distances between different types of objects include:
- The distance from a point to a line, in the Euclidean plane
- The distance from a point to a plane in three-dimensional Euclidean space
- The distance between two lines in three-dimensional Euclidean space
Properties
The Euclidean distance is the prototypical example of the distance in a metric space, and obeys all the defining properties of a metric space:
- 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.
- 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 , , and , . Intuitively, traveling from to via cannot be any shorter than traveling directly from to .
Another property, Ptolemy's inequality, concerns the Euclidean distances among four points , , , and . It states that
Squared Euclidean distance
Script error: No such module "Multiple_image". 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.[4] As an equation, it 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. 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.
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. 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. 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, 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.
Licensing
Content obtained and/or adapted from:
- Euclidean distance, Wikipedia under a CC BY-SA license
<ref>
tag;
no text was provided for refs named smith
<ref>
tag;
no text was provided for refs named spencer