Distance Matrices
Sometimes the data is not the points themselves but the distances between them: a table of pairwise separations, with no coordinates attached. A distance matrix records those separations, and the question is whether a set of points realizing them exists and how to recover it. The answer is a clean piece of linear algebra. A short matrix identity converts squared distances into inner products, and the SVD reads the coordinates off the resulting Gram matrix. The companion problem, aligning two known configurations, is solved by the same decomposition.
From distances to inner products
Section titled “From distances to inner products”Let be unknown points and suppose we are given only the squared distances . Expanding the square ties each distance to inner products:
The cross term is exactly the entry of the Gram matrix , where stacks the points as rows. The diagonal terms depend only on the origin, which the distances cannot fix; translating all points leaves unchanged. Pinning the origin at the centroid, , removes that freedom and lets us solve for .
Recovering the points: classical scaling
Section titled “Recovering the points: classical scaling”Once is known it is symmetric positive semidefinite, and its eigendecomposition hands back the coordinates. Write with eigenvalues . Then
realizes the distances, and the number of nonzero eigenvalues is the smallest dimension in which the points embed exactly. Keeping only the largest few eigenvalues gives the best low-dimensional embedding, by Eckart–Young applied to ; this is classical multidimensional scaling, the standard way to place points in the plane from a table of dissimilarities.
The pipeline: squared distances , double centered to the Gram matrix , then eigendecomposed to coordinates . The reconstruction is fixed only up to a rigid motion.
The construction also answers the existence question exactly.
The Procrustes problem: aligning two configurations
Section titled “The Procrustes problem: aligning two configurations”Distances determine points only up to a rigid motion: rotating, reflecting, or translating every point preserves every pairwise distance. So two reconstructions of the same data, or two measured configurations of corresponding points, will in general be misaligned by an orthogonal transformation. Finding the best one to bring them into register is the orthogonal Procrustes problem.
The maximum value is the nuclear norm of , and is the orthogonal matrix nearest to . If a proper rotation is required, , and the SVD returns a reflection, the standard fix is to negate the column of belonging to the smallest singular value, which costs the least in the objective.
Drag either point set below. The widget forms , takes its SVD, and rotates the movable set by to land as close as possible on the fixed set; the residual is the Procrustes distance between the two shapes.
Distance matrices and Procrustes alignment are the geometric face of the SVD: one recovers a configuration from its internal distances, the other matches two configurations across an orthogonal ambiguity, and both are solved by reading singular values and vectors off a single small matrix.