Manhattanavståndet
Manhattanavståndet, also known as the taxicab metric or L1 distance, is a metric defined on a vector space where the distance between two points is the sum of the absolute differences of their Cartesian coordinates. It is named after the grid layout of the streets on Manhattan Island, where a taxi or pedestrian must travel along the grid lines to get from one point to another, rather than a straight line.
Formally, for two points p = (p1, p2, ..., pn) and q = (q1, q2, ..., qn) in an n-dimensional
dp(p, q) = |p1 - q1| + |p2 - q2| + ... + |pn - qn|
This can also be expressed using summation notation as:
dp(p, q) = Σ (from i=1 to n) |pi - qi|
The Manhattan distance is a common distance metric in various fields, including urban planning, computer science