Tutorials › Linear Algebra › Worked Examples of Commuting Symmetric Matrices

Symmetric Matrices and the Spectral Theorem · Tutorial 750 of 1000

Worked Examples of Commuting Symmetric Matrices

Work through exact examples that use commutation and invariant eigenspaces to construct and verify a common orthonormal eigenbasis.

Advanced 11 min read

What You'll Learn

  • Check whether two real symmetric matrices commute by computing both matrix products.
  • Explain why commutation makes each eigenspace of one matrix invariant under the other.
  • Construct a common orthonormal eigenbasis, including when an eigenspace has dimension greater than one.
  • Verify both diagonal representations using the same orthogonal matrix.
  • Identify why symmetric matrices that do not commute cannot share an orthonormal eigenbasis.
  • Avoid pairing eigenvectors arbitrarily when an eigenspace has repeated eigenvalue.

What a Common Eigenbasis Accomplishes

Each real symmetric matrix can be diagonalized in an orthonormal basis. For a pair of matrices, the important question is whether one orthonormal basis works for both. If it does, the same orthogonal matrix \(\mathbf{Q}\) puts both matrices into diagonal form: \(\mathbf{Q}^{\top}\mathbf{A}\mathbf{Q}\) and \(\mathbf{Q}^{\top}\mathbf{B}\mathbf{Q}\) are diagonal. In these coordinates, each basis vector is an eigenvector of both matrices, and the two matrices act by scaling the same directions.

Throughout, \(\mathbf{A},\mathbf{B}\in\mathbb{R}^{n\times n}\) are real symmetric matrices. An orthonormal list has unit vectors that are pairwise orthogonal; an orthonormal basis is such a list that spans \(\mathbb{R}^n\). A matrix \(\mathbf{Q}\) is orthogonal when \(\mathbf{Q}^{\top}\mathbf{Q}=\mathbf{I}_n\); its columns then form an orthonormal basis. The matrices commute when \(\mathbf{A}\mathbf{B}=\mathbf{B}\mathbf{A}\).

Definition: A common orthonormal eigenbasis for \(\mathbf{A}\) and \(\mathbf{B}\) is an orthonormal basis \((\mathbf{q}_1,\dots,\mathbf{q}_n)\) of \(\mathbb{R}^n\) such that every \(\mathbf{q}_j\) is an eigenvector of both matrices. Equivalently, for each \(j\) there are scalars \(\alpha_j,\beta_j\) with \(\mathbf{A}\mathbf{q}_j=\alpha_j\mathbf{q}_j\) and \(\mathbf{B}\mathbf{q}_j=\beta_j\mathbf{q}_j\).

Why Commutation Preserves Eigenspaces

An eigenspace gives all vectors associated with one eigenvalue, including the zero vector. The key calculation is that if \(\mathbf{A}\) and \(\mathbf{B}\) commute, applying \(\mathbf{A}\) to an eigenvector of \(\mathbf{B}\) cannot take it out of that eigenspace.

Lemma: If \(\mathbf{A}\mathbf{B}=\mathbf{B}\mathbf{A}\), then for every eigenvalue \(\lambda\) of \(\mathbf{B}\), the eigenspace \(E_\lambda=\{\mathbf{x}\in\mathbb{R}^n:\mathbf{B}\mathbf{x}=\lambda\mathbf{x}\}\) is invariant under \(\mathbf{A}\). That is, \(\mathbf{x}\in E_\lambda\) implies \(\mathbf{A}\mathbf{x}\in E_\lambda\).

Proof. Assume \(\mathbf{x}\in E_\lambda\), so \(\mathbf{B}\mathbf{x}=\lambda\mathbf{x}\). Using commutation and the fact that scalar multiplication can be moved outside a matrix product, we obtain \(\mathbf{B}(\mathbf{A}\mathbf{x})=\mathbf{A}(\mathbf{B}\mathbf{x})=\mathbf{A}(\lambda\mathbf{x})=\lambda(\mathbf{A}\mathbf{x})\). By the definition of \(E_\lambda\), this says \(\mathbf{A}\mathbf{x}\in E_\lambda\). If \(\mathbf{A}\mathbf{x}=\mathbf{0}\), the conclusion still holds, since \(\mathbf{B}\mathbf{0}=\lambda\mathbf{0}\). \(\square\)

This gives a practical construction. First split the space into the mutually orthogonal eigenspaces of \(\mathbf{B}\), using the Spectral Theorem for real symmetric matrices. Commutation says each such space is preserved by \(\mathbf{A}\). The restriction of \(\mathbf{A}\) to each eigenspace remains symmetric with respect to the inherited dot product, so the Spectral Theorem provides an orthonormal eigenbasis for that restriction. Combining those bases gives vectors that are eigenvectors of \(\mathbf{A}\) and of \(\mathbf{B}\).

Theorem (simultaneous orthogonal diagonalization): Two real symmetric matrices \(\mathbf{A},\mathbf{B}\in\mathbb{R}^{n\times n}\) have a common orthonormal eigenbasis if and only if \(\mathbf{A}\mathbf{B}=\mathbf{B}\mathbf{A}\).

Proof. First suppose that the matrices commute. By the Spectral Theorem, \(\mathbb{R}^n\) is the orthogonal direct sum of the eigenspaces of \(\mathbf{B}\). For any eigenvalue \(\lambda\), the lemma shows that \(E_\lambda\) is invariant under \(\mathbf{A}\). The restriction \(\mathbf{A}|_{E_\lambda}\) is a linear map from \(E_\lambda\) to itself. It is symmetric: for \(\mathbf{x},\mathbf{y}\in E_\lambda\), symmetry of \(\mathbf{A}\) gives \(\langle \mathbf{A}\mathbf{x},\mathbf{y}\rangle=\langle\mathbf{x},\mathbf{A}\mathbf{y}\rangle\). The Spectral Theorem applied on this finite-dimensional real inner-product space gives an orthonormal basis of \(E_\lambda\) consisting of eigenvectors of \(\mathbf{A}|_{E_\lambda}\). Every vector in \(E_\lambda\) is also an eigenvector of \(\mathbf{B}\) with eigenvalue \(\lambda\). Combining these orthonormal bases over all eigenspaces of \(\mathbf{B}\) produces a common orthonormal eigenbasis of \(\mathbb{R}^n\).

Conversely, suppose \((\mathbf{q}_1,\dots,\mathbf{q}_n)\) is a common orthonormal eigenbasis, and let \(\mathbf{Q}\) have these vectors as its columns. Then \(\mathbf{Q}^{\top}\mathbf{Q}=\mathbf{I}_n\), and for diagonal matrices \(\mathbf{D}_A,\mathbf{D}_B\) we have \(\mathbf{A}=\mathbf{Q}\mathbf{D}_A\mathbf{Q}^{\top}\) and \(\mathbf{B}=\mathbf{Q}\mathbf{D}_B\mathbf{Q}^{\top}\). Diagonal matrices commute, so \(\mathbf{A}\mathbf{B}=\mathbf{Q}\mathbf{D}_A\mathbf{D}_B\mathbf{Q}^{\top}=\mathbf{Q}\mathbf{D}_B\mathbf{D}_A\mathbf{Q}^{\top}=\mathbf{B}\mathbf{A}\). Thus the matrices commute. \(\square\)

Worked Examples: Constructing and Checking a Shared Basis

Worked Example: A Common Basis in Two Dimensions

Find a common orthonormal eigenbasis for the following symmetric matrices, and verify their commutation and diagonal representations:

$$ \mathbf{A}=\begin{bmatrix}\frac72&-\frac32\\-\frac32&\frac72\end{bmatrix}, \qquad \mathbf{B}=\begin{bmatrix}1&2\\2&1\end{bmatrix}. $$

Try the orthonormal vectors \(\mathbf{q}_1=\frac{1}{\sqrt{2}}(1,1)^{\top}\) and \(\mathbf{q}_2=\frac{1}{\sqrt{2}}(1,-1)^{\top}\). Each has squared length \(\frac12+\frac12=1\), and their dot product is \(\frac12-\frac12=0\). Direct multiplication gives

$$ \mathbf{A}\mathbf{q}_1 =\frac{1}{\sqrt{2}}\begin{bmatrix}2\\2\end{bmatrix} =2\mathbf{q}_1,\qquad \mathbf{A}\mathbf{q}_2 =\frac{1}{\sqrt{2}}\begin{bmatrix}5\\-5\end{bmatrix} =5\mathbf{q}_2. $$

For the second matrix, the corresponding products are

$$ \mathbf{B}\mathbf{q}_1 =\frac{1}{\sqrt{2}}\begin{bmatrix}3\\3\end{bmatrix} =3\mathbf{q}_1,\qquad \mathbf{B}\mathbf{q}_2 =\frac{1}{\sqrt{2}}\begin{bmatrix}-1\\1\end{bmatrix} =-\mathbf{q}_2. $$

Thus the same basis diagonalizes both. Let \(\mathbf{Q}=\begin{bmatrix}\mathbf{q}_1&\mathbf{q}_2\end{bmatrix}\). Its columns are orthonormal, and the eigenvector equations verify each diagonal representation:

$$ \mathbf{Q}^{\top}\mathbf{A}\mathbf{Q} =\begin{bmatrix}2&0\\0&5\end{bmatrix}, \qquad \mathbf{Q}^{\top}\mathbf{B}\mathbf{Q} =\begin{bmatrix}3&0\\0&-1\end{bmatrix}. $$

Check commutation by multiplying in the original coordinates:

$$ \mathbf{A}\mathbf{B} =\begin{bmatrix}\frac12&\frac{11}{2}\\[2pt]\frac{11}{2}&\frac12\end{bmatrix}, \qquad \mathbf{B}\mathbf{A} =\begin{bmatrix}\frac12&\frac{11}{2}\\[2pt]\frac{11}{2}&\frac12\end{bmatrix}. $$

The products agree, as the theorem predicts. The eigenvector calculations check the result directly, while the two matrix products independently verify the commutation condition.

Worked Example: Resolving a Repeated Eigenspace

Consider \(\mathbf{A}=\begin{bmatrix}2&1&0\\1&2&0\\0&0&4\end{bmatrix}\) and \(\mathbf{B}=\begin{bmatrix}2&0&0\\0&2&0\\0&0&-1\end{bmatrix}\). Find a common orthonormal eigenbasis. The first two standard basis directions belong to the same eigenspace of \(\mathbf{B}\), so an eigenbasis for \(\mathbf{B}\) alone does not yet specify which orthonormal directions will diagonalize \(\mathbf{A}\) there.

First check that the matrices commute. Multiplication gives

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

The eigenspace of \(\mathbf{B}\) for eigenvalue \(2\) is the span of \(\mathbf{e}_1,\mathbf{e}_2\). On this space, \(\mathbf{A}\) acts by the block \(\begin{bmatrix}2&1\\1&2\end{bmatrix}\). Choose \(\mathbf{q}_1=\frac1{\sqrt2}(1,1,0)^{\top}\), \(\mathbf{q}_2=\frac1{\sqrt2}(1,-1,0)^{\top}\), and \(\mathbf{q}_3=(0,0,1)^{\top}\). These are unit vectors and pairwise orthogonal. Their eigenvector checks are

$$ \begin{aligned} \mathbf{A}\mathbf{q}_1&=\frac1{\sqrt2}(3,3,0)^{\top}=3\mathbf{q}_1, &\mathbf{B}\mathbf{q}_1&=\frac1{\sqrt2}(2,2,0)^{\top}=2\mathbf{q}_1,\\ \mathbf{A}\mathbf{q}_2&=\frac1{\sqrt2}(1,-1,0)^{\top}=\mathbf{q}_2, &\mathbf{B}\mathbf{q}_2&=\frac1{\sqrt2}(2,-2,0)^{\top}=2\mathbf{q}_2,\\ \mathbf{A}\mathbf{q}_3&=(0,0,4)^{\top}=4\mathbf{q}_3, &\mathbf{B}\mathbf{q}_3&=(0,0,-1)^{\top}=-\mathbf{q}_3. \end{aligned} $$

With \(\mathbf{Q}=\begin{bmatrix}\mathbf{q}_1&\mathbf{q}_2&\mathbf{q}_3\end{bmatrix}\), the checked eigenvalues in column order give

$$ \mathbf{Q}^{\top}\mathbf{A}\mathbf{Q} =\begin{bmatrix}3&0&0\\0&1&0\\0&0&4\end{bmatrix}, \qquad \mathbf{Q}^{\top}\mathbf{B}\mathbf{Q} =\begin{bmatrix}2&0&0\\0&2&0\\0&0&-1\end{bmatrix}. $$

In particular, the repeated eigenvalue \(2\) for \(\mathbf{B}\) permits a choice of orthonormal basis inside its two-dimensional eigenspace. Choosing that basis to diagonalize the restriction of \(\mathbf{A}\) is the essential step.

When Commutation Fails

Worked Example: Symmetry Alone Does Not Give a Common Basis

Let \(\mathbf{A}=\begin{bmatrix}1&0\\0&2\end{bmatrix}\) and \(\mathbf{B}=\begin{bmatrix}0&1\\1&0\end{bmatrix}\). Both are real symmetric. Check whether they commute and whether they can have a common eigenbasis.

The products are

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

They are unequal, so the matrices do not commute. The only eigenvector directions of \(\mathbf{A}\) are multiples of \(\mathbf{e}_1\) and \(\mathbf{e}_2\), because its two diagonal entries are distinct. But \(\mathbf{B}\mathbf{e}_1=\mathbf{e}_2\) and \(\mathbf{B}\mathbf{e}_2=\mathbf{e}_1\), so neither direction is an eigenvector of \(\mathbf{B}\). There is no common eigenbasis, and therefore no common orthonormal eigenbasis. This agrees with the theorem.

Common Mistakes and Verification

Mistake: assuming any eigenbasis of one matrix works for the other. In the repeated-eigenspace example, \(\mathbf{e}_1\) is an eigenvector of \(\mathbf{B}\), but it is not an eigenvector of \(\mathbf{A}\): \(\mathbf{A}\mathbf{e}_1=(2,1,0)^{\top}\), which is not a scalar multiple of \(\mathbf{e}_1\). The correction is to use the invariant eigenspace of \(\mathbf{B}\), then diagonalize the restriction of \(\mathbf{A}\) within it.

When checking a proposed answer, keep the eigenvalues in the same order as the columns of \(\mathbf{Q}\). If \(\mathbf{A}\mathbf{q}_j=\alpha_j\mathbf{q}_j\), the \(j\)-th diagonal entry of \(\mathbf{Q}^{\top}\mathbf{A}\mathbf{Q}\) must be \(\alpha_j\), not an eigenvalue assigned to a different column. A reliable check is to multiply \(\mathbf{A}\mathbf{q}_j\) and \(\mathbf{B}\mathbf{q}_j\) explicitly before writing either diagonal matrix. Also verify \(\mathbf{Q}^{\top}\mathbf{Q}=\mathbf{I}_n\) and, separately, \(\mathbf{A}\mathbf{B}=\mathbf{B}\mathbf{A}\).

These checks answer distinct questions. Commutation is the criterion for whether a common orthonormal eigenbasis exists for two real symmetric matrices. Orthonormality verifies the coordinate change, and the individual eigenvector equations verify that the diagonal entries in both representations are correct.

Check Your Understanding

For each question, justify your conclusion with a computation or the stated theorem.

  1. For \(\mathbf{C}=\begin{bmatrix}3&1\\1&3\end{bmatrix}\) and \(\mathbf{D}=\begin{bmatrix}2&0\\0&2\end{bmatrix}\), check commutation and give a common orthonormal eigenbasis.
  2. Explain why every vector in a repeated eigenspace of \(\mathbf{B}\) need not be an eigenvector of \(\mathbf{A}\), even when \(\mathbf{A}\) and \(\mathbf{B}\) commute.
  3. Suppose \(\mathbf{A}\) and \(\mathbf{B}\) are real symmetric and have a common orthonormal eigenbasis. Prove that they commute by writing both in that basis.
  4. For \(\mathbf{A}=\begin{bmatrix}2&0\\0&5\end{bmatrix}\) and \(\mathbf{B}=\begin{bmatrix}1&1\\1&1\end{bmatrix}\), compute \(\mathbf{A}\mathbf{B}\) and \(\mathbf{B}\mathbf{A}\). What does the theorem imply?
  5. In a proposed simultaneous diagonalization, what two checks confirm that the same \(\mathbf{Q}\) gives correct diagonal representations for both matrices?

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