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
- Enter the coordinates of point A and point B, separated by commas.
- Use the same number of dimensions for both.
- Read the Euclidean distance and the other distance measures.
What you enter
- Coordinates of point A
- Coordinates of point B
What you get
- Euclidean distance
- Squared Euclidean distance
- Manhattan distance
- Cosine similarity
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
- Sensitive to the scale of each dimension; standardize mixed units first.
References
Related reading
More STEM & Mathematics
- Scientific Calculator Online
- Fraction Calculator (Add, Subtract, Multiply, Divide)
- Ratio Calculator
- Logarithm Calculator (log, ln, log2, any base)
- Percent Change Calculator
- GCF Calculator (Greatest Common Factor)
- LCM Calculator (Least Common Multiple)
- Proportion Calculator
- Radians to Degrees Converter
All free tools · By Dr. Zubair Khalid, DVM, MS, PhD.