Euclidean Distance Calculator

Euclidean, squared Euclidean, Manhattan and cosine distance between two points or vectors.

Euclidean distance = √Σ(aᵢ − bᵢ)². Between (1, 2) and (4, 6) it is √(3² + 4²) = 5. The same formula works in 3D or any number of dimensions.

Free, runs in your browser. Nothing you enter is uploaded.

How to use it

  1. Enter the coordinates of point A and point B, separated by commas.
  2. Use the same number of dimensions for both.
  3. Read the Euclidean distance and the other distance measures.

What you enter

What you get

Formula

d = √Σ(aᵢ − bᵢ)² | Manhattan = Σ|aᵢ − bᵢ| | cos θ = (a·b) ÷ (‖a‖‖b‖)

Worked example

Input: A = (1, 2), B = (4, 6)

Result: d = 5, Manhattan = 7

The 3-4-5 right triangle.

Questions

How do you calculate Euclidean distance?

Subtract each coordinate, square the differences, add them up, and take the square root.

What is the difference between Euclidean and Manhattan distance?

Euclidean is the straight-line distance. Manhattan adds the absolute differences, like walking along a city grid.

Why is Euclidean distance used in clustering?

k-means and hierarchical clustering group points that are close in feature space. Scale the features first, or variables with large units will dominate.

What is squared Euclidean distance?

The sum of squared differences without the square root. It ranks points the same way and is cheaper to compute.

Limitations

References

Related reading

More STEM & Mathematics

All free tools · By Dr. Zubair Khalid, DVM, MS, PhD.