# Manhattan distance

The manhattan distance is a different way of measuring distance. It is named after the grid shape of streets in Manhattan. If there are two points, ${\displaystyle (x_{1},y_{1})}$ and ${\displaystyle (x_{2},y_{2})}$, the manhattan distance between the two points is ${\displaystyle |x_{1}-x_{2}|+|y_{1}-y_{2}|}$.

This distance can be imagined as the length needed to move between two points in a grid where you can only move up, down, left or right.

## Extension

This definition can be used for three and higher dimensions too. If there are two vectors, ${\displaystyle \mathbf {p} =(p_{1},p_{2}\dots ,p_{n})}$ and ${\displaystyle \mathbf {q} =(q_{1},p_{2}\dots ,q_{n})}$, then the manhattan distance between the two points is the absolute value of the difference between all numbers in the vector. Or, in notation:

${\displaystyle \sum _{i=1}^{n}|p_{i}-q_{i}|}$