What is the Euclidean distance between vectors?
The Euclidean distance is the straight-line ("as the crow flies") distance between two points or vectors in n-dimensional space. It generalizes the Pythagorean theorem to any number of dimensions and is one of the most widely used distance metrics in geometry, machine learning, clustering, and data science.
How to use this calculator
Enter the components of Vector A and Vector B as comma-separated numbers — for example 1, 2, 3 and 4, 6, 8. The two vectors should have the same number of components; if they differ, only the overlapping leading components are compared. Click calculate to see the distance, the number of dimensions compared, and the sum of squared differences.
The formula explained
The distance is computed as $$d = \sqrt{\sum_{i=1}^{n}\left(\text{A}_i - \text{B}_i\right)^{2}}$$. For each matching pair of components, subtract one from the other, square the result so negatives don't cancel positives, add all those squares together, then take the square root of the total. The square root returns the value to the original scale of measurement.
Worked example
Take A = (1, 2, 3) and B = (4, 6, 8). The differences are −3, −4, and −5. Squaring gives 9, 16, and 25, which sum to 50. The square root of 50 is approximately 7.0711. That is the Euclidean distance between the two vectors.
$$d = \sqrt{(1-4)^{2} + (2-6)^{2} + (3-8)^{2}} = \sqrt{9 + 16 + 25} = \sqrt{50} \approx 7.0711$$
FAQ
What if my vectors have different lengths? Distance is only well-defined for equal-length vectors. This tool compares the leading components up to the shorter vector's length.
Does this work for 2D and 3D points? Yes — enter two numbers for 2D points or three for 3D points; the same formula applies.
How is this different from Manhattan distance? Manhattan distance sums absolute differences (\(|\text{A}_i - \text{B}_i|\)) without squaring or taking a root, measuring distance along axes rather than the straight line.