🧮
🧮 Math & statistics

Manhattan Distance Calculator (taxicab distance in 2-D and 3-D)

Results update as you type.

Your numbers

Understanding the Manhattan distance calculator — concept and principle

This calculator finds the Manhattan (taxicab or city-block) distance between two points in 2-D or 3-D, the distance travelled when you may only move along grid lines. It compares it with the straight-line distance and counts the shortest grid routes. Use it for city navigation puzzles, grid games, warehouse layouts and data science.

Grid distance A → BGrid distance A → BAB68Straight line√(36 + 64) = 10Ratio1.4Shortest routesC(14, 6) = 3,003Manhattan6 + 8 + 0 = 14
Every shortest grid route (red or gold) is 14 blocks; only the straight line is 10.

How it is calculated

Manhattan distance = |x₁ − x₂| + |y₁ − y₂| (+ |z₁ − z₂| in 3-D)

Straight-line (Euclidean) distance = √(Δx² + Δy² + Δz²)

Shortest grid routes in 2-D with whole-number steps = C(|Δx| + |Δy|, |Δx|)

The principle

On a street grid you cannot cut diagonally across blocks, so you must cover the full east–west difference and the full north–south difference, in any order. That is why the distance is the sum of the absolute differences. Every shortest route uses the same number of east steps and north steps; only their order changes, so the number of routes is the number of ways to choose which steps go east. The straight line is never longer, and the two distances are equal only when the points differ in just one coordinate.

Worked example

Default inputs: A = (1, 2, 0), B = (7, 10, 0).

  1. |Δx| = |1 − 7| = 6; |Δy| = |2 − 10| = 8; |Δz| = 0.
  2. Manhattan distance = 6 + 8 + 0 = 14.
  3. Straight-line distance = √(36 + 64) = 10.
  4. Ratio Manhattan ÷ straight-line = 1.4.
  5. Shortest grid routes = C(14, 6) = 3,003.
How Manhattan distance changes with Point B: y₂How Manhattan distance changes with Poin…5101520252.557.51012.51520Example: 14Point B: y₂
Each point is the calculator re-run with only “Point B: y₂” changed; the gold point is the default example. Change the inputs above and this chart follows your numbers.
Point B: y₂Manhattan distance
2.56.5
59
7.511.5
1014
12.516.5
1519
2024

How to read the result

A ratio of 1.4 means travelling on the grid is 40 % longer than flying straight here. The ratio is largest, √2 ≈ 1.41 in 2-D, when the move is diagonal with equal steps. In data science the Manhattan distance is less influenced by a single large difference than the Euclidean distance.

Common mistakes

Keep in mind: Real streets are not perfect grids; one-way streets and blocked routes change actual travel distance.

Frequently asked questions

What is the Manhattan distance between (1, 2) and (7, 10)?

14.

Why is it called taxicab distance?

It is how far a taxi drives on a rectangular street grid.

How many shortest routes are there?

C(Δx + Δy, Δx); here C(14, 6) = 3,003.

Sources: E. W. Weisstein, "Taxicab Metric", Wolfram MathWorld

Checked 9 Nov 2026. Weisstein, E. W., “Taxicab Metric”, Wolfram MathWorld (g((x₁, y₁), (x₂, y₂)) = |x₁ − x₂| + |y₁ − y₂|; also called rectilinear, city-block or Manhattan distance). The 3-D term and the route count C(Δx + Δy, Δx) are standard extensions.

🧮 All math & statistics tools →🌍 Calculators by country →