Distance Between Two Points
The formula
It returns the straight-line distance between two points on a coordinate plane.
Where it comes from
This is the Pythagorean theorem wearing different clothes. Draw a right triangle between your two points: the horizontal leg is the difference in x, the vertical leg is the difference in y, and the distance you want is the hypotenuse.
Since a² + b² = c², the hypotenuse is √(a² + b²) — which is exactly the distance formula with the legs written as coordinate differences.
Worked example
Distance from (1, 2) to (4, 6):
- Horizontal difference: 4 − 1 = 3
- Vertical difference: 6 − 2 = 4
- d = √(3² + 4²) = √(9 + 16) = √25 = 5
That's the familiar 3-4-5 triangle. Most real coordinate pairs produce an irrational result instead — the distance from (0,0) to (2,3) is √13 ≈ 3.606.
Negative coordinates
Subtraction handles them automatically, and squaring removes any sign issue. From (−3, 5) to (2, −1):
- 2 − (−3) = 5
- −1 − 5 = −6
- d = √(25 + 36) = √61 ≈ 7.81
Because the differences are squared, the order of the points doesn't matter. Distance from A to B equals distance from B to A.
Three dimensions
The pattern extends to any number of dimensions: square each difference, add them, take the root.
Where it's used
Geometry and coordinate proofs, physics displacement problems, computer graphics and collision detection, navigation on a flat map, and clustering algorithms in data science — where it's known as Euclidean distance.
One limit worth knowing: on the Earth's surface this underestimates real distance over long spans, because the planet is curved. Great-circle formulas handle that case.