Manhattan Distance Calculator

Calculate the Manhattan (taxicab/L1) distance between two points or vectors of any dimension, with Euclidean distance shown for comparison.

Use the Manhattan Distance Calculator

Vector Inputs

Quick Presets

Manhattan Distance

—

L1 / taxicab / city-block

Euclidean Distance

—

L2 / straight-line

Per-Dimension Breakdown

Enter values above and click Calculate.

Formula

d(P, Q) = |P₁−Q₁| + |P₂−Q₂| + … + |Pₙ−Qₙ|

Summary

Manhattan distance (also called taxicab or L1 distance) sums the absolute differences of each coordinate pair. It differs from Euclidean distance, which uses the straight-line path; Manhattan distance only allows movement along axis-aligned steps — like navigating city blocks. This tool handles vectors of any dimension and shows both metrics side by side so you can compare them for your use case.

How it works

  1. Enter the coordinates of the first point (P) as a comma-separated list, e.g. "1, 2, 3".
  2. Enter the coordinates of the second point (Q) with the same number of dimensions.
  3. The tool computes |P1−Q1| + |P2−Q2| + … for each dimension to produce the Manhattan distance.
  4. Euclidean distance (√∑(Pi−Qi)²) is computed alongside for comparison.
  5. Component-level breakdown shows the absolute difference for each dimension.

Use cases

  • Compare feature vectors in machine-learning distance metrics (k-NN, k-means).
  • Calculate grid-based pathfinding costs in games or robotics.
  • Check distance between data points when outliers should not be over-penalized (L1 vs L2).
  • Verify algorithm output during development of spatial or clustering code.
  • Teach the difference between L1 and L2 norms in linear algebra coursework.
  • Compute pixel-wise L1 distance between image patches in computer vision.

Frequently Asked Questions

Last updated: 2026-06-19 · Reviewed by Nham Vu