Manhattan Distance Calculator

Manhattan Distance Calculator

Named after how a taxi navigates a city grid (only along streets, never diagonally through buildings), Manhattan distance sums the absolute differences between two points across every dimension.

Distance = sum(|Ai - Bi|) across all dimensions

Example

Point A = (1, 2, 3), Point B = (4, 6, 8):

Distance = |1-4| + |2-6| + |3-8| = 3 + 4 + 5 = 12

Manhattan vs. Euclidean Distance

While Euclidean distance measures the straight-line "as the crow flies" path between points, Manhattan distance measures the path along grid lines - this makes it more appropriate for data where dimensions represent genuinely separate, non-diagonal steps (like city blocks, or independent feature axes), and it tends to be more robust to large outliers in any single dimension since differences are summed directly rather than squared.

Where It's Used

Manhattan distance appears in k-nearest neighbors classification, clustering algorithms, and regularization techniques (L1 regularization, or "Lasso," is named for this same distance metric) - it's often preferred over Euclidean distance in high-dimensional spaces or when features are on grid-like or highly correlated scales.