Tutorials › Linear Algebra › Gram Matrices as Orthonormality Tests

Orthogonal Sets and Gram-Schmidt · Tutorial 637 of 1000

Gram Matrices as Orthonormality Tests

Use a list’s Gram matrix to check its pairwise orthogonality and vector lengths in real, complex and matrix inner product spaces.

Intermediate 10 min read

What You'll Learn

  • Define the Gram matrix using the course’s convention that complex inner products are linear in the first slot.
  • Read pairwise inner products and squared norms from the matrix entries.
  • Test whether a list of nonzero vectors is orthogonal or orthonormal.
  • Calculate Gram matrices for real vectors, complex vectors and matrices.
  • Verify why Gram matrices are Hermitian and positive semidefinite.
  • Avoid conjugation errors when computing complex inner products.

What a Gram Matrix Records

When a list of vectors is under consideration, its pairwise inner products collect the essential information about orthogonality and lengths. Arranging those numbers in a matrix makes the tests systematic: off-diagonal entries record interactions between different vectors, while diagonal entries record squared norms. This matrix is called the Gram matrix of the list.

We work over \(\mathbb{R}\) or \(\mathbb{C}\), with the inner product linear in its first slot, as in the course convention. Thus, over \(\mathbb{C}\), \(\langle a\mathbf{u},b\mathbf{v}\rangle=a\overline{b}\langle\mathbf{u},\mathbf{v}\rangle\). In \(\mathbb{R}^n\), the inner product is the dot product. The norm is \(\|\mathbf{v}\|=\sqrt{\langle\mathbf{v},\mathbf{v}\rangle}\). For a list \(\mathbf{v}_1,\dots,\mathbf{v}_p\), we use the following entry order. It is chosen so the Gram matrix agrees with \(\mathbf{X}^{*}\mathbf{X}\) when the vectors are columns of \(\mathbf{X}\) in the standard complex inner product.

Definition: The Gram matrix of an ordered list \(\mathbf{v}_1,\dots,\mathbf{v}_p\) is the \(p\times p\) matrix \(\mathbf{G}\) whose entry in row \(i\), column \(j\) is \(G_{ij}=\langle\mathbf{v}_j,\mathbf{v}_i\rangle\). Its diagonal entry \(G_{ii}\) is \(\|\mathbf{v}_i\|^2\); its off-diagonal entries record inner products between distinct list members, with the order fixed by the formula above.

Since \(\langle\mathbf{v}_j,\mathbf{v}_i\rangle=\overline{\langle\mathbf{v}_i,\mathbf{v}_j\rangle}\), the order of the two vectors matters in complex spaces. In real inner product spaces the entries are symmetric, so this order makes no numerical difference. The diagonal entries are always real and nonnegative, and are positive exactly when the corresponding vector is nonzero.

The Orthogonality Tests

Theorem: Let \(\mathbf{v}_1,\dots,\mathbf{v}_p\) be a list in an inner product space over \(\mathbb{R}\) or \(\mathbb{C}\), with \(p\geq1\), and let \(\mathbf{G}\) be its Gram matrix. The list consists of nonzero, pairwise orthogonal vectors if and only if \(\mathbf{G}\) is diagonal with every diagonal entry positive. The list is orthonormal if and only if \(\mathbf{G}=\mathbf{I}_p\).

Proof. By definition, a list of nonzero vectors is pairwise orthogonal exactly when \(\langle\mathbf{v}_j,\mathbf{v}_i\rangle=0\) whenever \(i\ne j\). These are precisely the off-diagonal entries of \(\mathbf{G}\), so the pairwise inner products vanish exactly when \(\mathbf{G}\) is diagonal. Also, \(G_{ii}=\|\mathbf{v}_i\|^2>0\) exactly when \(\mathbf{v}_i\ne\mathbf{0}\). This proves both directions of the first equivalence. For the second, if the list is orthonormal, its vectors are pairwise orthogonal and each has norm \(1\). Thus the off-diagonal entries are zero and \(G_{ii}=\|\mathbf{v}_i\|^2=1\), giving \(\mathbf{G}=\mathbf{I}_p\). Conversely, if \(\mathbf{G}=\mathbf{I}_p\), its off-diagonal entries give pairwise orthogonality, and its diagonal entries give \(\|\mathbf{v}_i\|^2=1\) for every \(i\). The list is therefore orthonormal. \(\square\)

The nonzero condition in the first test matters. A zero vector has inner product zero with every vector, so all off-diagonal entries in its row and column are zero. But its diagonal entry is also zero, and it is not a member of an orthogonal list of nonzero vectors. The matrix reveals this: check for positive diagonal entries as well as zero off-diagonal entries.

Worked Example: Orthogonal but Not Orthonormal in R³

For \(\mathbf{v}_1=(1,1,0)^{\top}\), \(\mathbf{v}_2=(1,-1,0)^{\top}\), and \(\mathbf{v}_3=(0,0,2)^{\top}\), calculate the Gram matrix and classify the list.

First compute the diagonal entries as squared norms:

$$ \begin{aligned} \langle\mathbf{v}_1,\mathbf{v}_1\rangle&=1^2+1^2+0^2=2,\\ \langle\mathbf{v}_2,\mathbf{v}_2\rangle&=1^2+(-1)^2+0^2=2,\\ \langle\mathbf{v}_3,\mathbf{v}_3\rangle&=0^2+0^2+2^2=4. \end{aligned} $$

Now compute the inner products between distinct vectors:

$$ \begin{aligned} \langle\mathbf{v}_2,\mathbf{v}_1\rangle&=1(1)+(-1)(1)+0(0)=0,\\ \langle\mathbf{v}_3,\mathbf{v}_1\rangle&=0(1)+0(1)+2(0)=0,\\ \langle\mathbf{v}_3,\mathbf{v}_2\rangle&=0(1)+0(-1)+2(0)=0. \end{aligned} $$

The reverse-order inner products are also zero, so

$$ \mathbf{G}= \begin{bmatrix} 2&0&0\\ 0&2&0\\ 0&0&4 \end{bmatrix}. $$

The positive diagonal entries and zero off-diagonal entries show that the list is orthogonal. It is not orthonormal because its vectors do not all have norm \(1\): their norms are \(\sqrt{2},\sqrt{2},2\). Check: the computed diagonal entries are exactly the squares of those norms, and each pairwise dot product is zero.

Calculating Gram Matrices in Other Spaces

The definition uses the inner product of the space, not a special formula tied to coordinate vectors in \(\mathbb{R}^n\). For example, matrices can themselves be vectors in an inner product space. With the Frobenius inner product \(\langle\mathbf{A},\mathbf{B}\rangle=\operatorname{tr}(\mathbf{A}\mathbf{B}^{\top})\) on real matrices of the same size, this inner product is the sum of the products of corresponding entries. The same diagonal and off-diagonal tests apply.

Worked Example: A Gram Matrix in a Matrix Space

Use the Frobenius inner product to find the Gram matrix of

$$ \mathbf{A}=\begin{bmatrix}1&0\\0&0\end{bmatrix}, \qquad \mathbf{B}=\begin{bmatrix}1&0\\0&1\end{bmatrix}. $$

The diagonal entries are sums of squares of the entries:

$$ \langle\mathbf{A},\mathbf{A}\rangle=1^2+0^2+0^2+0^2=1, \qquad \langle\mathbf{B},\mathbf{B}\rangle=1^2+0^2+0^2+1^2=2. $$

The off-diagonal entry is the sum of the products of corresponding entries:

$$ \langle\mathbf{B},\mathbf{A}\rangle =1(1)+0(0)+0(0)+1(0)=1. $$

The real Frobenius inner product is symmetric, so \(\langle\mathbf{A},\mathbf{B}\rangle=1\) as well. Hence

$$ \mathbf{G}= \begin{bmatrix} 1&1\\ 1&2 \end{bmatrix}. $$

The nonzero off-diagonal entries show that \(\mathbf{A}\) and \(\mathbf{B}\) are not orthogonal. The diagonal entries give \(\|\mathbf{A}\|=1\) and \(\|\mathbf{B}\|=\sqrt{2}\). Check: \(\mathbf{A}\) and \(\mathbf{B}\) share a \(1\) in their upper-left entry and have zero products in the other positions, so their Frobenius inner product is indeed \(1\).

Complex Entries and Conjugation

In a complex inner product space, the Gram matrix may have complex off-diagonal entries. The two entries on opposite sides of the diagonal are complex conjugates, not necessarily equal. The diagonal remains real and nonnegative. This is why the complex test is still that the off-diagonal entries vanish, rather than that they are merely real or equal.

Worked Example: A Complex Orthogonal List

In \(\mathbb{C}^2\) with \(\langle\mathbf{u},\mathbf{v}\rangle=u_1\overline{v_1}+u_2\overline{v_2}\), let \(\mathbf{u}=(1,i)^{\top}\) and \(\mathbf{v}=(i,1)^{\top}\). Find their Gram matrix and decide whether the list is orthogonal or orthonormal.

The squared norms are

$$ \begin{aligned} \langle\mathbf{u},\mathbf{u}\rangle &=1\overline{1}+i\overline{i}=1+i(-i)=2,\\ \langle\mathbf{v},\mathbf{v}\rangle &=i\overline{i}+1\overline{1}=i(-i)+1=2. \end{aligned} $$

For the off-diagonal entry in row 1, column 2, use the specified order in the definition:

$$ G_{12}=\langle\mathbf{v},\mathbf{u}\rangle =i\overline{1}+1\overline{i}=i-i=0. $$

The reverse-order entry is also zero:

$$ G_{21}=\langle\mathbf{u},\mathbf{v}\rangle =1\overline{i}+i\overline{1}=-i+i=0. $$

Thus \(\mathbf{G}=\begin{bmatrix}2&0\\0&2\end{bmatrix}\). Both vectors are nonzero and orthogonal, but their norms are \(\sqrt{2}\), so the list is not orthonormal. Check: the off-diagonal entries vanish and the diagonal entries are \(\|\mathbf{u}\|^2=\|\mathbf{v}\|^2=2\).

A Useful Identity and a Common Error

Proposition: For a list \(\mathbf{v}_1,\dots,\mathbf{v}_p\) in an inner product space over \(\mathbb{C}\) or \(\mathbb{R}\), let \(\mathbf{G}\) be its Gram matrix. For any coefficient column \(\mathbf{c}=(c_1,\dots,c_p)^{\top}\), \(\left\|\sum_{j=1}^{p}c_j\mathbf{v}_j\right\|^2=\mathbf{c}^{*}\mathbf{G}\mathbf{c}\). Consequently, \(\mathbf{G}\) is Hermitian and positive semidefinite: \(\mathbf{G}^{*}=\mathbf{G}\), and \(\mathbf{c}^{*}\mathbf{G}\mathbf{c}\geq0\) for every \(\mathbf{c}\).

Proof. Write \(\mathbf{w}=\sum_{j=1}^{p}c_j\mathbf{v}_j\). Linearity in the first slot and conjugate-linearity in the second give \(\langle\mathbf{w},\mathbf{w}\rangle=\sum_{j=1}^{p}\sum_{i=1}^{p}c_j\overline{c_i}\langle\mathbf{v}_j,\mathbf{v}_i\rangle\). By the definition of the Gram matrix, \(\langle\mathbf{v}_j,\mathbf{v}_i\rangle=G_{ij}\). Therefore this sum is \(\sum_{i=1}^{p}\sum_{j=1}^{p}\overline{c_i}G_{ij}c_j=\mathbf{c}^{*}\mathbf{G}\mathbf{c}\). Since a squared norm is real and nonnegative, this quantity is nonnegative for every \(\mathbf{c}\), which proves positive semidefiniteness. Also, \(G_{ji}=\langle\mathbf{v}_i,\mathbf{v}_j\rangle=\overline{\langle\mathbf{v}_j,\mathbf{v}_i\rangle}=\overline{G_{ij}}\), so \(\mathbf{G}^{*}=\mathbf{G}\). \(\square\)

A common mistake is to multiply complex components without conjugating the second vector. For the vectors \(\mathbf{u}=(1,i)^{\top}\) and \(\mathbf{v}=(i,1)^{\top}\) above, this incorrect calculation gives \(1(i)+i(1)=2i\) for their inner product and wrongly declares them nonorthogonal. The correction is to conjugate the components of the second vector: \(\langle\mathbf{u},\mathbf{v}\rangle=1\overline{i}+i\overline{1}=-i+i=0\). Follow the stated inner-product convention before filling any Gram matrix entry.

In practice, a Gram matrix compresses several pairwise tests into one calculation. The diagonal tells you whether each vector has unit length, while the off-diagonal entries tell you whether different vectors are orthogonal. It does not list the vectors themselves; it records the inner products relevant to these tests. In particular, \(\mathbf{G}=\mathbf{I}_p\) is the complete test for an orthonormal list, while a diagonal matrix with positive entries certifies an orthogonal list whose vectors may have different lengths.

Check Your Understanding

For each question, write the Gram matrix using \(G_{ij}=\langle\mathbf{v}_j,\mathbf{v}_i\rangle\), then use its entries to justify your conclusion.

  1. Find the Gram matrix of \((1,0)^{\top}\) and \((0,3)^{\top}\) in \(\mathbb{R}^2\). Is the list orthogonal? Is it orthonormal?
  2. For \(\mathbf{v}_1=(1,1)^{\top}\) and \(\mathbf{v}_2=(1,0)^{\top}\), calculate the real Gram matrix and decide whether the list is orthogonal.
  3. In \(\mathbb{C}^2\) with \(\langle\mathbf{u},\mathbf{v}\rangle=\sum_k u_k\overline{v_k}\), find \(\langle(1,i)^{\top},(i,1)^{\top}\rangle\). Show the conjugation in your calculation.
  4. What does a zero diagonal entry of a Gram matrix tell you about the corresponding vector?
  5. State the diagonal and off-diagonal conditions that make a Gram matrix equal to the identity matrix.

Test yourself: Linear Algebra final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon