Gram matrix

In linear algebra, the Gram matrix (or Gramian matrix, Gramian) of a set of vectors formula_1 in an inner product space is the Hermitian matrix of inner products, whose entries are given by the inner product formula_2. If the vectors formula_1 are the columns of matrix formula_4 then the Gram matrix is formula_5 in the general case that the vector coordinates are complex numbers, which simplifies to formula_6 for the case that the vector coordinates are real numbers. 
An important application is to compute linear independence: a set of vectors are linearly independent if and only if the Gram determinant (the determinant of the Gram matrix) is non-zero.
It is named after Jørgen Pedersen Gram.
Examples.
For finite-dimensional real vectors in formula_7 with the usual Euclidean dot product, the Gram matrix is formula_8, where formula_9 is a matrix whose columns are the vectors formula_10 and formula_11 is its transpose whose rows are the vectors formula_12. For complex vectors in formula_13, formula_14, where formula_15 is the conjugate transpose of formula_9.
Given square-integrable functions formula_17 on the interval formula_18, the Gram matrix formula_19 is:
where formula_21 is the complex conjugate of formula_22.
For any bilinear form formula_23 on a finite-dimensional vector space over any field we can define a Gram matrix formula_24 attached to a set of vectors formula_25 by formula_26. The matrix will be symmetric if the bilinear form formula_23 is symmetric.
Properties.
Positive-semidefiniteness.
The Gram matrix is symmetric in the case the real product is real-valued; it is Hermitian in the general, complex case by definition of an inner product.
The Gram matrix is positive semidefinite, and every positive semidefinite matrix is the Gramian matrix for some set of vectors. The fact that the Gramian matrix is positive-semidefinite can be seen from the following simple derivation:
The first equality follows from the definition of matrix multiplication, the second and third from the bi-linearity of the inner-product, and the last from the positive definiteness of the inner product.
Note that this also shows that the Gramian matrix is positive definite if and only if the vectors formula_38 are linearly independent (that is, formula_39 for all formula_40).
Finding a vector realization.
Given any positive semidefinite matrix formula_32, one can decompose it as:
where formula_43 is the conjugate transpose of formula_23 (or formula_45 in the real case).
Here formula_23 is a formula_47 matrix, where formula_28 is the rank of formula_32. Various ways to obtain such a decomposition include computing the Cholesky decomposition or taking the non-negative square root of formula_32.
The columns formula_51 of formula_23 can be seen as "n" vectors in formula_53 (or "k"-dimensional Euclidean space formula_54, in the real case). Then
where the dot product formula_56 is the usual inner product on formula_53.
Thus a Hermitian matrix formula_32 is positive semidefinite if and only if it is the Gram matrix of some vectors formula_51. Such vectors are called a vector realization of The infinite-dimensional analog of this statement is Mercer's theorem.
Uniqueness of vector realizations.
If formula_32 is the Gram matrix of vectors formula_61 in formula_54 then applying any rotation or reflection of formula_54 (any orthogonal transformation, that is, any Euclidean isometry preserving 0) to the sequence of vectors results in the same Gram matrix. That is, for any formula_64 orthogonal matrix formula_65, the Gram matrix of formula_66 is also 
This is the only way in which two real vector realizations of formula_32 can differ: the vectors formula_61 are unique up to orthogonal transformations. In other words, the dot products formula_69 and formula_70 are equal if and only if some rigid transformation of formula_54 transforms the vectors formula_61 to formula_73 and 0 to 0.
The same holds in the complex case, with unitary transformations in place of orthogonal ones.
That is, if the Gram matrix of vectors formula_25 is equal to the Gram matrix of vectors formula_73 in formula_53 then there is a unitary formula_64 matrix formula_78 (meaning formula_79) such that formula_80 for formula_81.
Gram determinant.
The Gram determinant or Gramian is the determinant of the Gram matrix:
formula_88
If formula_25 are vectors in formula_90 then it is the square of the "n"-dimensional volume of the parallelotope formed by the vectors. In particular, the vectors are linearly independent if and only if the parallelotope has nonzero "n"-dimensional volume, if and only if Gram determinant is nonzero, if and only if the Gram matrix is nonsingular. When the determinant and volume are zero. When , this reduces to the standard theorem that the absolute value of the determinant of "n" "n"-dimensional vectors is the "n"-dimensional volume. The Gram determinant is also useful for computing the volume of the simplex formed by the vectors; its volume is .
The Gram determinant can also be expressed in terms of the exterior product of vectors by
When the vectors formula_92 are defined from the positions of points formula_93 relative to some reference point formula_94,
then the Gram determinant can be written as the difference of two Gram determinants,
where each formula_97 is the corresponding point formula_98 supplemented with the coordinate value of 1 for an formula_99-st dimension. Note that in the common case that , the second term on the right-hand side will be zero.
Constructing an orthonormal basis.
Given a set of linearly independent vectors formula_100 with Gram matrix formula_101, one can construct an orthonormal basis
The positive definite matrix formula_103 is guaranteed to exist because, as mentioned above, the formula_104 are linearly independent if and only if G is invertible and hence is positive definite (not just semidefinite). The inverse formula_105 of positive definite matrix G is unique and also positive definite and thus has a unique positive definite square root formula_106. One can check that these new vectors are orthonormal: