The Manhattan distance (or taxicab distance) between vectors p and q is the sum of the absolute differences of their Cartesian coordinates. If p=(p1, p2,…, p n ) and q=(q1, q2,…,q n ) are vectors in an n-dimensional real vector space with a fixed Cartesian coordinate system, then the Manhattan distance between them is:
For example, in the plane, the Manhattan distance between (p1, p2) and (q1, q2) is |p1-q1 |+|p2-q2|.