The distance between two points in the coordinate plane comes from the Pythagorean theorem1. Here we find the distance between and .
Going from to moves across and up. Taking these horizontal and vertical differences as the two legs of a right triangle, the segment joining and is its hypotenuse.
The familiar right triangle with sides in the ratio has appeared.
Because the differences are squared, it does not matter if is negative: naming the points in either order gives the same distance.
| Situation | Formula |
|---|---|
| General pair of points | |
| Distance from the origin | |
| On the number line |
The distance from the origin is what the absolute value on the number line becomes in the plane.
The same two points also give the midpoint of the segment, whose coordinates are the averages of the values and of the values.
A circle is the set of points at distance from a center , so , and squaring gives the familiar equation.
The equation of a circle is nothing but the distance formula rewritten.
Identifying the shape of a triangle from three points also begins here, by computing its three side lengths.
| Condition on the sides | The triangle is |
|---|---|
| two sides equal | isosceles |
| for the longest side | right-angled |
| all three sides equal | equilateral |
The distance is only when the two points coincide; otherwise it is always positive.
In three dimensions you add the square of the difference in . This is the Euclidean distance2, and it remains the basic tool in applications such as nearest-neighbor search, where the closest data point is the one to find.
The large dots on the graph are and , and the length of the segment joining them is the distance we found.