How do I calculate Euclidean and Manhattan distance by hand?

I have a practice problem that I am working on (artificial intelligence), but am unable to calculate the Euclidean and Manhattan distances by hand using the following values:

x1:  1.0, 3.2, 4.8, 0.1, 3.2, 0.6, 2.2, 1.1
x2:  0.1, 5.2, 1.9, 4.2, 1.9, 0.1, 0.1, 6.0

Could somebody kindly explain how I would go about working out the Euclidean and Manhattan distances by hand as I have no idea where to begin, so some pointers in the right direction would be highly appreciated!

Please note that I'm not asking to have it done for me; I am interested in the workings behind it so that I know how to go about it.


Solution 1:

Euclidean: Take the square root of the sum of the squares of the differences of the coordinates.

For example, if $x=(\color{darkgreen}a,\color{maroon}b)$ and $y=(\color{darkgreen}c,\color{maroon}d)$, the Euclidean distance between $x$ and $y$ is

$\sqrt{(\color{darkgreen}a-\color{darkgreen}c)^2+(\color{maroon}b-\color{maroon}d)^2 }$.

Manhattan: Take the sum of the absolute values of the differences of the coordinates.

For example, if $x=(\color{darkgreen}a,\color{maroon}b)$ and $y=(\color{darkgreen}c,\color{maroon}d)$, the Manhattan distance between $x$ and $y$ is

$ {|\color{darkgreen}a-\color{darkgreen}c|+|\color{maroon}b-\color{maroon}d| }$.

For your vectors, it's the same thing except you have more coordinates.

Solution 2:

This is an old post, but just want to explain that the squaring and square rooting in the euclidean distance function is basically to get absolute values of each dimension assessed. Manhattan distance just bypasses that and goes right to abs value (which if your doing ai, data mining, machine learning, may be a cheaper function call then pow'ing and sqrt'ing.) I've seen debates about using one way vs the other when it gets to higher level stuff, like comparing least squares or linear algebra (?). Manhattan distance is easier to calculate by hand, bc you just subtract the values of a dimensiin then abs them and add all the results. Euclidean distance is harder by hand bc you're squaring anf square rooting. So some of this comes down to what purpose you're using it for.