On a grid of streets you cannot cut across the blocks, so the distance to travel is longer than the straight line. This Manhattan distance calculator takes the coordinates of two points and gives the Manhattan distance, the Euclidean distance, the Chebyshev distance, the Minkowski distance of order p and the ratio between the grid path and the straight line.
How the calculation works
- Manhattan distance = |x₂ − x₁| + |y₂ − y₁| + |z₂ − z₁|. It is the length of a path that moves along the axes only, like a taxi on a grid of streets.
- Euclidean distance = √(Δx² + Δy² + Δz²), the straight line between the two points.
- Chebyshev distance = the largest of |Δx|, |Δy| and |Δz|, the number of moves of a chess king when each move can change every coordinate by one.
- Minkowski distance of order p = (|Δx|^p + |Δy|^p + |Δz|^p)^(1/p). It is the Manhattan distance for p = 1, the Euclidean distance for p = 2 and approaches the Chebyshev distance as p grows.
Example
Take the points (1, 2, 3) and (4, 6, 15). The differences are 3, 4 and 12. The Manhattan distance is 3 + 4 + 12 = 19. The Euclidean distance is √(9 + 16 + 144) = √169 = 13, and the Chebyshev distance is 12. The Minkowski distance of order 3 is (27 + 64 + 1,728)^(1/3), about 12.2. The grid path is 19 ÷ 13 = 1.46 times longer than the straight line.
Why it matters
Data scientists compare vectors with the Manhattan distance, game developers use it to guess how far a unit must walk on a tile map, and planners use it to estimate a trip in a city laid out in blocks. Seeing it beside the Euclidean and Chebyshev distances shows how the choice of metric changes which points count as close.
Good to know
The calculator works for three coordinates and also for two when the z values are equal. It treats the axes as having the same scale, so mixed units, such as meters and seconds, should be rescaled first. The Manhattan distance depends on the orientation of the axes, unlike the Euclidean distance, so rotating a grid changes the result. Real streets are not a perfect grid, and a real route will be longer.
Related tools
The distance formula calculator gives the straight line between two points and the point to line distance calculator finds the shortest distance to a line.