StatGardenREF. DESK
Calculators/Maths/Manhattan (taxicab) distance
Maths

Manhattan (taxicab) distance calculator

Grid-style distance between two points, moving only along axes.

Published 8 August 2026 · Updated 24 September 2026

What this calculator does

Manhattan distance, also called taxicab or L1 distance, measures how far apart two points are when movement is restricted to the axes. Rather than cutting across at an angle, you add the distance travelled along x, then along y, then along z if the problem is three-dimensional. The name comes from the street grid: a taxi cannot drive through buildings, so it covers the sum of the blocks instead of the diagonal.

It is never shorter than the straight-line distance, and it can be up to √2 times longer in two dimensions, or √3 times in three. That gap is the entire point of the measure. Where a grid, a circuit board or a warehouse aisle forces axis-aligned movement, the Manhattan figure is the distance actually travelled and the Euclidean one is a lower bound nothing can reach.

The formula

Formulad = |x₂−x₁| + |y₂−y₁| + |z₂−z₁| (z optional, for 3D)

Each coordinate pair is subtracted and the absolute value of the difference is taken, so direction does not matter, and the three results are added together. Leaving both z values at zero reduces the calculation to the two-dimensional case. The straight-line distance shown alongside is the ordinary Pythagorean one, the square root of the summed squared differences, included so the two can be compared directly.

TermMeaning
Manhattan distanceThe sum of the absolute differences along each axis, written |x₂−x₁| + |y₂−y₁| + |z₂−z₁|.
Euclidean distanceThe ordinary straight-line distance, the shortest path if movement is unrestricted.
L1 normAnother name for the same quantity, from the general family of distance measures that sum absolute differences raised to a power.
Component differenceThe gap along one axis on its own, before the components are added.

The inputs explained

FieldWhat to enter
x₁The x coordinate of the first point.
y₁The y coordinate of the first point.
z₁ (optional)The z coordinate of the first point. Leave it at zero for a two-dimensional problem.
x₂The x coordinate of the second point.
y₂The y coordinate of the second point.
z₂ (optional)The z coordinate of the second point. Leave it at zero for a two-dimensional problem.

When to use it

Routing on a grid

Delivery routes through a gridded street layout, robot movement across a warehouse floor and trace routing on a circuit board all move along axes rather than diagonally, which makes Manhattan distance the honest measure of how far something has to travel.

Choosing a distance metric for clustering or nearest-neighbour work

Manhattan distance is a common alternative to Euclidean distance in k-nearest-neighbour and clustering methods. It weights a single large difference less heavily, because the components are added rather than squared, which can make it steadier on data with outliers.

Getting a quick upper bound by hand

The Manhattan figure needs only subtraction and addition, with no squaring or square root, so it is the easier of the two to work out mentally and it always bounds the straight-line distance from above.

Worked examples

Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.

How far does Manhattan distance drift from straight-line distance?

One point fixed at the origin, the other at x = 10 with the y coordinate increasing.

From the origin to (10, y)
y coordinate of second pointManhattan distanceStraight-line (Euclidean) distance for comparisonRatio to Euclidean distance
010.00010.0001.000
212.00010.1981.177
414.00010.7701.300
616.00011.6621.372
818.00012.8061.406
1020.00014.1421.414
The first row is a straight run along a single axis, where both measures agree exactly at 10 and the ratio is 1. As the second component grows, the Manhattan figure climbs in even steps to 20 while the straight-line distance only reaches 14.142, and the ratio tops out at 1.414. That is √2, the largest gap possible in two dimensions, reached when the two components are equal.

Questions

Why is it called Manhattan distance?

Because of the street grid it describes. In a city laid out in regular blocks, a taxi cannot take the diagonal, so the distance it drives is the number of blocks east or west plus the number north or south. Taxicab distance and city block distance are the same measure under different names.

Can Manhattan distance ever be shorter than straight-line distance?

No. The straight line is the shortest path between two points, so Manhattan distance is always equal to it or longer. The two are equal only when the points differ along a single axis, since then there is no diagonal to cut across.

How do I use this for a two-dimensional problem?

Leave both z values at zero. The z component then contributes nothing to either distance and the result is the ordinary two-dimensional Manhattan distance.

When is Manhattan distance the better choice than Euclidean?

When movement is genuinely constrained to the axes, and also as a matter of taste in high-dimensional data work, where summing absolute differences rather than squaring them keeps any one large component from dominating the total.

For the straight-line distance and midpoint between two points in three dimensions, see the 3D distance and midpoint calculator. For the length of a single vector, see the vector magnitude calculator.