Mathwords logoMathwords

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 P=(x1,y1)P = (x_1, y_1) and Q=(x2,y2)Q = (x_2, y_2) in R2\mathbb{R}^2, the taxicab metric (or L1L^1 norm) defines the distance dT(P,Q)=x1x2+y1y2d_T(P, Q) = |x_1 - x_2| + |y_1 - y_2|. This function satisfies the metric axioms (non-negativity, identity of indiscernibles, symmetry, and the triangle inequality) and thus induces a valid metric space on Rn\mathbb{R}^n.

Key Formula

dT(P,Q)=i=1npiqid_T(P,Q) = \sum_{i=1}^{n} |p_i - q_i|
Where:
  • dTd_T = Taxicab distance between points P and Q
  • pip_i = The i-th coordinate of point P
  • qiq_i = The i-th coordinate of point Q
  • nn = 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 nn dimensions, you simply sum the absolute differences across all nn 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.
17=6|1 - 7| = 6
Vertical distance: Compute the absolute difference in y-coordinates.
25=3|2 - 5| = 3
Sum: Add the two component distances.
dT=6+3=9d_T = 6 + 3 = 9
Answer: The taxicab distance is 9. (For comparison, the Euclidean distance is 36+9=456.71\sqrt{36 + 9} = \sqrt{45} \approx 6.71.)

Why It Matters

The taxicab metric is widely used in machine learning and data science as the L1L^1 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 x1x2+y1y2|x_1 - x_2| + |y_1 - y_2|, not (x1x2)2+(y1y2)2\sqrt{(x_1-x_2)^2 + (y_1-y_2)^2}. Sum absolute differences, do not square and square-root.

Related Terms