# Taxicab geometry

Taxicab geometry versus Euclidean distance: In taxicab geometry, the red, yellow, blue, and green paths all have the same shortest path length of 12. In Euclidean geometry, the green line has length ${\displaystyle 6{\sqrt {2}}\approx 8.49}$ and is the unique shortest path, while the other paths have the longer length of 12.

A taxicab geometry or a Manhattan geometry is a geometry whose usual distance function or metric of Euclidean geometry is replaced by a new metric in which the distance between two points is the sum of the absolute differences of their Cartesian coordinates. The taxicab metric is also known as rectilinear distance, L1 distance, L1 distance or ${\displaystyle \ell _{1}}$ norm (see Lp space), snake distance, city block distance, Manhattan distance or Manhattan length.[1] The latter names refer to the rectilinear street layout on the island of Manhattan, where the shortest path a taxi travels between two points is the sum of the absolute values of distances that it travels on avenues and on streets.

The geometry has been used in regression analysis since the 18th century, and is often referred to as LASSO. The geometric interpretation dates to non-Euclidean geometry of the 19th century and is due to Hermann Minkowski.

In ${\displaystyle \mathbb {R} ^{2}}$, the taxicab distance between two points ${\displaystyle (x_{1},y_{1})}$ and ${\displaystyle (x_{2},y_{2})}$ is ${\displaystyle \left|x_{1}-x_{2}\right|+\left|y_{1}-y_{2}\right|}$. That is, it is the sum of the absolute values of the differences in both coordinates.

## Formal definition

The taxicab distance, ${\displaystyle d_{\text{T}}}$, between two vectors ${\displaystyle \mathbf {p} =(p_{1},p_{2},\dots ,p_{n}){\text{ and }}\mathbf {q} =(q_{1},q_{2},\dots ,q_{n})}$ in an n-dimensional real vector space with fixed Cartesian coordinate system, is the sum of the lengths of the projections of the line segment between the points onto the coordinate axes. More formally,

${\displaystyle d_{\text{T}}(\mathbf {p} ,\mathbf {q} )=\left\|\mathbf {p} -\mathbf {q} \right\|_{\text{T}}=\sum _{i=1}^{n}\left|p_{i}-q_{i}\right|}$
For example, in ${\displaystyle \mathbb {R} ^{2}}$, the taxicab distance between ${\displaystyle \mathbf {p} =(p_{1},p_{2})}$ and ${\displaystyle \mathbf {q} =(q_{1},q_{2})}$ is ${\displaystyle \left|p_{1}-q_{1}\right|+\left|p_{2}-q_{2}\right|.}$

## History

The L1 metric was used in regression analysis in 1757 by Roger Joseph Boscovich.[2] The geometric interpretation dates to the late 19th century and the development of non-Euclidean geometries, notably by Hermann Minkowski and his Minkowski inequality, of which this geometry is a special case, particularly used in the geometry of numbers, (Minkowski 1910). The formalization of Lp spaces is credited to (Riesz 1910).

## Properties

Taxicab distance depends on the rotation of the coordinate system, but does not depend on its reflection about a coordinate axis or its translation. Taxicab geometry satisfies all of Hilbert's axioms (a formalization of Euclidean geometry) except for the side-angle-side axiom, as two triangles with equally "long" two sides and an identical angle between them are typically not congruent unless the mentioned sides are parallel.

### Balls

Circles in discrete and continuous taxicab geometry

A topological ball is a set of points with a fixed distance, called the radius, from a point called the center. In n-dimensional Euclidean geometry, the balls are spheres. In taxicab geometry, distance is determined by a different metric than in Euclidean geometry, and the shape of the ball changes as well. In n dimensions, a taxicab ball is in the shape of an n-dimensional orthoplex. In two dimensions, these are squares with sides oriented at a 45° angle to the coordinate axes. The image to the right shows why this is true, by showing in red the set of all points with a fixed distance from a center, shown in blue. As the size of the city blocks diminishes, the points become more numerous and become a rotated square in a continuous taxicab geometry. While each side would have length ${\displaystyle {\sqrt {2}}r}$ using a Euclidean metric, where r is the circle's radius, its length in taxicab geometry is 2r. Thus, a circle's circumference is 8r. Thus, the value of a geometric analog to ${\displaystyle \pi }$ is 4 in this geometry. The formula for the unit circle in taxicab geometry is ${\displaystyle |x|+|y|=1}$ in Cartesian coordinates and

${\displaystyle r={\frac {1}{\left|\sin \theta \right|+\left|\cos \theta \right|}}}$
in polar coordinates.

A circle of radius 1 (using this distance) is the von Neumann neighborhood of its center.

A circle of radius r for the Chebyshev distance (L metric) on a plane is also a square with side length 2r parallel to the coordinate axes, so planar Chebyshev distance can be viewed as equivalent by rotation and scaling to planar taxicab distance. However, this equivalence between L1 and L metrics does not generalize to higher dimensions.

Whenever each pair in a collection of these circles has a nonempty intersection, there exists an intersection point for the whole collection; therefore, the Manhattan distance forms an injective metric space.

### Arc length

Let ${\displaystyle y=f(x)}$ be a continuously differentiable function in ${\displaystyle \mathbb {R} ^{2}}$. Let ${\displaystyle s}$ be the taxicab arc length of the planar curve defined by ${\displaystyle f}$ on some interval ${\displaystyle [a,b]}$. Then the taxicab length of the ${\displaystyle i^{\text{th}}}$ infinitesimal regular partition of the arc, ${\displaystyle \Delta s_{i}}$, is given by:[3]

${\displaystyle \Delta s_{i}=\Delta x_{i}+\Delta y_{i}=\Delta x_{i}+|f(x_{i})-f(x_{i-1})|}$

By the Mean Value Theorem, there exists some point ${\displaystyle x_{i}^{*}}$ between ${\displaystyle x_{i}}$ and ${\displaystyle x_{i-1}}$such that ${\displaystyle f(x_{i})-f(x_{i-1})=f'(x_{i}^{*})dx_{i}}$.[4]

${\displaystyle \Delta s_{i}=\Delta x_{i}+|f'(x_{i}^{*})|\Delta x_{i}=\Delta x_{i}(1+|f'(x_{i}^{*})|)}$

Then ${\displaystyle s}$ is given as the sum of every partition of ${\displaystyle s}$ on ${\displaystyle [a,b]}$ as they get arbitrarily small.

Curves defined by monotone increasing or decreasing functions have the same taxicab arc length as long as they share the same endpoints.

{\displaystyle {\begin{aligned}s&=\lim _{n\rightarrow \infty }\sum _{i=1}^{n}\Delta x_{i}(1+|f'(x_{i}^{*})|)\\&=\int _{a}^{b}1+|f'(x)|\,dx\end{aligned}}}

To test this, take the taxicab circle of radius ${\displaystyle r}$ centered at the origin. Its curve in the first quadrant is given by ${\displaystyle f(x)=-x+r}$ whose length is

${\displaystyle s=\int _{0}^{r}1+|-1|dx=2r}$

Multiplying this value by ${\displaystyle 4}$ to account for the remaining quadrants gives ${\displaystyle 8r}$, which agrees with the circumference of a taxicab circle.[5] Now take the Euclidean circle of radius ${\displaystyle r}$ centered at the origin, which is given by ${\displaystyle f(x)={\sqrt {r^{2}-x^{2}}}}$. Its arc length in the first quadrant is given by

{\displaystyle {\begin{aligned}s&=\int _{0}^{r}1+|x{\sqrt {r^{2}-x^{2}}}|dx\\&=x+{\sqrt {r^{2}-x^{2}}}{\bigg |}_{0}^{r}\\&=r-(-r)\\&=2r\end{aligned}}}

Accounting for the remaining quadrants gives ${\displaystyle 4\times 2r=8r}$ again. Therefore, the circumference of the taxicab circle and the Euclidean circle in the taxicab metric are equal.[6] In fact, for any function ${\displaystyle f}$ that is monotonic and differentiable with a continuous derivative over an interval ${\displaystyle [a,b]}$, the arc length of ${\displaystyle f}$ over ${\displaystyle [a,b]}$ is ${\displaystyle (b-a)+\mid f(b)-f(a)\mid }$.[7]

Two taxicab right isoceles triangles. Three angles and two legs are congruent, but the triangles are not congruent. Therefore, ASASA is not a congruence theorem in taxicab geometry.

### Triangle congruence

Two triangles are congruent if and only if three corresponding sides are equal in distance and three corresponding angles are equal in measure. There are several theorems that guarantee triangle congruence in Euclidean geometry, namely Angle-Angle-Side (AAS), Angle-Side-Angle (ASA), Side-Angle-Side (SAS), and Side-Side-Side (SSS). In taxicab geometry, however, only SASAS guarantees triangle congruence.[8]

Take, for example, two right isosceles taxicab triangles whose angles measure 45-90-45. The two legs of both triangles have taxilength 2, but the hypotenuses are not congruent. This counterexample eliminates AAS, ASA, and SAS. It also eliminates AASS, AAAS, and even ASASA. Having three congruent angles and two sides does not guarantee triangle congruence in taxicab geometry. Therefore, the only triangle congruence theorem in taxicab geometry is SASAS, where all three corresponding sides must be congruent and at least two corresponding angles must be congruent.[9] This result is mainly due to the fact that the length of a line segment depends on its orientation in taxicab geometry.

## Applications

### Compressed sensing

In solving an underdetermined system of linear equations, the regularization term for the parameter vector is expressed in terms of the ${\displaystyle \ell _{1}}$ norm (taxicab geometry) of the vector.[10] This approach appears in the signal recovery framework called compressed sensing.

### Differences of frequency distributions

Taxicab geometry can be used to assess the differences in discrete frequency distributions. For example, in RNA splicing positional distributions of hexamers, which plot the probability of each hexamer appearing at each given nucleotide near a splice site, can be compared with L1-distance. Each position distribution can be represented as a vector where each entry represents the likelihood of the hexamer starting at a certain nucleotide. A large L1-distance between the two vectors indicates a significant difference in the nature of the distributions while a small distance denotes similarly shaped distributions. This is equivalent to measuring the area between the two distribution curves because the area of each segment is the absolute difference between the two curves' likelihoods at that point. When summed together for all segments, it provides the same measure as L1-distance.[11]