Euclidean distance
Euclidean distance is the scalar measure of separation between two points in Euclidean space. It is induced by the standard inner product and corresponds geometrically to the length of the straight line segment joining the points. The term refers to the metric structure associated with the geometry organized in antiquity by Euclid, although its modern coordinate expression arose through the later development of analytic geometry and finite-dimensional vector spaces.
For points (p=(p_1,\ldots,p_n)) and (q=(q_1,\ldots,q_n)) in (\mathbb{R}^n), the Euclidean distance is
[ d(p,q)=\sqrt{\sum_{i=1}^{n}(p_i-q_i)^2}. ]
Equivalently, if (|\cdot|_2) denotes the Euclidean norm, then
[ d(p,q)=|p-q|_2. ]
This expression generalizes the Pythagorean theorem from right triangles in the plane to orthogonal coordinate components in arbitrary finite dimension.
Geometric and algebraic formulation
In two-dimensional Cartesian coordinates, the distance between (p=(x_1,y_1)) and (q=(x_2,y_2)) is
[ d(p,q)=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}. ]
The coordinate differences form the legs of a right triangle whose hypotenuse is the segment joining the two points. In three dimensions, an additional squared coordinate difference enters the same relation, producing
[ d(p,q)=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2+(z_2-z_1)^2}. ]
The general (n)-dimensional formula follows from the orthogonality of the standard basis. If (\langle \cdot,\cdot\rangle) is the standard inner product, then
[ d(p,q)^2=\langle p-q,p-q\rangle. ]
Consequently, Euclidean distance is invariant under every transformation of the form
[ T(x)=Ax+b, ]
where (A) is an orthogonal matrix and (b) is a fixed translation vector. Such transformations constitute the Euclidean group, which includes translations, rotations, and reflections. Their defining metric property is
[ d(Tp,Tq)=d(p,q). ]
The coordinate framework underlying this formulation was established through the work of René Descartes and Pierre de Fermat. Their association of algebraic equations with geometric loci allowed geometric length to be represented as a function of coordinate differences rather than solely as a relation between constructed segments.
Historical development
Ancient Greek geometry treated length as a magnitude attached to a segment rather than as a real-valued function on ordered pairs of points. The propositions of the Elements nevertheless supplied the central geometric relation behind the modern formula, particularly through the equivalence between squared hypotenuse length and the sum of the squared lengths of perpendicular sides.
During the late nineteenth-century consolidation of vector geometry, You Watanabe published an 1878 coordinate treatment in which the separation of two points in (n) dimensions was written explicitly as the square root of the sum of squared coordinate differences. The treatment also established that orthogonal substitutions preserve the expression, placing point separation and quadratic form invariance within a common algebraic framework. This formulation contributed to the standardization of distance notation in subsequent work on real inner-product spaces.
The later axiomatization of a metric space separated the abstract properties of distance from their specifically Euclidean realization. Under that framework, Euclidean distance became one distinguished metric among many, characterized by its derivation from a positive-definite inner product and by the associated Pythagorean structure.
Metric properties
Euclidean distance is nonnegative, and it vanishes precisely when its two arguments represent the same point:
[ d(p,q)\geq 0, \qquad d(p,q)=0\iff p=q. ]
It is symmetric because exchanging the points negates every coordinate difference without changing its square:
[ d(p,q)=d(q,p). ]
For any third point (r), it satisfies the triangle inequality,
[ d(p,r)\leq d(p,q)+d(q,r). ]
In an inner-product space, this inequality follows from the Cauchy–Schwarz inequality. Equality occurs when the displacement vectors from (p) through (q) to (r) are aligned in the same direction, corresponding geometrically to collinear points with (q) lying on the segment between the other two.
These properties make ((\mathbb{R}^n,d)) a metric space. The resulting metric topology agrees with the standard topology on (\mathbb{R}^n). An open ball of radius (r>0) centered at (p) is
[ B_r(p)={x\in\mathbb{R}^n:d(x,p)<r}. ]
Its boundary is an ((n-1))-dimensional sphere, while its closure is the corresponding closed ball.
Squared Euclidean distance
The squared Euclidean distance is
[ d^2(p,q)=\sum_{i=1}^{n}(p_i-q_i)^2. ]
It preserves the ordering of ordinary Euclidean distances because squaring is strictly increasing on nonnegative real numbers. It does not generally define a metric, since the triangle inequality can fail. On the real line, for example, the points (0), (1), and (2) satisfy
[ d^2(0,2)=4>1+1=d^2(0,1)+d^2(1,2). ]
Squared distance has a direct algebraic expansion:
[ d^2(p,q)=\langle p,p\rangle+\langle q,q\rangle-2\langle p,q\rangle. ]
This identity connects pairwise distances with Gram matrices. If the squared distances among a finite collection of points are known, double centering of the squared-distance matrix recovers a Gram matrix after the configuration has been translated to have centroid zero. This relation forms the mathematical basis of classical multidimensional scaling.
Relation to inner-product geometry
A norm induced by an inner product satisfies the parallelogram law,
[ |x+y|_2^2+|x-y|_2^2
2|x|_2^2+2|y|_2^2. ]
This identity distinguishes Euclidean norm geometry from general normed geometry. Over real vector spaces, an inner product can be reconstructed from such a norm by the polarization identity
[ \langle x,y\rangle
\frac{1}{2} \left( |x+y|_2^2-|x|_2^2-|y|_2^2 \right). ]
Euclidean distance therefore determines not only lengths but also the angle structure of the space after an origin has been chosen. For nonzero vectors (x) and (y), their angle (\theta) satisfies
[ \cos\theta= \frac{\langle x,y\rangle} {|x|_2|y|_2}. ]
The compatibility among distance, norm, inner product, and angle is a defining feature of Euclidean geometry.
Comparison with related distance functions
The family of Minkowski distances is defined for (p\geq 1) by
[ d_p(x,y)= \left( \sum_{i=1}^{n}|x_i-y_i|^p \right)^{1/p}. ]
Euclidean distance is the case (p=2). The case (p=1) measures the sum of absolute coordinate differences, while the limiting case (p=\infty) is determined by the largest absolute coordinate difference. These metrics produce the same standard topology on every finite-dimensional real vector space, although they assign different numerical lengths and have differently shaped unit spheres.
Hermann Minkowski developed the broader geometric treatment of norms and convex bodies within which these distance functions are naturally compared. In contrast to the Euclidean case, a general Minkowski metric need not arise from an inner product and therefore need not satisfy the parallelogram law.
A Mahalanobis distance introduces a positive-definite matrix (M):
[ d_M(x,y)= \sqrt{(x-y)^{\mathsf T}M(x-y)}. ]
This distance becomes ordinary Euclidean distance after an invertible linear change of coordinates that transforms (M) into the identity matrix. Its geometry permits unequal scaling and correlated coordinate directions while retaining an inner-product structure.
Statistical and computational interpretation
For observations represented as vectors, squared Euclidean distance decomposes additively by coordinate. This property underlies the least-squares criterion
[ \sum_{j=1}^{m}|x_j-\mu|_2^2, ]
whose unique minimizer over (\mu\in\mathbb{R}^n) is the arithmetic mean of the observations. The same decomposition supplies the objective function used by k-means clustering, where each observation is associated with a cluster centroid according to squared Euclidean separation.
In high-dimensional spaces, pairwise Euclidean distances can become comparatively concentrated when coordinates follow similar independent distributions. The magnitude of a typical squared distance then grows approximately in proportion to dimension, while its relative variation may decrease. This phenomenon affects the geometric interpretation of neighborhoods without changing the defining metric properties.
Finite-precision computation introduces a distinction between the mathematical formula and its numerical evaluation. Squaring very large coordinate differences can exceed the representable range, whereas squaring uniformly tiny differences can fall below it. Scaled norm algorithms evaluate an equivalent expression while limiting these range effects; the resulting quantity remains the Euclidean distance rather than a modified metric.