Taxicab Metric — Definition, Formula & Examples
The taxicab metric is a way of measuring distance between two points by adding the absolute differences of their coordinates, as if you could only travel along grid lines rather than diagonally. It is also called the Manhattan distance because it mimics navigating a city's street grid.
Given two points and in , the taxicab metric (or norm) defines the distance . This function satisfies the metric axioms (non-negativity, identity of indiscernibles, symmetry, and the triangle inequality) and thus induces a valid metric space on .
Key Formula
Where:
- = Taxicab distance between points P and Q
- = The i-th coordinate of point P
- = The i-th coordinate of point Q
- = Number of dimensions
How It Works
Instead of drawing a straight line between two points, you measure how far you travel horizontally plus how far you travel vertically. Think of a taxi driving through Manhattan: it cannot cut through buildings, so it follows the grid. The taxicab distance is always greater than or equal to the Euclidean distance between the same two points, with equality only when the points share a coordinate. In dimensions, you simply sum the absolute differences across all coordinates.
Worked Example
Problem: Find the taxicab distance between A = (1, 2) and B = (7, 5).
Horizontal distance: Compute the absolute difference in x-coordinates.
Vertical distance: Compute the absolute difference in y-coordinates.
Sum: Add the two component distances.
Answer: The taxicab distance is 9. (For comparison, the Euclidean distance is .)
Why It Matters
The taxicab metric is widely used in machine learning and data science as the distance for clustering, nearest-neighbor search, and regularization (e.g., LASSO regression). Urban planners and logistics engineers rely on it to model realistic travel distances on road grids. It also serves as a key introductory example in topology and metric space theory, illustrating that distance can be defined in multiple valid ways.
Common Mistakes
Mistake: Computing the taxicab distance by squaring the coordinate differences (using the Euclidean formula) instead of taking absolute values.
Correction: The taxicab metric uses , not . Sum absolute differences, do not square and square-root.
