Definitions

# Euclidean distance

In mathematics, the Euclidean distance or Euclidean metric is the "ordinary" distance between two points that one would measure with a ruler, which can be proven by repeated application of the Pythagorean theorem. By using this formula as distance, Euclidean space becomes a metric space (even a Hilbert space). The associated norm is called the

Older literature refers to this metric as Pythagorean metric. The technique has been rediscovered numerous times throughout history, as it is a logical extension of the Pythagorean theorem.

## Definition

The Euclidean distance between points $P=\left(p_1,p_2,dots,p_n\right),$ and $Q=\left(q_1,q_2,dots,q_n\right),$, in Euclidean n-space, is defined as:

$sqrt\left\{\left(p_1-q_1\right)^2 + \left(p_2-q_2\right)^2 + cdots + \left(p_n-q_n\right)^2\right\} = sqrt\left\{sum_\left\{i=1\right\}^n \left(p_i-q_i\right)^2\right\}.$

### One-dimensional distance

For two 1D points, $P=\left(p_x\right),$ and $Q=\left(q_x\right),$, the distance is computed as:

$sqrt\left\{\left(p_x-q_x\right)^2\right\} = | p_x-q_x |$

The absolute value signs are used since distance is normally considered to be an unsigned scalar value.

In one dimension, there is a single homogeneous, translation-invariant metric (in other words, a distance that is induced by a norm), up to a scale factor of length, which is the Euclidean distance. In higher dimensions there are other possible norms.

### Two-dimensional distance

For two 2D points, $P=\left(p_x,p_y\right),$ and $Q=\left(q_x,q_y\right),$, the distance is computed as:

$sqrt\left\{\left(p_x-q_x\right)^2 + \left(p_y-q_y\right)^2\right\}$

Alternatively, expressed in circular coordinates (also known as polar coordinates), using $P=\left(r_1, theta_1\right),$ and $Q=\left(r_2, theta_2\right),$, the distance can be computed as:

$sqrt\left\{r_1^2 + r_2^2 - 2 r_1 r_2 cos\left(theta_1 - theta_2\right)\right\}$

### Three-dimensional distance

For two 3D points, $P=\left(p_x,p_y,p_z\right),$ and $Q=\left(q_x,q_y,q_z\right),$, the distance is computed as

$sqrt\left\{\left(p_x-q_x\right)^2 + \left(p_y-q_y\right)^2+\left(p_z-q_z\right)^2\right\}.$

### N-dimensional distance

For two N-D points, $P=\left(p_1,p_2,...,p_n\right),$ and $Q=\left(q_1,q_2,...,q_n\right),$, the distance is computed as

$sqrt\left\{\left(p_1-q_1\right)^2 + \left(p_2-q_2\right)^2+...+\left(p_n-q_n\right)^2\right\}.$