Manhattan Distance Calculator
Compute the Manhattan (L1 / taxicab / city-block) distance between two points or two vectors of any dimension, in your browser. See the full per-dimension working, the substituted expression, and the Euclidean and Chebyshev comparisons. Matches scikit-learn and SciPy — no signup, nothing uploaded.
How it works
Manhattan distance — also called L1, taxicab, or city-block distance — is the distance between two points measured along axis-aligned moves, the way a taxi travels a rectangular street grid rather than cutting diagonally. For two equal-length vectors a = [a₁…aₙ] and b = [b₁…bₙ], it is the sum of the absolute coordinate differences. It is the metric scikit-learn calls manhattan_distances and SciPy calls cityblock.
d₁(a, b) = Σ |aᵢ − bᵢ| = |a₁ − b₁| + … + |aₙ − bₙ|
The tool computes this in three steps:
- Per-dimension difference. Subtract the vectors coordinate by coordinate:
dᵢ = aᵢ − bᵢ. - Absolute value and sum. Take
|dᵢ|for each dimension and add them. That sumΣ |dᵢ|is the Manhattan distance — no squaring, no square root. - Comparison metrics. Over the same differences the tool also reports Euclidean
√(Σ dᵢ²)and Chebyshevmax |dᵢ|, the L2 and L∞ members of the same Minkowski family.
All three metrics are special cases of the Minkowski distance dₚ = (Σ |aᵢ − bᵢ|ᵖ)^(1/p): p = 1 gives Manhattan, p = 2 gives Euclidean, and p → ∞ gives Chebyshev. Because Manhattan is the p = 1 case, the calculator uses that general form as an independent cross-check — it recomputes (Σ |dᵢ|¹)^(1/1) and confirms it reconciles with the direct Σ |dᵢ| sum, exactly as SciPy's minkowski(u, v, 1) equals cityblock(u, v). All arithmetic is double-precision and is rounded only for display, using the decimal places you pick, so even inputs around 10⁹ stay exact.
Worked examples
Frequently asked questions
Sources & references
- scikit-learn — sklearn.metrics.pairwise.manhattan_distances (the canonical L1 definition this tool matches)
- SciPy — scipy.spatial.distance.cityblock (the city-block / L1 definition and naming)
- SciPy — scipy.spatial.distance.minkowski (the general dₚ form; p = 1 is the cross-check route)
The formulas on this page were last cross-checked against these sources on 2026-06-11. Manhattan distance is a stable mathematical definition, so this tool needs no rate or schedule updates — only the worked examples are periodically re-reconciled.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a bug, edge case, or want to suggest an improvement?
Email me at [email protected] — most fixes ship within 24 hours.