The distance formula is Pythagoras applied to a coordinate grid. The horizontal separation and the vertical separation form the two legs of a right triangle, and the straight-line distance between the points is the hypotenuse. The order of the points makes no difference, because both differences are squared.
Manhattan distance, the sum of the two separations without squaring, is the alternative worth knowing. It is what you actually travel on a street grid, and it is always at least as large as the straight-line distance — up to about 41% larger when the two points sit on a perfect diagonal. Routing software uses one or the other depending on whether movement is free or constrained to axes.
The formula
x₁, y₁- Coordinates of the first point
x₂, y₂- Coordinates of the second point
Δx, Δy- The horizontal and vertical separations
How it works, step by step
- Enter the coordinates of the first point.
- Enter the coordinates of the second point.
- The gauge shows the straight-line distance.
- The separations, the Manhattan distance and the bearing appear below.
Worked examples
From (2, 3) to (10, 9)
The separations are 8 and 6, so the distance is the root of 64 + 36 = 10. The Manhattan distance is 14, which is 40% further.
A perfect diagonal
From the origin to (10, 10) the straight-line distance is 14.1421 but the Manhattan distance is 20. That ratio, 1.4142, is root two and is the largest the gap can ever be.
How to read your score
Frequently asked questions
Does it matter which point I enter first?
No. Reversing the points flips the sign of both separations, but squaring removes the sign entirely. Only the reported bearing changes, by 180 degrees.
What is Manhattan distance?
The distance travelled when you can only move along the axes, like walking a street grid. It is the sum of the absolute separations and never smaller than the straight-line distance.
How do I extend this to three dimensions?
Add the square of the z separation before taking the root. The structure of the formula is identical.
Can I use this for latitude and longitude?
Only over very short distances. The Earth is curved and a degree of longitude shrinks towards the poles, so proper geographic work needs the haversine formula instead.
Distances from the origin
| Point | Straight line | Manhattan | Ratio | Bearing |
|---|---|---|---|---|
| (3, 4) | 5.0000 | 7 | 1.4000 | 53.13 deg |
| (5, 0) | 5.0000 | 5 | 1.0000 | 0.00 deg |
| (5, 5) | 7.0711 | 10 | 1.4142 | 45.00 deg |
| (8, 6) | 10.0000 | 14 | 1.4000 | 36.87 deg |
| (10, 2) | 10.1980 | 12 | 1.1767 | 11.31 deg |
| (12, 5) | 13.0000 | 17 | 1.3077 | 22.62 deg |
| (1, 9) | 9.0554 | 10 | 1.1043 | 83.66 deg |
The ratio column peaks at root two for a perfect diagonal and falls to one on an axis.