Euclidean distance matrix
In mathematics, a Euclidean distance matrix is an n×n matrix representing the spacing of a set of n points in Euclidean space. For points [math]\displaystyle{ x_1,x_2,\ldots,x_n }[/math] in kdimensional space ℝ^{k}, the elements of their Euclidean distance matrix A are given by squares of distances between them. That is
 [math]\displaystyle{ \begin{align} A & = (a_{ij}); \\ a_{ij} & = d_{ij}^2 \;=\; \lVert x_i  x_j\rVert^2 \end{align} }[/math]
where [math]\displaystyle{ \\cdot\ }[/math] denotes the Euclidean norm on ℝ^{k}.
 [math]\displaystyle{ A = \begin{bmatrix} 0 & d_{12}^2 & d_{13}^2 & \dots & d_{1n}^2 \\ d_{21}^2 & 0 & d_{23}^2 & \dots & d_{2n}^2 \\ d_{31}^2 & d_{32}^2 & 0 & \dots & d_{3n}^2 \\ \vdots&\vdots & \vdots & \ddots&\vdots& \\ d_{n1}^2 & d_{n2}^2 & d_{n3}^2 & \dots & 0 \\ \end{bmatrix} }[/math]
In the context of (not necessarily Euclidean) distance matrices, the entries are usually defined directly as distances, not their squares. However, in the Euclidean case, squares of distances are used to avoid computing square roots and to simplify relevant theorems and algorithms.
Euclidean distance matrices are closely related to Gram matrices (matrices of dot products, describing norms of vectors and angles between them). The latter are easily analyzed using methods of linear algebra. This allows to characterize Euclidean distance matrices and recover the points [math]\displaystyle{ x_1,x_2,\ldots,x_n }[/math] that realize it. A realization, if it exists, is unique up to rigid transformations, i.e. distancepreserving transformations of Euclidean space (rotations, reflections, translations).
In practical applications, distances are noisy measurements or come from arbitrary dissimilarity estimates (not necessarily metric). The goal may be to visualize such data by points in Euclidean space whose distance matrix approximates a given dissimilarity matrix as well as possible — this is known as multidimensional scaling. Alternatively, given two sets of data already represented by points in Euclidean space, one may ask how similar they are in shape, that is, how closely can they be related by a distancepreserving transformation — this is Procrustes analysis. Some of the distances may also be missing or come unlabelled (as an unordered set or multiset instead of a matrix), leading to more complex algorithmic tasks, such as the graph realization problem or the turnpike problem (for points on a line).^{[1]}^{[2]}
Properties
By the fact that Euclidean distance is a metric, the matrix A has the following properties.
 All elements on the diagonal of A are zero (i.e. it is a hollow matrix); hence the trace of A is zero.
 A is symmetric (i.e. [math]\displaystyle{ a_{ij} = a_{ji} }[/math]).
 [math]\displaystyle{ \sqrt{a_{ij}} \le \sqrt{a_{ik}} + \sqrt{a_{kj}} }[/math] (by the triangle inequality)
 [math]\displaystyle{ a_{ij}\ge 0 }[/math]
In dimension k, a Euclidean distance matrix has rank less than or equal to k+2. If the points [math]\displaystyle{ x_1,x_2,\ldots,x_n }[/math] are in general position, the rank is exactly min(n, k + 2).
Distances can be shrunk by any power to obtain another Euclidean distance matrix. That is, if [math]\displaystyle{ A=(a_{ij}) }[/math] is a Euclidean distance matrix, then [math]\displaystyle{ ({a_{ij}}^s) }[/math] is a Euclidean distance matrix for every 0<s<1.^{[3]}
Relation to Gram matrix
The Gram matrix of a sequence of points [math]\displaystyle{ x_1,x_2,\ldots,x_n }[/math] in kdimensional space ℝ^{k} is the n×n matrix [math]\displaystyle{ G = (g_{ij}) }[/math] of their dot products (here a point [math]\displaystyle{ x_i }[/math] is thought of as a vector from 0 to that point):
 [math]\displaystyle{ g_{ij} = x_i \cdot x_j = \x_i\ \x_j\ \cos \theta }[/math], where [math]\displaystyle{ \theta }[/math] is the angle between the vector [math]\displaystyle{ x_i }[/math] and [math]\displaystyle{ x_j }[/math].
In particular
 [math]\displaystyle{ g_{ii} = \x_i\^2 }[/math] is the square of the distance of [math]\displaystyle{ x_i }[/math] from 0.
Thus the Gram matrix describes norms and angles of vectors (from 0 to) [math]\displaystyle{ x_1,x_2,\ldots,x_n }[/math].
Let [math]\displaystyle{ X }[/math] be the k×n matrix containing [math]\displaystyle{ x_1,x_2,\ldots,x_n }[/math] as columns. Then
 [math]\displaystyle{ G = X^\textsf{T} X }[/math], because [math]\displaystyle{ g_{ij} = x_i^\textsf{T} x_j }[/math] (seeing [math]\displaystyle{ x_i }[/math] as a column vector).
Matrices that can be decomposed as [math]\displaystyle{ X^\textsf{T}X }[/math], that is, Gram matrices of some sequence of vectors (columns of [math]\displaystyle{ X }[/math]), are well understood — these are precisely positive semidefinite matrices.
To relate the Euclidean distance matrix to the Gram matrix, observe that
 [math]\displaystyle{ d_{ij}^2 = \x_i  x_j\^2 = (x_i  x_j)^\textsf{T} (x_i  x_j) = x_i^\textsf{T} x_i  2x_i^\textsf{T} x_j + x_j^\textsf{T} x_j = g_{ii} 2g_{ij} + g_{jj} }[/math]
That is, the norms and angles determine the distances. Note that the Gram matrix contains additional information: distances from 0.
Conversely, distances [math]\displaystyle{ d_{ij} }[/math] between pairs of n+1 points [math]\displaystyle{ x_0,x_1,\ldots,x_n }[/math] determine dot products between n vectors [math]\displaystyle{ x_ix_0 }[/math] (1≤i≤n):
 [math]\displaystyle{ g_{ij} = (x_ix_0) \cdot (x_jx_0) = \frac{1}{2}\left(\x_ix_0\^2 + \x_jx_0\^2  \x_i  x_j\^2 \right) = \frac{1}{2}(d_{0i}^2 + d_{0j}^2  d_{ij}^2) }[/math]
(this is known as the polarization identity).
Characterizations
For a n×n matrix A, a sequence of points [math]\displaystyle{ x_1,x_2,\ldots,x_n }[/math] in kdimensional Euclidean space ℝ^{k} is called a realization of A in ℝ^{k} if A is their Euclidean distance matrix. One can assume without loss of generality that [math]\displaystyle{ x_1 = \mathbf{0} }[/math] (because translating by [math]\displaystyle{ x_1 }[/math] preserves distances).
Theorem^{[4]} (Schoenberg criterion,^{[5]} independently shown by Young & Householder^{[6]}) — A symmetric hollow n×n matrix A with real entries admits a realization in ℝ^{k} if and only if the (n1)×(n1) matrix [math]\displaystyle{ G = (g_{ij})_{2 \leq i,j \leq n} }[/math] defined by
 [math]\displaystyle{ g_{ij} = \frac{1}{2}(a_{1i}^2 + a_{1j}^2  a_{ij}^2) }[/math]
is positive semidefinite and has rank at most k.
This follows from the previous discussion because G is positive semidefinite of rank at most k if and only if it can be decomposed as [math]\displaystyle{ G = X^\textsf{T} X }[/math] where X is a k×n matrix.^{[7]} Moreover, the columns of X give a realization in ℝ^{k}. Therefore, any method to decompose G allows to find a realization. The two main approaches are variants of Cholesky decomposition or using spectral decompositions to find the principal square root of G, see Definite matrix.
The statement of theorem distinguishes the first point [math]\displaystyle{ x_1 }[/math]. A more symmetric variant of the same theorem is the following:
Corollary^{[8]} — A symmetric hollow n×n matrix A with real entries admits a realization if and only if A is negative semidefinite on the hyperplane [math]\displaystyle{ H=\{v \in \mathbf{R}^n \colon e^\textsf{T}v = 0\} }[/math], that is
 [math]\displaystyle{ v^\textsf{T} A v \leq 0 }[/math] for all [math]\displaystyle{ v \in \mathbf{R}^n }[/math] such that [math]\displaystyle{ \textstyle\sum_{i=1}^n v_i = 0 }[/math].
Other characterizations involve Cayley–Menger determinants. In particular, these allow to show that a symmetric hollow n×n matrix is realizable in ℝ^{k} if and only if every (k+3)×(k+3) principal submatrix is. In other words, a semimetric on finitely many points is embedabble isometrically in ℝ^{k} if and only if every k+3 points are.^{[9]}
In practice, the definiteness or rank conditions may fail due to numerical errors, noise in measurements, or due to the data not coming from actual Euclidean distances. Points that realize optimally similar distances can then be found by semidefinite approximation (and low rank approximation, if desired) using linear algebraic tools such as singular value decomposition or semidefinite programming. This is known as multidimensional scaling. Variants of these methods can also deal with incomplete distance data.
Unlabeled data, that is, a set or multiset of distances not assigned to particular pairs, is much more difficult to deal with. Such data arises, for example, in DNA sequencing (specifically, genome recovery from partial digest) or phase retrieval. Two sets of points are called homometric if they have the same multiset of distances (but are not necessarily related by a rigid transformation). Deciding whether a given multiset of n(n1)/2 distances can be realized in a given dimension k is strongly NPhard. In one dimension this is known as the turnpike problem; it is an open question whether it can be solved in polynomial time. When the multiset of distances is given with error bars, even the one dimensional case is NPhard. Nevertheless, practical algorithms exist for many cases, e.g. random points.^{[10]}^{[11]}^{[12]}
Uniqueness of representations
Given a Euclidean distance matrix, the sequence of points that realize it is unique up to rigid transformations – these are isometries of Euclidean space: rotations, reflections, translations, and their compositions.^{[1]}
Theorem — Let [math]\displaystyle{ x_1,x_2,\ldots,x_n }[/math] and [math]\displaystyle{ y_1,y_2,\ldots,y_n }[/math] be two sequences of points in kdimensional Euclidean space ℝ^{k}. The distances [math]\displaystyle{ \x_ix_j\ }[/math] and [math]\displaystyle{ \y_iy_j\ }[/math] are equal (for all 1≤i,j≤n) if and only if there is a rigid transformation of ℝ^{k} mapping [math]\displaystyle{ x_i }[/math] to [math]\displaystyle{ y_i }[/math] (for all 1≤i≤n).
Proof


Rigid transformations preserve distances so one direction is clear. Suppose the distances [math]\displaystyle{ \x_ix_j\ }[/math] and [math]\displaystyle{ \y_iy_j\ }[/math] are equal. Without loss of generality we can assume [math]\displaystyle{ x_1=y_1=\textbf{0} }[/math] by translating the points by [math]\displaystyle{ x_1 }[/math] and [math]\displaystyle{ y_1 }[/math], respectively. Then the (n1)×(n1) Gram matrix of remaining vectors [math]\displaystyle{ x_i=x_ix_1 }[/math] is identical to the Gram matrix of vectors [math]\displaystyle{ y_i }[/math] (2≤i≤n). That is, [math]\displaystyle{ X^\textsf{T} X = Y^\textsf{T} Y }[/math], where X and Y are the k×(n1) matrices containing the respective vectors as columns. This implies there exists an orthogonal k×k matrix Q such that QX=Y, see Definite symmetric matrix. Q describes an orthogonal transformation of ℝ^{k} (a composition of rotations and reflections, without translations) which maps [math]\displaystyle{ x_i }[/math] to [math]\displaystyle{ y_i }[/math] (and 0 to 0). The final rigid transformation is described by [math]\displaystyle{ T(x) = Q(xx_1)+y_1 }[/math]. 
In applications, when distances don't match exactly, Procrustes analysis aims to relate two point sets as close as possible via rigid transformations, usually using singular value decomposition.
The ordinary Euclidean case is known as the orthogonal Procrustes problem or Wahba's problem (when observations are weighted to account for varying uncertainties).
Examples of applications include determining orientations of satellites, comparing molecule structure (in cheminformatics), protein structure (structural alignment in bioinformatics), or bone structure (statistical shape analysis in biology).
See also
 Adjacency matrix
 Coplanarity
 Distance geometry
 Hollow matrix
 Distance matrix
 Euclidean random matrix
 Classical multidimensional scaling, a visualization technique that approximates an arbitrary dissimilarity matrix by a Euclidean distance matrix
 Cayley–Menger determinant
 Semidefinite embedding
Notes
 ↑ ^{1.0} ^{1.1} (Dokmanic Parhizkar)
 ↑ (So 2007)
 ↑ Maehara, Hiroshi (2013). "Euclidean embeddings of finite metric spaces" (in en). Discrete Mathematics 313 (23): 2848–2856. doi:10.1016/j.disc.2013.08.029. ISSN 0012365X. Theorem 2.6
 ↑ (So 2007), Theorem 3.3.1, p. 40
 ↑ Schoenberg, I. J. (1935). "Remarks to Maurice Fréchet's Article "Sur La Definition Axiomatique D'Une Classe D'Espace Distances Vectoriellement Applicable Sur L'Espace De Hilbert"". Annals of Mathematics 36 (3): 724–732. doi:10.2307/1968654. ISSN 0003486X.
 ↑ Young, Gale; Householder, A. S. (19380301). "Discussion of a set of points in terms of their mutual distances" (in en). Psychometrika 3 (1): 19–22. doi:10.1007/BF02287916. ISSN 18600980.
 ↑ (So 2007), Theorem 2.2.1, p. 10
 ↑ (So 2007), Corollary 3.3.3, p. 42
 ↑ Menger, Karl (1931). "New Foundation of Euclidean Geometry". American Journal of Mathematics 53 (4): 721–745. doi:10.2307/2371222.
 ↑ Lemke, Paul; Skiena, Steven S.; Smith, Warren D. (2003). "Reconstructing Sets From Interpoint Distances". in Aronov, Boris. Discrete and Computational Geometry. 25. Berlin, Heidelberg: Springer Berlin Heidelberg. pp. 597–631. doi:10.1007/9783642555664_27. ISBN 9783642624421.
 ↑ Huang, Shuai; Dokmanić, Ivan (2021). "Reconstructing Point Sets from Distance Distributions". IEEE Transactions on Signal Processing 69: 1811–1827. doi:10.1109/TSP.2021.3063458.
 ↑ Jaganathan, Kishore; Hassibi, Babak (2012). "Reconstruction of Integers from Pairwise Distances". arXiv:1212.2386 [cs.DM].
References
 Dokmanic, Ivan; Parhizkar, Reza; Ranieri, Juri; Vetterli, Martin (2015). "Euclidean Distance Matrices: Essential theory, algorithms, and applications". IEEE Signal Processing Magazine 32 (6): 12–30. doi:10.1109/MSP.2015.2398954. ISSN 15580792.
 James E. Gentle (2007). Matrix Algebra: Theory, Computations, and Applications in Statistics. SpringerVerlag. p. 299. ISBN 9780387708720. https://books.google.com/books?id=PDjIV0iWa2cC.
 So, Anthony ManCho (2007). A Semidefinite Programming Approach to the Graph Realization Problem: Theory, Applications and Extensions (PDF) (PhD).
 Liberti, Leo; Lavor, Carlile; Maculan, Nelson; Mucherino, Antonio (2014). "Euclidean Distance Geometry and Applications" (in en). SIAM Review 56 (1): 3–69. doi:10.1137/120875909. ISSN 00361445.
 Alfakih, Abdo Y. (2018) (in en). Euclidean Distance Matrices and Their Applications in Rigidity Theory. Cham: Springer International Publishing. doi:10.1007/9783319978468. ISBN 9783319978451.
Original source: https://en.wikipedia.org/wiki/Euclidean distance matrix.
Read more 