Connect via MCP →

Enter Calculation

Formula

Advertisement

Results

Manhattan Distance
7
|x₂−x₁| + |y₂−y₁|
Horizontal distance |x₂−x₁| 3
Vertical distance |y₂−y₁| 4

What Is Manhattan Distance?

The Manhattan distance — also called the taxicab distance, city-block distance, or L1 distance — measures how far apart two points are when you can only travel along horizontal and vertical paths, like a taxi navigating the grid streets of Manhattan. Unlike the straight-line Euclidean distance, it adds up the horizontal and vertical movements separately, so you can never cut diagonally across a block.

Grid showing Manhattan path versus straight-line path between two points
Manhattan distance follows grid lines (red), unlike the straight diagonal (dashed).

How to Use This Calculator

Enter the coordinates of your first point as X₁ and Y₁, and your second point as X₂ and Y₂. The calculator instantly returns the total Manhattan distance along with the horizontal and vertical components so you can see exactly how the result is built.

The Formula Explained

The Manhattan distance is defined as $$d = \left| \text{x}_2 - \text{x}_1 \right| + \left| \text{y}_2 - \text{y}_1 \right|$$. The vertical bars denote absolute value, which discards the sign so direction doesn't matter — moving left or right both count as positive horizontal travel. The two absolute differences are simply added together.

Advertisement
Right-triangle layout showing horizontal and vertical legs between two points
The formula sums the horizontal and vertical leg lengths between the two points.

Worked Example

Suppose point 1 is (1, 2) and point 2 is (4, 6). The horizontal difference is \( \left| 4 - 1 \right| = 3 \) and the vertical difference is \( \left| 6 - 2 \right| = 4 \). Adding them gives $$d = 3 + 4 = 7$$ Note the Euclidean distance for the same points would be 5, showing how the grid constraint makes the taxicab path longer.

FAQ

How is Manhattan distance different from Euclidean distance? Euclidean distance is the straight-line "as the crow flies" path; Manhattan distance only allows axis-aligned moves, so it is always greater than or equal to the Euclidean distance.

Can coordinates be negative or decimals? Yes. The formula uses absolute values, so negative and fractional coordinates work perfectly fine.

Where is Manhattan distance used? It is common in machine learning (k-nearest neighbors, clustering), chess and grid pathfinding, image processing, and logistics routing on street grids.

Last updated: