Manhattan Distance Calculator
Find the Manhattan (taxicab/city-block) distance between two points — the total horizontal and vertical steps required to travel between them on a grid, with no diagonal shortcuts.
|Δx| + |Δy| = 3 + 4
- 1
Horizontal distance |Δx|
|4 − 1| = 3 - 2
Vertical distance |Δy|
|6 − 2| = 4 - 3
Manhattan distance = |Δx| + |Δy|
3 + 4 = 7Total axis-aligned travel — horizontal steps plus vertical steps.
How does this calculator work?
Manhattan distance between (x₁, y₁) and (x₂, y₂) equals |x₂ − x₁| + |y₂ − y₁| — the total horizontal plus vertical displacement with no diagonal shortcuts. Always ≥ Euclidean distance; the detour ratio peaks at √2 for diagonal paths. Used in grid path-planning, k-NN with L¹ metric, and image processing.
Formula
How this is calculated
Manhattan distance gets its name from the grid layout of Manhattan island: because you cannot cut through a city block diagonally, the shortest traversable path between two intersections is the sum of horizontal and vertical steps. Formally, for two points A = (x₁, y₁) and B = (x₂, y₂), the Manhattan distance is |x₂ − x₁| + |y₂ − y₁|.
This is also called L¹ or taxicab distance, one of the standard Minkowski metrics. Compare it with the Euclidean (straight-line) distance √((Δx)² + (Δy)²): the Manhattan distance is always ≥ Euclidean, with equality only when the two points share the same x- or y-coordinate. The detour ratio (Manhattan ÷ Euclidean) shows how much longer the axis-aligned path is than a direct line; it ranges from 1.0 (co-axial points) to √2 ≈ 1.414 (perfectly diagonal points).
Manhattan distance appears throughout computer science and data science: k-nearest-neighbours with the L¹ metric, image processing (sum of absolute differences), robot path planning on grids, and clustering algorithms. The XY plot above shows the right-angle Manhattan path from A to B — horizontal first, then vertical.
Frequently asked questions
Manhattan distance between points (x₁, y₁) and (x₂, y₂) is |x₂ − x₁| + |y₂ − y₁|. It counts total horizontal and vertical steps needed, with no diagonal movement allowed.
Euclidean distance is the straight-line length √((Δx)² + (Δy)²), while Manhattan distance is |Δx| + |Δy|. Manhattan is always ≥ Euclidean and equals it only when one coordinate difference is zero.
Use Manhattan distance when movement is constrained to a grid (city navigation, chessboard rooks, image patches), or when you want the L¹ norm — it is more robust to large outlier values in a single dimension than the L² (Euclidean) norm.
TG we-Calculate Editorial Team. (2026). Manhattan Distance Calculator [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/manhattan-distance-calculator
TG we-Calculate Editorial Team. "Manhattan Distance Calculator." TG we-Calculate. 2026. https://we-calculate.com/calculator/manhattan-distance-calculator.
TG we-Calculate Editorial Team, "Manhattan Distance Calculator," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/manhattan-distance-calculator
@misc{wecalculate_manhattan_distance_calculator, title = {Manhattan Distance Calculator}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/manhattan-distance-calculator}}, year = {2026}, note = {TG we-Calculate} }
Did this calculator help you?
