# Euclidean & Manhattan Distance

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.

Many thanks.

-

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 }$.

Manhatten: 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 Manhatten 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.

-
@user1366769 Yes, that's how you would do it. No misunderstanding, it seems. – David Mitra May 1 '12 at 21:47
@SnookerFan That's correct. – David Mitra May 1 '12 at 22:11
@SnookerFan You take the absolute value of the differences of the coordinates. Then sum. The sum should not be negative, as no term in the sum is negative. – David Mitra May 1 '12 at 22:30
@SnookerFan No :(, Start with$$|1-0.1|+|3.2-5.2|+|4.8-1.9|+|0.1-4.2|+|3.2-1.9|+|0.6-0.1|+|2.2-0.1|+|1.1-6.0|$$c‌​ompute the absolute values$$.9+2+2.9+4.1+1.3+.5+2.1+4.9$$ sum them up to get $18.7$. – David Mitra May 1 '12 at 23:01
@SnookerFan You're welcome. Glad to help. – David Mitra May 1 '12 at 23:08

http://en.wikipedia.org/wiki/Manhattan_distance

http://en.wikipedia.org/wiki/Euclidean_distance


Edited: eucledian distance between two points

P=[p0,p1,p2..pn]  and  Q=[q1,q2,...qn}


$D(p,q)=\sqrt(((sum((qi-pi)^2)$)) for i=1....n manhattan distance is sum of absolute differences between points,see wikipedia

-
Thank you for your help. – SnookerFan May 1 '12 at 23:08
you are welcome – dato datuashvili May 2 '12 at 9:26