I don't understand this picture, which says if we change the coordinate system, we would have the same result for $L_2$ distance, whereas, our result would differ for $L_1$ distance. What does it mean by coordinate system? $(0,0)$ if yes, the assertion is not true.


I mean, suppose we have a picture with this matrix A, and another with B, for calculating their L1(Manhattan) and L2(Euclidean) distances, we would have the following code, how is this slide applied to the proposed problem?

import numpy as np
A = [[0,21,2],[3,4,5],[6,7,8]]
B = [[5,6,37],[8,0,10],[11,12,13]]
L1 = np.zeros((3,3))
L2 = np.zeros((3,3))
C = np.zeros((3,3))
for i in range(len(A)):
    for j in range(len(A)):
        L1[i][j] = np.abs(A[i][j] - B[i][j])
        L2[i][j] = np.power((A[i][j] - B[i][j]),2)    

2 Answers 2


For example, consider the green line. What is its length? In $L_2$, the answer is $1$, in $L_1$, the answer is $1$ as well.

Now, for the same line, let's rotate it $45^\circ$ counterclockwise. What is the length again? In $L_2$, its length remains to be $1$. However, in $L_1$, using Manhattan distance, it's length is now $\frac{1}{\sqrt{2}}+\frac{1}{\sqrt{2}}=\sqrt2$. As we can see, rotation can change $L_1$ distance.

Rather than rotating the line, we could also equivalently rotated our $x$ and $y$-axis instead.

enter image description here


I saw the same lecture, it might not of been made clear the Circular Line is the Euclidian (L2) distance of 1, and the Dimond is the Manhattan (L1) distance when at a distance of 1. I guess as a unit vector in each case. The video kind of implied there both from a circle image but actually if you listen very hard, he did not actually say that, he said "it was the Manhattan (L1) circle". As the Manhattan circle equivalence, and is from conceptually a square diamond i.e. same number of steps in any direction resulting in a value of 1 hence it is a diamond (up, down, left and right), enter image description here

Also the Euclidian (L2) distance is from a shape with a constant distance value (radial), i.e. a circle. enter image description here

So the confusion may be that the examples have used same addressing in both the Manhattan (L1) and Euclidian (L2), as the unit vector, but those original shapes are not a square or a circle.

It confused me too, by the way until a realized it was the unit vector. Then I realized he said "it was the Manhattan (L1) circle" not it is the shape from a circle. Thus for a diamond input....

enter image description here

The confusion for me, and perhaps you, was that if you plot a diamond image for L2 using the a capture of the angle you get the original shape (diamond), and from L1 you get the circle. which appear to be the wrong way around, as presented.

enter image description here

Also if you start with a Circle:

enter image description here

Then you get the following....

enter image description here

However, what you really starting with is:

enter image description here

Which is the addition of the addressing, and that results in the diamond and circle the right way around.

enter image description here

I hope that helps, it helped me.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.