Euclidean Distance Calculator
The Straight-Line Distance, Generalized to Any Number of Dimensions
Euclidean distance extends the Pythagorean theorem beyond two dimensions: instead of just height and width, it sums the squared difference across however many dimensions each point has, then takes the square root. It's the most intuitive distance metric in machine learning precisely because it matches ordinary geometric distance, just applied to feature vectors instead of physical coordinates.
The Formula
d = √(Σ(aᵢ − bᵢ)²)
Where This Matters
- K-nearest neighbors — classifying or predicting based on the closest points in feature space by Euclidean distance.
- Clustering (K-means) — assigning points to the nearest cluster center using this exact distance formula.
- Anomaly detection — flagging points that sit unusually far from the rest of the data cloud.
Worked Example
| Dimension | Difference | Squared |
|---|---|---|
| 1st | 1 − 4 = −3 | 9 |
| 2nd | 2 − 6 = −4 | 16 |
| 3rd | 3 − 8 = −5 | 25 |
d = √(9 + 16 + 25) = √50 = 7.071068.
How to Use This Calculator
- Enter Point A as a comma-separated list of coordinates.
- Enter Point B with the same number of dimensions.
- Select Calculate to get the Euclidean distance between the two points.
Related Calculations
Compare direction instead of distance with the Cosine Similarity Calculator, or normalize features before measuring distance with the Feature Scaling Calculator.