Gram matrix: Difference between revisions

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
 
imported>Quantling
"list" isn't that mathematical a word. Let's use no word at all (or "sequence" or "tuple").
 
Line 1: Line 1:
{{short description|Matrix of inner products of a set of vectors}}
{{short description|Matrix of inner products of vectors}}
In [[linear algebra]], the '''Gram matrix''' (or '''Gramian matrix''', '''Gramian''') of a set of vectors <math>v_1,\dots, v_n</math> in an [[inner product space]] is the [[Hermitian matrix]] of [[inner product]]s, whose entries are given by the [[inner product]] <math>G_{ij} = \left\langle v_i, v_j \right\rangle</math>.<ref name="HJ-7.2.10">{{harvnb|Horn|Johnson|2013|p=441}}, p.441, Theorem 7.2.10</ref> If the vectors <math>v_1,\dots, v_n</math> are the columns of matrix <math>X</math> then the Gram matrix is <math>X^\dagger X</math> in the general case that the vector coordinates are complex numbers, which simplifies to <math>X^\top X</math> for the case that the vector coordinates are real numbers.
In [[linear algebra]], the '''Gram matrix''' (or '''Gramian matrix''', '''Gramian''') of vectors <math>v_1,\dots, v_n</math> in an [[inner product space]] is the [[Hermitian matrix]] of [[inner product]]s, whose entries are given by the [[inner product]] <math>G_{ij} = \left\langle v_i, v_j \right\rangle</math>.<ref name="HJ-7.2.10">{{harvnb|Horn|Johnson|2013|p=441}}, p.441, Theorem 7.2.10</ref> If the vectors <math>v_1,\dots, v_n</math> are the columns of matrix <math>X</math> then the Gram matrix is <math>X^\dagger X</math> in the general case that the vector coordinates are complex numbers, which simplifies to <math>X^\top X</math> 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|Gram determinant]] (the [[determinant]] of the Gram matrix) is non-zero.
An important application is to compute [[linear independence]]: a set of vectors are linearly independent if and only if the [[#Gram determinant|Gram determinant]] (the [[determinant]] of the Gram matrix) is non-zero.
Line 23: Line 23:
* Gramian matrices arise in covariance structure model fitting (see e.g., Jamshidian and Bentler, 1993, Applied Psychological Measurement, Volume 18, pp.&nbsp;79–94).
* Gramian matrices arise in covariance structure model fitting (see e.g., Jamshidian and Bentler, 1993, Applied Psychological Measurement, Volume 18, pp.&nbsp;79–94).
* In the [[finite element method]], the Gram matrix arises from approximating a function from a finite dimensional space; the Gram matrix entries are then the inner products of the basis functions of the finite dimensional subspace.
* In the [[finite element method]], the Gram matrix arises from approximating a function from a finite dimensional space; the Gram matrix entries are then the inner products of the basis functions of the finite dimensional subspace.
* In [[machine learning]], [[kernel function]]s are often represented as Gram matrices.<ref>{{cite journal |last1=Lanckriet |first1=G. R. G. |first2=N. |last2=Cristianini |first3=P. |last3=Bartlett |first4=L. E. |last4=Ghaoui |first5=M. I. |last5=Jordan |title=Learning the kernel matrix with semidefinite programming |journal=Journal of Machine Learning Research |volume=5 |year=2004 |pages=27–72 [p. 29] |url=https://dl.acm.org/citation.cfm?id=894170 }}</ref> (Also see [[kernel principal component analysis|kernel PCA]])
* In [[machine learning]], [[kernel function]]s are often represented as Gram matrices.<ref>{{Cite report |url=https://dl.acm.org/citation.cfm?id=894170 |title=Learning the kernel matrix with semidefinite programming |last=Lanckriet |first=G. R. G. |last2=Cristianini |first2=N. |last3=Bartlett |first3=P. |last4=Ghaoui |first4=L. E. |last5=Jordan |first5=M. I. |year=2004 |volume=5 |pages=27–72 [p. 29] |journal=Journal of Machine Learning Research}}</ref> (Also see [[kernel principal component analysis|kernel PCA]])
* Since the Gram matrix over the reals is a [[symmetric matrix]], it is [[diagonalizable]] and its [[eigenvalues]] are non-negative. The diagonalization of the Gram matrix is the [[singular value decomposition]].
* Since the Gram matrix over the reals is a [[symmetric matrix]], it is [[diagonalizable]] and its [[eigenvalues]] are non-negative. The diagonalization of the Gram matrix is the [[singular value decomposition]].


Line 40: Line 40:


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.
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 <math> v_i </math> are linearly independent (that is, <math display="inline">\sum_i x_i v_i \neq 0</math> for all <math>x</math>).<ref name="HJ-7.2.10"/>
Note that this also shows that the Gramian matrix is positive definite if and only if the vectors <math> v_i </math> are linearly independent (that is, <math display="inline">\sum_i x_i v_i \neq 0</math> for all <math>x</math>).<ref name="HJ-7.2.10" />


===Finding a vector realization===
===Finding a vector realization===
Line 69: Line 69:
* Because <math>G = G^\dagger</math>, it is necessarily the case that <math>G</math> and <math>G^\dagger</math> commute.  That is, a real or complex Gram matrix <math>G</math> is also a [[normal matrix]].
* Because <math>G = G^\dagger</math>, it is necessarily the case that <math>G</math> and <math>G^\dagger</math> commute.  That is, a real or complex Gram matrix <math>G</math> is also a [[normal matrix]].
* The Gram matrix of any [[orthonormal basis]] is the identity matrix.  Equivalently, the Gram matrix of the rows or the columns of a real [[rotation matrix]] is the identity matrix.  Likewise, the Gram matrix of the rows or columns of a [[unitary matrix]] is the identity matrix.
* The Gram matrix of any [[orthonormal basis]] is the identity matrix.  Equivalently, the Gram matrix of the rows or the columns of a real [[rotation matrix]] is the identity matrix.  Likewise, the Gram matrix of the rows or columns of a [[unitary matrix]] is the identity matrix.
* The rank of the Gram matrix of vectors in <math>\mathbb{R}^k</math> or <math>\mathbb{C}^k</math> equals the dimension of the space [[Linear span|spanned]] by these vectors.<ref name="HJ-7.2.10"/>
* The rank of the Gram matrix of vectors in <math>\mathbb{R}^k</math> or <math>\mathbb{C}^k</math> equals the dimension of the space [[Linear span|spanned]] by these vectors.<ref name="HJ-7.2.10" />


==Gram determinant==
==Gram determinant==
Line 84: Line 84:
When <math>v_1, \dots, v_n</math> are linearly independent, the distance between a point <math>x</math> and the linear span of <math>v_1, \dots, v_n</math> is <math>\sqrt{\frac{|G(x,v_1, \dots, v_n)|}{|G(v_1, \dots, v_n)|}}</math>.
When <math>v_1, \dots, v_n</math> are linearly independent, the distance between a point <math>x</math> and the linear span of <math>v_1, \dots, v_n</math> is <math>\sqrt{\frac{|G(x,v_1, \dots, v_n)|}{|G(v_1, \dots, v_n)|}}</math>.


Consider the moment problem: given <math>c_1, \dots, c_n \in \mathbb C</math>, find a vector <math>v</math> such that <math display="inline">\left\langle v, v_i\right\rangle=c_i</math>, for all <math display="inline">1 \leqslant i \leqslant n</math>. There exists a unique solution with minimal norm:<ref>{{Cite journal |last1=Ramon |first1=Garcia, Stephan |last2=Javad |first2=Mashreghi |last3=T. |first3=Ross, William |date=2023-01-30 |title=Operator Theory by Example |url=https://academic.oup.com/book/45766 |journal=OUP Academic |language=en |doi=10.1093/o|doi-broken-date=13 April 2025 }}</ref>{{Pg|page=38}}<math display="block">v=-\frac{1}{G\left(v_1, v_2, \ldots, v_n\right)} \det
Consider the moment problem: given <math>c_1, \dots, c_n \in \mathbb C</math>, find a vector <math>v</math> such that <math display="inline">\left\langle v, v_i\right\rangle=c_i</math>, for all <math display="inline">1 \leqslant i \leqslant n</math>. There exists a unique solution with minimal norm:<ref>{{Cite journal |last=Ramon |first=Garcia, Stephan |last2=Javad |first2=Mashreghi |last3=T. |first3=Ross, William |date=2023-01-30 |title=Operator Theory by Example |url=https://academic.oup.com/book/45766 |journal=OUP Academic |language=en |doi=10.1093/oso/9780192863867.001.0001|url-access=subscription }}</ref>{{Pg|page=38}}<math display="block">v=-\frac{1}{G\left(v_1, v_2, \ldots, v_n\right)} \det
\begin{bmatrix}
\begin{bmatrix}
0 & c_1 & c_2 & \cdots & c_n \\
0 & c_1 & c_2 & \cdots & c_n \\
Line 127: Line 127:
==References==
==References==
{{reflist}}
{{reflist}}
* {{Cite book | last1=Horn | first1=Roger A. | last2=Johnson | first2=Charles R. | title=Matrix Analysis | publisher=[[Cambridge University Press]] | isbn=978-0-521-54823-6 | year=2013 |edition=2nd }}
* {{Cite book |last=Horn |first=Roger A. |title=Matrix Analysis |last2=Johnson |first2=Charles R. |publisher=[[Cambridge University Press]] |year=2013 |isbn=978-0-521-54823-6 |edition=2nd}}


==External links==
==External links==

Latest revision as of 16:16, 17 September 2025

Template:Short description In linear algebra, the Gram matrix (or Gramian matrix, Gramian) of vectors v1,,vn in an inner product space is the Hermitian matrix of inner products, whose entries are given by the inner product Gij=vi,vj.[1] If the vectors v1,,vn are the columns of matrix X then the Gram matrix is XX in the general case that the vector coordinates are complex numbers, which simplifies to XX 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 n with the usual Euclidean dot product, the Gram matrix is G=VV, where V is a matrix whose columns are the vectors vk and V is its transpose whose rows are the vectors vk. For complex vectors in n, G=VV, where V is the conjugate transpose of V.

Given square-integrable functions {i(),i=1,,n} on the interval [t0,tf], the Gram matrix G=[Gij] is:

Gij=t0tfi*(τ)j(τ)dτ.

where i*(τ) is the complex conjugate of i(τ).

For any 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 v1,,vn by Gij=B(vi,vj). The matrix will be symmetric if the bilinear form B is symmetric.

Applications

Properties

Positive-semidefiniteness

The Gram matrix is symmetric in the case the inner 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:

x𝐆x=i,jxi*xjvi,vj=i,jxivi,xjvj=ixivi,jxjvj=ixivi20.

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 vi are linearly independent (that is, ixivi0 for all x).[1]

Finding a vector realization

Script error: No such module "Labelled list hatnote". Given any positive semidefinite matrix M, one can decompose it as:

M=BB,

where B is the conjugate transpose of B (or M=BTB in the real case).

Here B is a k×n matrix, where k is the rank of M. Various ways to obtain such a decomposition include computing the Cholesky decomposition or taking the non-negative square root of M.

The columns b(1),,b(n) of B can be seen as n vectors in k (or k-dimensional Euclidean space k, in the real case). Then

Mij=b(i)b(j)

where the dot product ab==1ka*b is the usual inner product on k.

Thus a Hermitian matrix M is positive semidefinite if and only if it is the Gram matrix of some vectors b(1),,b(n). Such vectors are called a vector realization of M. The infinite-dimensional analog of this statement is Mercer's theorem.

Uniqueness of vector realizations

If M is the Gram matrix of vectors v1,,vn in k then applying any rotation or reflection of k (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 k×k orthogonal matrix Q, the Gram matrix of Qv1,,Qvn is also M.

This is the only way in which two real vector realizations of M can differ: the vectors v1,,vn are unique up to orthogonal transformations. In other words, the dot products vivj and wiwj are equal if and only if some rigid transformation of k transforms the vectors v1,,vn to w1,,wn 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 v1,,vn is equal to the Gram matrix of vectors w1,,wn in k then there is a unitary k×k matrix U (meaning UU=I) such that vi=Uwi for i=1,,n.[3]

Other properties

  • Because G=G, it is necessarily the case that G and G commute. That is, a real or complex Gram matrix G is also a normal matrix.
  • The Gram matrix of any orthonormal basis is the identity matrix. Equivalently, the Gram matrix of the rows or the columns of a real rotation matrix is the identity matrix. Likewise, the Gram matrix of the rows or columns of a unitary matrix is the identity matrix.
  • The rank of the Gram matrix of vectors in k or k equals the dimension of the space spanned by these vectors.[1]

Gram determinant

The Gram determinant or Gramian is the determinant of the Gram matrix: |G(v1,,vn)|=|v1,v1v1,v2v1,vnv2,v1v2,v2v2,vnvn,v1vn,v2vn,vn|.

If v1,,vn are vectors in m 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 n > m the determinant and volume are zero. When n = m, this reduces to the standard theorem that the absolute value of the determinant of n n-dimensional vectors is the n-dimensional volume. The volume of the simplex formed by the vectors is Volume(parallelotope) / n!Script error: No such module "Check for unknown parameters"..

When v1,,vn are linearly independent, the distance between a point x and the linear span of v1,,vn is |G(x,v1,,vn)||G(v1,,vn)|.

Consider the moment problem: given c1,,cn, find a vector v such that v,vi=ci, for all 1in. There exists a unique solution with minimal norm:[4]Template:Pgv=1G(v1,v2,,vn)det[0c1c2cnv1v1,v1v1,v2v1,vnv2v2,v1v2,v2v2,vnvnvn,v1vn,v2vn,vn]The Gram determinant can also be expressed in terms of the exterior product of vectors by

|G(v1,,vn)|=v1vn2.

The Gram determinant therefore supplies an inner product for the space Template:Tmath. If an orthonormal basis ei, i = 1, 2, ..., n on Template:Tmath is given, the vectors

ei1ein,i1<<in,

will constitute an orthonormal basis of n-dimensional volumes on the space Template:Tmath. Then the Gram determinant |G(v1,,vn)| amounts to an n-dimensional Pythagorean Theorem for the volume of the parallelotope formed by the vectors v1vn in terms of its projections onto the basis volumes ei1ein.

When the vectors v1,,vnm are defined from the positions of points p1,,pn relative to some reference point pn+1,

(v1,v2,,vn)=(p1pn+1,p2pn+1,,pnpn+1),

then the Gram determinant can be written as the difference of two Gram determinants,

|G(v1,,vn)|=|G((p1,1),,(pn+1,1))||G(p1,,pn+1)|,

where each (pj,1) is the corresponding point pj supplemented with the coordinate value of 1 for an (m+1)-st dimension.Script error: No such module "Unsubst". Note that in the common case that n = mScript error: No such module "Check for unknown parameters"., the second term on the right-hand side will be zero.

Constructing an orthonormal basis

Given a set of linearly independent vectors {vi} with Gram matrix G defined by Gij:=vi,vj, one can construct an orthonormal basis

ui:=j(G1/2)jivj.

In matrix notation, U=VG1/2, where U has orthonormal basis vectors {ui} and the matrix V is composed of the given column vectors {vi}.

The matrix G1/2 is guaranteed to exist. Indeed, G is Hermitian, and so can be decomposed as G=UDU with U a unitary matrix and D a real diagonal matrix. Additionally, the vi are linearly independent if and only if G is positive definite, which implies that the diagonal entries of D are positive. G1/2 is therefore uniquely defined by G1/2:=UD1/2U. One can check that these new vectors are orthonormal:

ui,uj=ij(G1/2)iivi,(G1/2)jjvj=ij(G1/2)iiGij(G1/2)jj=(G1/2GG1/2)ij=δij

where we used (G1/2)=G1/2.

See also

References

<templatestyles src="Reflist/styles.css" />

  1. a b c Script error: No such module "Footnotes"., p.441, Theorem 7.2.10
  2. Script error: No such module "citation/CS1".
  3. Script error: No such module "Footnotes"., p. 452, Theorem 7.3.11
  4. Script error: No such module "Citation/CS1".

Script error: No such module "Check for unknown parameters".

  • Script error: No such module "citation/CS1".

External links

Template:Matrix classes

fr:Matrice de Gram