Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Euclidean distance
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== 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, their [[absolute difference]]. Thus if <math>p</math> and <math>q</math> are two points on the real line, then the distance between them is given by:<ref name=smith>{{citation|title=Precalculus: A Functional Approach to Graphing and Problem Solving|first=Karl|last=Smith|publisher=Jones & Bartlett Publishers|year=2013|isbn=978-0-7637-5177-7|page=8|url=https://books.google.com/books?id=ZUJbVQN37bIC&pg=PA8}}</ref> <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 /> <math display=block>d(p,q) = \sqrt{(p-q)^2}.</math> In this formula, [[square (algebra)|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 === 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{(p_1-q_1)^2 + (p_2-q_2)^2}.</math> 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.<ref>{{citation|title=College Trigonometry|first1=Richard N.|last1=Aufmann|first2=Vernon C.|last2=Barker|first3=Richard D.|last3=Nation|edition=6th|publisher=Cengage Learning|year=2007|isbn=978-1-111-80864-8|page=17|url=https://books.google.com/books?id=kZ8HAAAAQBAJ&pg=PA17}}</ref> In terms of the [[Pythagorean addition]] operation <math>\oplus</math>, available in many [[software library|software libraries]] as <code>hypot</code>, the same formula can be expressed as:<ref>{{citation|title=Java Script Notes for Professionals|first=Rohit|last=Manglik|publisher=EduGorilla|year=2024|isbn=9789367840320|contribution=Section 14.22: Math.hypot|page=144|contribution-url=https://books.google.com/books?id=jwU6EQAAQBAJ&pg=PA144}}</ref> <math display=block>d(p,q) = (p_1-q_1) \oplus (p_2-q_2) = \mathsf{hypot}(p_1-q_1,p_2-q_2).</math> It is also possible to compute the distance for points given by [[Polar coordinate system|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> When <math>p</math> and <math>q</math> are expressed as [[complex number]]s 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]]:<ref>{{citation|title=Complex Numbers from A to ... Z|first1=Titu|last1=Andreescu|first2=Dorin|last2=Andrica|publisher=Birkhäuser|year=2014|edition=2nd|isbn=978-0-8176-8415-0|contribution=3.1.1 The Distance Between Two Points|pages=57–58}}</ref> <math display=block>d(p,q)=|p-q|.</math> === Higher dimensions === [[File:Euclidean distance 3d 2 cropped.png|thumb|upright=1.2|Deriving the <math>n</math>-dimensional Euclidean distance formula by repeatedly applying the Pythagorean theorem]] In three dimensions, for points given by their Cartesian coordinates, the distance is <math display=block>d(p,q)=\sqrt{(p_1-q_1)^2 + (p_2-q_2)^2 + (p_3-q_3)^2}.</math> In general, for points given by Cartesian coordinates in <math>n</math>-dimensional Euclidean space, the distance is<ref>{{citation|title=Geometry: The Language of Space and Form|series=Facts on File math library|first=John|last=Tabak|publisher=Infobase Publishing|year=2014|isbn=978-0-8160-6876-0|page=150|url=https://books.google.com/books?id=r0HuPiexnYwC&pg=PA150}}</ref> <math display=block>d(p,q) = \sqrt{(p_1- q_1)^2 + (p_2 - q_2)^2+\cdots+(p_n - q_n)^2}.</math> The Euclidean distance may also be expressed more compactly in terms of the [[Euclidean norm]] of the [[Euclidean vector]] difference: <math display=block>d(p,q) = \| p - q \|.</math> === 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.<ref>{{citation|title=Metric Spaces|series=Springer Undergraduate Mathematics Series|first=Mícheál|last=Ó Searcóid|publisher=Springer|year=2006|isbn=978-1-84628-627-8|contribution=2.7 Distances from Sets to Sets|pages=29–30|url=https://books.google.com/books?id=aP37I4QWFRcC&pg=PA29}}</ref> Formulas for computing distances between different types of objects include: *The [[distance from a point to a line]], in the Euclidean plane<ref name=baljer>{{citation|last1=Ballantine|first1=J. P.|last2=Jerbert|first2=A. R.|date=April 1952|department=Classroom notes|doi=10.2307/2306514|issue=4|journal=[[American Mathematical Monthly]]|jstor=2306514|pages=242–243|title=Distance from a line, or plane, to a point|volume=59}}</ref> *The [[distance from a point to a plane]] in three-dimensional Euclidean space<ref name=baljer /> *The [[Skew lines#Distance|distance between two lines]] in three-dimensional Euclidean space<ref>{{citation|last=Bell|first=Robert J. T.|author-link=Robert J. T. Bell|edition=2nd|contribution=49. The shortest distance between two lines|contribution-url=https://archive.org/details/elementarytreati00bell/page/56/mode/2up|pages=57–61|publisher=Macmillan|title=An Elementary Treatise on Coordinate Geometry of Three Dimensions|year=1914}}</ref> 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.<ref>{{citation | last = Maekawa | first = Takashi | date = March 1999 | doi = 10.1016/s0010-4485(99)00013-5 | issue = 3 | journal = Computer-Aided Design | pages = 165–173 | title = An overview of offset curves and surfaces | volume = 31}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)