# 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. If A is a Euclidean distance matrix and the points ${\displaystyle x_{1},x_{2},\ldots ,x_{n}}$ are defined on m-dimensional space, then the elements of A are given by

{\displaystyle {\begin{aligned}A&=(a_{ij});\\a_{ij}&=d_{ij}^{2}\;=\;\lVert x_{i}-x_{j}\rVert _{2}^{2}\end{aligned}}}

where ||.||2 denotes the 2-norm on Rm.

${\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}}}$

## Properties

Simply put, the element ${\displaystyle a_{ij}}$ describes the square of the distance between the i th and j th points in the set. By the properties of the 2-norm (or indeed, Euclidean distance in general), the matrix A has the following properties.

• All elements on the diagonal of A are zero (i.e. it is a hollow matrix).
• The trace of A is zero (by the above property).
• A is symmetric (i.e. ${\displaystyle a_{ij}=a_{ji}}$).
• ${\displaystyle {\sqrt {a_{ij}}}\leq {\sqrt {a_{ik}}}+{\sqrt {a_{kj}}}}$ (by the triangle inequality)
• ${\displaystyle a_{ij}\geq 0}$
• The number of unique (distinct) non-zero values within an n-by-n Euclidean distance matrix is bounded above by ${\displaystyle n(n-1)/2}$ due to the matrix being symmetric and hollow.
• In dimension m, a Euclidean distance matrix has rank less than or equal to m+2. If the points ${\displaystyle x_{1},x_{2},\ldots ,x_{n}}$ are in general position, the rank is exactly min(n, m + 2).