# How to Calculate Euclidean Distance

••• Antonio_Diaz/iStock/GettyImages
Print

Euclidean distance is the distance between two points in Euclidean space. Euclidean space was originally devised by the Greek mathematician Euclid around 300 B.C.E. to study the relationships between angles and distances. This system of geometry is still in use today and is the one that high school students study most often. Euclidean geometry specifically applies to spaces of two and three dimensions. However, it can easily be generalized to higher order dimensions.

Compute the Euclidean distance for one dimension. The distance between two points in one dimension is simply the absolute value of the difference between their coordinates. Mathematically, this is shown as |p1 - q1| where p1 is the first coordinate of the first point and q1 is the first coordinate of the second point. We use the absolute value of this difference since distance is normally considered to have only a non-negative value.

Take two points P and Q in two dimensional Euclidean space. We will describe P with the coordinates (p1,p2) and Q with the coordinates (q1,q2). Now construct a line segment with the endpoints of P and Q. This line segment will form the hypotenuse of a right triangle. Extending the results obtained in Step 1, we note that the lengths of the legs of this triangle are given by |p1 - q1| and |p2 - q2|. The distance between the two points will then be given as the length of the hypotenuse.

Use the Pythagorean theorem to determine the length of the hypotenuse in Step 2. This theorem states that c^2 = a^2 + b^2 where c is the length of a right triangle's hypotenuse and a,b are the lengths of the other two legs. This gives us c = (a^2 + b^2)^(1/2) = ((p1 - q1)^2 + (p2 - q2)^2)^(1/2). The distance between 2 points P = (p1,p2) and Q = (q1,q2) in two dimensional space is therefore ((p1 - q1)^2 + (p2 - q2)^2)^(1/2).

Extend the results of Step 3 to three dimensional space. The distance between points P = (p1, p2, p3) and Q = (q1,q2,q3) can then be given as ((p1-q1)^2 + (p2-q2)^2 + (p3-q3)^2)^(1/2).

Generalize the solution in Step 4 for the distance between two points P = (p1, p2, ..., pn) and Q = (q1,q2, ..., qn) in n dimensions. This general solution can be given as ((p1-q1)^2 + (p2-q2)^2 + ... + (pn-qn)^2)^(1/2).