Manhattan Distance Calculator

Calculate the taxicab distance between two points in N-dimensional space

Enter Coordinates

First Point (A)

Second Point (B)

Results

0.000000
Manhattan Distance
(Taxicab / City Block Distance)
0.000000
Euclidean Distance
(Straight line distance)

Points

Point A: (0, 0)
Point B: (0, 0)

Step-by-Step Calculation

Manhattan Distance Formula:
d = |x₁ - x₂| + |y₁ - y₂|
Substituting values:
d = |0 - 0| + |0 - 0|
Calculating absolute differences:
|0 - 0| = 0
|0 - 0| = 0
Final calculation:
d = 0 + 0 = 0

Example: Walking in Manhattan

Scenario

You live at the corner of 2nd Avenue and 9th Street: A(2, 9)
The grocery store is at 3rd Avenue and 5th Street: B(3, 5)

Calculation

Manhattan Distance: d = |2 - 3| + |9 - 5| = 1 + 4 = 5 blocks

Euclidean Distance: d = √[(2-3)² + (9-5)²] = √[1 + 16] = √17 ≈ 4.12 blocks

Result: You need to walk 5 city blocks, not 4.12 blocks in a straight line

Distance Comparison

M

Manhattan

Sum of absolute differences

|a₁-b₁| + |a₂-b₂| + ...

E

Euclidean

Straight line distance

√[(a₁-b₁)² + (a₂-b₂)² + ...]

Note: Manhattan distance is always ≥ Euclidean distance

Applications

🏢

Urban Planning

City block navigation, taxi routing

♟️

Chess

Rook movement distance calculation

🧬

Biology

Gene splicing, molecular distances

🎮

Gaming

Snake game pathfinding

🤖

Machine Learning

Feature similarity, clustering

Tips

Also called taxicab, city block, or snake distance

Useful when movement is restricted to grid lines

Always greater than or equal to Euclidean distance

Works in any number of dimensions

Understanding Manhattan Distance

What is Manhattan Distance?

The Manhattan distance, also known as taxicab distance or city block distance, is a metric that measures the distance between two points by summing the absolute differences of their coordinates. Unlike Euclidean distance, which measures the straight-line distance, Manhattan distance represents the distance you would travel along a grid-like path.

Mathematical Formula

For two N-dimensional points a⃗ = [a₁, a₂, ..., aₙ] and b⃗ = [b₁, b₂, ..., bₙ]:

d = |a₁ - b₁| + |a₂ - b₂| + ... + |aₙ - bₙ|

Why "Manhattan"?

The name comes from the grid-like street layout of Manhattan, New York City. When walking from one point to another in Manhattan, you can't walk diagonally through buildings - you must follow the streets and avenues, which form a grid pattern. The total distance walked equals the Manhattan distance.

Practical Applications

Urban Navigation

GPS routing in cities with grid layouts, taxi fare calculations

Game Development

Pathfinding algorithms, movement in grid-based games

Data Science

Feature similarity, clustering algorithms, recommendation systems

Computer Vision

Image processing, pixel distance calculations

Key Properties

  • Always non-negative (d ≥ 0)
  • Symmetric: d(A,B) = d(B,A)
  • Satisfies triangle inequality
  • d(A,B) = 0 if and only if A = B