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

Euclidean distance between A = (1, 2, 3) and B = (4, 6, 8)
DimensionDifferenceSquared
1st1 − 4 = −39
2nd2 − 6 = −416
3rd3 − 8 = −525

d = √(9 + 16 + 25) = √50 = 7.071068.

How to Use This Calculator

  1. Enter Point A as a comma-separated list of coordinates.
  2. Enter Point B with the same number of dimensions.
  3. 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.