Manhattan Distance Calculator

Calculate the taxicab (Manhattan) distance between two points, with Euclidean distance comparison.

Enter Coordinates

Point A
Point B

Result

Manhattan Distance
12
units
Point A (x1, y1) (1, 2)
Point B (x2, y2) (7, 8)
|x2 - x1| 6
|y2 - y1| 6
Manhattan Distance 12
Euclidean Distance -
Chebyshev Distance -

Step-by-Step Solution

d = |x2 - x1| + |y2 - y1|

Understanding Manhattan Distance

Manhattan distance, also known as taxicab distance, city block distance, or L1 norm, measures the distance between two points in a grid-based path. Unlike Euclidean distance (the straight-line "as the crow flies" distance), Manhattan distance measures the total horizontal and vertical distance you would travel along grid lines, much like navigating city blocks in Manhattan, New York City.

The Formula

For two points P1 = (x1, y1) and P2 = (x2, y2) in 2D space:

dManhattan = |x2 - x1| + |y2 - y1|

In n-dimensional space, this generalizes to the sum of absolute differences across all dimensions:

d = |p1 - q1| + |p2 - q2| + ... + |pn - qn|

Distance Metrics Compared

Manhattan (L1)

Sum of absolute differences. Follows grid paths. Always greater than or equal to Euclidean distance.

d = |dx| + |dy|

Euclidean (L2)

Straight-line distance. The shortest possible path between two points in space.

d = sqrt(dx^2 + dy^2)

Chebyshev (L-infinity)

Maximum of absolute differences. Allows diagonal movement at no extra cost, like a king in chess.

d = max(|dx|, |dy|)

Minkowski (Lp)

Generalized distance metric. Manhattan (p=1) and Euclidean (p=2) are special cases.

d = (|dx|^p + |dy|^p)^(1/p)

Applications

  • Urban planning: Estimating travel distances in grid-based cities.
  • Machine learning: Used in k-NN classification, clustering (k-medians), and feature comparison.
  • Robotics: Path planning for robots that can only move in cardinal directions.
  • Computer vision: Image comparison and template matching.
  • Logistics: Warehouse routing and delivery distance estimation.
  • Board games: Movement calculations on grid-based game boards.

When to Use Manhattan Distance

Manhattan distance is preferred when movement is restricted to orthogonal directions (horizontal and vertical only) or when you want a distance metric that is less sensitive to outliers than Euclidean distance. In high-dimensional spaces, Manhattan distance often performs better than Euclidean distance for machine learning tasks, as it is less affected by the "curse of dimensionality."