Manhattan Distance Calculator
Test cases replayed : 2 of 2 match · Methodology · No outside source listed
Enter two points. Leave z at 0 for points in the plane.
Result
Manhattan distance |Δx| + |Δy| + |Δz|
Euclidean (straight-line) distance
- Chebyshev distance (largest single difference)
Estimate for planning only, not tax, legal, financial or medical advice. This calculator uses the method explained on this page.
This browser did not allow copying. The sentence is in the box below, already selected: copy it with your keyboard or the menu.
How to use this calculator
Fill in the fields in this order; each step takes you to its field.
- Point 1: x: enter a number.
- Point 1: y: enter a number.
- Point 1: z (0 for 2D): enter a number.
- Point 2: x: enter a number.
- Point 2: y: enter a number.
- Point 2: z (0 for 2D): enter a number.
- Read the result: Manhattan distance |Δx| + |Δy| + |Δz|; the panel also shows Euclidean (straight-line) distance and Chebyshev distance (largest single difference).
How this calculator works
The Manhattan distance, also called taxicab or L1 distance, adds the absolute differences of the coordinates: d = |x₂ − x₁| + |y₂ − y₁| + |z₂ − z₁|. It is the length of a path that moves only along the grid, like a car on a city street plan.
For comparison, the Euclidean distance is the straight line √(Δx² + Δy² + Δz²) and the Chebyshev distance is the largest single difference. Manhattan ≥ Euclidean ≥ Chebyshev always holds.
The formula
| Symbol | Meaning |
|---|---|
| Point 1: x | |
| Point 1: y | |
| Point 1: z (0 for 2D) | |
| Point 2: x | |
| Point 2: y | |
| Point 2: z (0 for 2D) | |
| Manhattan distance |Δx| + |Δy| + |Δz| |
Worked example
| Point 1: x | 1 |
|---|---|
| Point 1: y | 2 |
| Point 1: z (0 for 2D) | 0 |
| Point 2: x | 4 |
| Point 2: y | 6 |
| Point 2: z (0 for 2D) | 0 |
| Euclidean (straight-line) distance | 5 |
|---|---|
| Chebyshev distance (largest single difference) | 4 |
Manhattan distance |Δx| + |Δy| + |Δz| 7
Each step uses the unrounded value of the step before it; figures on this page are rounded for display.
Frequently asked questions
What is the Manhattan distance from (1, 2) to (4, 6)?
|4 − 1| + |6 − 2| = 3 + 4 = 7, while the straight-line distance is 5.
Where is Manhattan distance used?
In grid path-finding, in machine learning (L1 norm, k-nearest neighbors) and for travel along city blocks.