Euclidean Distance
Euclidean distance is the straight-line distance between two points. It works in two dimensions, three dimensions, or even higher — it's the most common way to measure how far apart two points are.
Euclidean distance is the length of the line segment connecting two points in -dimensional Euclidean space. It generalizes the Pythagorean theorem: for two points and with coordinates each, the Euclidean distance is the square root of the sum of squared differences across all coordinates. In two dimensions, this reduces to the familiar distance formula from coordinate geometry.
Key Formula
Where:
- = the Euclidean distance between points p and q
- = the number of dimensions (coordinates)
- = the i-th coordinate of point p
- = the i-th coordinate of point q
Worked Example
Problem: Find the Euclidean distance between the points and in 3D space.
Step 1: Subtract each coordinate of p from the corresponding coordinate of q.
Step 2: Square each of those differences.
Step 3: Add the squared differences together.
Step 4: Take the square root of the sum.
Answer: The Euclidean distance between and is .
Visualization
Why It Matters
Euclidean distance is the default distance metric in many machine learning and data science algorithms. Clustering methods like k-means group data points by measuring Euclidean distances between them and cluster centers. It also appears in computer graphics for collision detection, in recommendation systems for comparing user preferences, and throughout physics whenever straight-line distance matters.
Common Mistakes
Mistake: Forgetting to take the square root at the end
Correction: Without the square root, you get the squared Euclidean distance, which is a different (though sometimes useful) quantity. Always finish with to get the actual distance.
Mistake: Subtracting coordinates in the wrong order across dimensions
Correction: Stay consistent: subtract from (or vice versa) for every coordinate. Since the differences are squared, the order within a single subtraction doesn't affect the result, but mixing up which point's coordinates you use will give wrong differences.
