# Gramian matrix

(Redirected from Gram matrix)

In linear algebra, the Gram matrix (Gramian matrix or Gramian) of a set of vectors ${\displaystyle v_{1},\dots ,v_{n}}$ in an inner product space is the Hermitian matrix of inner products, whose entries are given by ${\displaystyle G_{ij}=\langle v_{i},v_{j}\rangle }$.[1]

An important application is to compute linear independence: a set of vectors is 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 with the usual Euclidean dot product, the Gram matrix is simply ${\displaystyle G=V^{\mathrm {T} }V}$ (or ${\displaystyle G=V^{*}V}$ for complex vectors using the conjugate transpose), where V is a matrix whose columns are the vectors ${\displaystyle v_{k}}$.

Most commonly, the vectors are elements of a Euclidean space, or are functions in an L2 space, such as continuous functions on a compact interval [ab] (which are a subspace of L 2([ab])).

Given real-valued functions ${\displaystyle \{\ell _{i}(\cdot ),\,i=1,\dots ,n\}}$ on the interval ${\displaystyle [t_{0},t_{f}]}$, the Gram matrix ${\displaystyle G=[G_{ij}]}$, is given by the standard inner product on functions:

${\displaystyle G_{ij}=\int _{t_{0}}^{t_{f}}\ell _{i}(\tau ){\bar {\ell _{j}}}(\tau )\,d\tau .}$

For a general bilinear form B on a finite-dimensional vector space over any field we can define a Gram matrix G attached to a set of vectors ${\displaystyle v_{1},\dots ,v_{n}}$ by ${\displaystyle G_{ij}=B(v_{i},v_{j})\,}$. The matrix will be symmetric if the bilinear form B is symmetric.

## Properties

### Positive semidefinite

The Gramian matrix is positive semidefinite, and every positive symmetric semidefinite matrix is the Gramian matrix for some set of vectors. Further, in finite-dimensions it determines the vectors up to isomorphism, i.e. any two sets of vectors with the same Gramian matrix must be related by a single unitary matrix. These facts follow from taking the spectral decomposition of any positive semidefinite matrix P, so that ${\displaystyle P=UDU^{*}=(U{\sqrt {D}})(U{\sqrt {D}})^{*}}$ and so P is the Gramian matrix of the columns of ${\displaystyle U{\sqrt {D}}}$. The Gramian matrix of any orthonormal basis is the identity matrix. The infinite-dimensional analog of this statement is Mercer's theorem.

### Change of basis

Under change of basis represented by an invertible matrix P, the Gram matrix will change by a matrix congruence to PTGP.

## Gram determinant

The Gram determinant or Gramian is the determinant of the Gram matrix:

${\displaystyle G(x_{1},\dots ,x_{n})={\begin{vmatrix}\langle x_{1},x_{1}\rangle &\langle x_{1},x_{2}\rangle &\dots &\langle x_{1},x_{n}\rangle \\\langle x_{2},x_{1}\rangle &\langle x_{2},x_{2}\rangle &\dots &\langle x_{2},x_{n}\rangle \\\vdots &\vdots &\ddots &\vdots \\\langle x_{n},x_{1}\rangle &\langle x_{n},x_{2}\rangle &\dots &\langle x_{n},x_{n}\rangle \end{vmatrix}}.}$

Geometrically, the Gram determinant is the square of the volume of the parallelotope formed by the vectors. In particular, the vectors are linearly independent if and only if the Gram determinant is nonzero (if and only if the Gram matrix is nonsingular).

The Gram determinant can also be expressed in terms of the exterior product of vectors by

${\displaystyle G(x_{1},\dots ,x_{n})=\|x_{1}\wedge \cdots \wedge x_{n}\|^{2}.}$

## References

1. ^ Horn & Johnson 2013, p. 441
Theorem 7.2.10 Let ${\displaystyle v_{1},\ldots ,v_{m}}$ be vectors in an inner product space V with inner product ${\displaystyle \langle {\cdot ,\cdot }\rangle }$ and let ${\displaystyle G=[\langle {v_{j},v_{i}}\rangle ]_{i,j=1}^{m}\in M_{m}}$. Then
(a) G is Hermitian and positive-semidefinite
(b) G is positive-definite if and only if the vectors ${\displaystyle v_{1},\ldots ,v_{m}}$ are linearly-independent.
(c) rank(G)=dimspan${\displaystyle \{v_{1},\ldots ,v_{m}\}}$
2. ^ Lanckriet, G. R. G.; Cristianini, N.; Bartlett, P.; Ghaoui, L. E.; Jordan, M. I. (2004). "Learning the kernel matrix with semidefinite programming". Journal of Machine Learning Research 5: 27–72 [p. 29].