Gram Matrices: Packaging Every Inner Product into One Matrix

Given a list of vectors v1,…,vkv_1,\dots,v_k in an inner product space, the Gram matrix GG is the k×kk\times k matrix that records every pairwise inner product in one place:


Gij=⟨vi,vj⟩.G_{ij}=\langle v_i,v_j\rangle.


That is the entire definition, and it is worth saying what it is not: the entries of GG are numbers produced by the inner product, never the coordinates of the vectors themselves.


The size of GG is set by how many vectors there are, not by the dimension they live in, five vectors in R100\mathbb{R}^{100} still give a 5×55\times5 Gram matrix.

Matrix form

If the vectors sit in Rn\mathbb{R}^{n} with the standard dot product and VV is the n×kn\times k matrix whose columns are v1,…,vkv_1,\dots,v_k, then


G=VTV.G=V^{T}V.


Watch the order. VTVV^{T}V is k×kk\times k and is the Gram matrix; VVTVV^{T} is n×nn\times n and is something else entirely (a projection-related operator on the ambient space). Getting these the wrong way round is the single most common error with Gram matrices, and a dimension check catches it immediately.

Three properties that do all the work

  • Symmetry. Gij=⟨vi,vj⟩=⟨vj,vi⟩=GjiG_{ij}=\langle v_i,v_j\rangle=\langle v_j,v_i\rangle=G_{ji} for a real inner product, so GG is always symmetric.
  • Positive semidefiniteness. For any coefficient vector cc, cTGc=⟨∑icivi, ∑jcjvj⟩=∥∑icivi∥2≥0c^{T}Gc=\left\langle \sum_i c_iv_i,\ \sum_j c_jv_j\right\rangle=\left\|\sum_i c_iv_i\right\|^{2}\ge0. So GG is positive semidefinite, always.
  • Independence test. That same identity says cTGc=0c^{T}Gc=0 exactly when ∑icivi=0\sum_i c_iv_i=0. So GG is positive definite precisely when the only such cc is zero, that is, when v1,…,vkv_1,\dots,v_k are linearly independent. Since a symmetric positive definite matrix has strictly positive determinant, this gives the clean criterion det⁡(G)=0\det(G)=0 if and only if the vectors are linearly dependent.

Geometry: the determinant is a squared measure

For two vectors, det⁡(G)\det(G) is the squared area of the parallelogram they span; for three vectors in R3\mathbb{R}^3 it is the squared volume of the parallelepiped.


The square is not decoration, it is what keeps the quantity computable from inner products alone, with no cross product and no ambient dimension required.


So an area is recovered as det⁡G\sqrt{\det G}, and forgetting the square root is an easy way to report a number that is far too large.


For two unit vectors separated by an angle θ\theta, the Gram matrix takes a particularly transparent form, since ⟨v1,v1⟩=⟨v2,v2⟩=1\langle v_1,v_1\rangle=\langle v_2,v_2\rangle=1 and ⟨v1,v2⟩=cos⁡θ\langle v_1,v_2\rangle=\cos\theta:


G=(1cos⁡θcos⁡θ1),det⁡(G)=1−cos⁡2θ.G=\begin{pmatrix}1&\cos\theta\\ \cos\theta&1\end{pmatrix}, \qquad \det(G)=1-\cos^{2}\theta.


The determinant collapses to zero when the vectors are parallel or antiparallel and is largest when they are orthogonal, exactly the behaviour a squared area should have. Note that det⁡(G)\det(G) depends only on cos⁡2θ\cos^{2}\theta, so an angle and its supplement give the same determinant; recovering θ\theta itself needs the sign of the off-diagonal entry as well.

Worked example

Let v1=(1,−1)v_1=(1,-1) and v2=(2,1)v_2=(2,1) with the standard dot product. Then ⟨v1,v1⟩=1+1=2\langle v_1,v_1\rangle=1+1=2, ⟨v1,v2⟩=2−1=1\langle v_1,v_2\rangle=2-1=1, and ⟨v2,v2⟩=4+1=5\langle v_2,v_2\rangle=4+1=5, so


G=(2115),det⁡(G)=10−1=9.G=\begin{pmatrix}2&1\\1&5\end{pmatrix}, \qquad \det(G)=10-1=9.


Since det⁡(G)≠0\det(G)\ne0, the vectors are linearly independent, and the parallelogram they span has area 9=3\sqrt{9}=3. Notice that both conclusions came out of four dot products and a 2×22\times2 determinant; the vectors' coordinates were needed only to compute those inner products.



Let u=(1,2)u=(1,2) and v=(3,−1)v=(3,-1) in R2\mathbb{R}^{2} with the standard dot product. Which matrix is the Gram matrix GG of the pair (u,v)(u,v), where G11=⟨u,u⟩G_{11}=\langle u,u\rangle, G12=G21=⟨u,v⟩G_{12}=G_{21}=\langle u,v\rangle and G22=⟨v,v⟩G_{22}=\langle v,v\rangle?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Mark Yourself Question

  1. Grab a piece of paper and try this problem yourself.
  2. When you're done, check the "I have answered this question" box below.
  3. View the solution and report whether you got it right or wrong.

Let v1v_1 and v2v_2 be unit vectors in an inner product space separated by an angle of θ=60∘\theta=60^{\circ}, so that ⟨v1,v2⟩=cos⁡θ\langle v_1,v_2\rangle=\cos\theta. Answer all three parts.

  1. Write down the Gram matrix GG of the pair (v1,v2)(v_1,v_2), with numerical entries.
  2. Compute det⁡(G)\det(G).
  3. Give the area of the parallelogram spanned by v1v_1 and v2v_2, to three decimal places.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Vectors v1,v2,v3v_1,v_2,v_3 lie in R3\mathbb{R}^{3}, and their 3×33\times3 Gram matrix GG satisfies det⁡(G)=0\det(G)=0. Which statement must be true?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors