Manhattan Distance
Manhattan distance measures the gap between two points as the sum of the absolute differences of their coordinates, like a taxi crossing a street grid with no diagonal shortcuts. As the p = 1 case of Minkowski distance, it is robust to outliers and useful in high dimensions.
The Manhattan distance between two points is the sum of the absolute differences of their coordinates. For a point x and a point y, each with n coordinates, it is computed as d(x, y) = |x₁ − y₁| + |x₂ − y₂| + … + |xₙ − yₙ|. It is also called the L1 distance, taxicab, rectilinear or city-block distance, and it measures the trip a taxi would take across a street grid: it can only move horizontally and vertically, never cutting across on the diagonal.
The name evokes Manhattan and its lattice of avenues. Unlike straight-line distance, there is no diagonal shortcut: to cross from one corner of a 6-by-6 block to the opposite one, the Manhattan distance is 12, whereas the Euclidean distance would be 6√2 ≈ 8.49.
The limit
Choosing L1 or another metric changes which examples count as “near.” Distance is useful only when the coordinates being compared represent differences relevant to the problem.
This article was produced with artificial intelligence under human editorial oversight.