Difference Between L1/Manhattan and L2/Euclidean Distance

Rina Mondal
2 min readDec 14, 2023

--

In this blog, I have elaborated on the distinction between the calculation methods of L1 distance (Manhattan distance) and L2 distance (Euclidean distance).

L1 /Manhattan distance measures the distance as if you were navigating a city grid system and could only move along the streets (i.e., horizontal and vertical directions).

L2 /Euclidean distance measures the shortest path or direct line between two points.

For instance, consider two points in a 2-dimensional space: P = (x1,y1) and Q = (x2​,y2​). Between these points (P,Q), the L1 distance: L1= ∣x1​−x2​∣ + ∣y1​−y2​∣ and the L2 distance: L2=root((x1​−x2​)²+(y1​−y2​)²)​

Let’s consider a simple example with two points: Point P = (3,5) and Point Q = (1,9).

  1. L1 distance =|3–1|+|5-9|=6
  2. L2 distance=root((x1​−x2​)²+(y1​−y2​)²)​ =root((3​−1​)²+(5−9​)²)​=4.97

The L1 distance is often referred to as the Manhattan distance due to its similarity to how distances are calculated in a grid-like road system, such as the streets in Manhattan, New York City. When traveling from one point to another in such a grid system, the distance covered is based on the sum of the horizontal and vertical distances rather than the shortest (or diagonal) distance as it is calculated in L2 /Euclidean distance. L2 is like the measuring the distance “as the crow flies.”

Euclidean distance can be valuable:

  • When dealing with continuous variables or features where the notion of “as-the-crow-flies” distance is meaningful.
  • In lower-dimensional spaces
  • In certain feature engineering tasks, especially when the differences in magnitudes across dimensions are considered essential or informative.

However, Euclidean distance is more sensitive to differences in magnitude between dimensions, while Manhattan distance is less sensitive to such differences and may be preferable when dimensions have different units or scales.

Explore Data Science Roadmap- 2024

Give it :👏👏👏👏:
If you found this guide helpful , why not show some love? and if you have questions or topics you’d like to explore further, drop a comment 💬 below 👇

Happy Learning.. :)

--

--

Rina Mondal

I have an 8 years of experience and I always enjoyed writing articles. If you appreciate my hard work, please follow me, then only I can continue my passion.