#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
📏 FREE · ANY DIMENSIONS

Distance Calculator: Euclidean, Manhattan and More

Enter two points with any number of coordinates and compare five distances.

  • 📐 Euclidean (L2)
  • 🏙️ Manhattan (L1)
  • ♾️ Chebyshev, Minkowski, cosine

How to use the Euclidean and Manhattan Distance Calculator

  1. 1. Enter point AType coordinates separated by commas, as many as you need.
  2. 2. Enter point BUse the same number of coordinates.
  3. 3. CompareSee every distance with the working for Euclidean and Manhattan.

Formulas with an example

  • Euclidean (L2): √Σ(aᵢ − bᵢ)², the straight-line distance.
  • Manhattan (L1): Σ|aᵢ − bᵢ|, like walking along city blocks.
  • Chebyshev (L∞): max|aᵢ − bᵢ|, like a king moving on a chessboard.
  • Minkowski: (Σ|aᵢ − bᵢ|ᵖ)^(1/p); p = 1 is Manhattan, p = 2 is Euclidean.

For A = (1, 2, 3) and B = (4, 6, 8), the differences are 3, 4 and 5. Euclidean distance is √(9 + 16 + 25) = √50 = 7.0711, Manhattan is 3 + 4 + 5 = 12, Chebyshev is 5, and Minkowski with p = 3 is exactly 6, since 27 + 64 + 125 = 216 = 6³.

Which distance to use in ML

  • Euclidean is the default in k-means and KNN for continuous, scaled features.
  • Manhattan is less affected by one big difference and can work better with many dimensions or grid-like data.
  • Cosine distance ignores length and compares direction, which suits text and embeddings.
  • Chebyshev suits problems where the worst single difference matters, such as tolerances.

Scale features before measuring distance. Otherwise a feature such as salary in rupees will swamp one such as age in years. In SciPy, scipy.spatial.distance has all of these, and scikit-learn's KNN takes a metric argument. See distances drive predictions in the KNN classifier visualizer, or compare directions with the cosine similarity calculator.

Frequently asked questions

Can I use more than three dimensions?

Yes. Enter as many coordinates as you like, as long as both points have the same number.

Why is Manhattan always at least Euclidean?

A straight line is the shortest path, so the block-by-block route is never shorter.

Is the Euclidean and Manhattan Distance Calculator free?

Yes, the Euclidean and Manhattan Distance Calculator is free. The first time you see your first result, you are asked for your name and WhatsApp number once. After that, this and every other Uncodemy tool opens straight away without the form.

More free tools

See all free tools