Tutorials › Linear Algebra › Simultaneous Diagonalization of Commuting Symmetric Matrices

Symmetric Matrices and the Spectral Theorem · Tutorial 749 of 1000

Simultaneous Diagonalization of Commuting Symmetric Matrices

Learn how commutation lets two real symmetric matrices be diagonalized in the same orthonormal basis, and how to verify the condition in examples.

Advanced 9 min read

What You'll Learn

  • State the simultaneous diagonalization criterion for two real symmetric matrices.
  • Prove that commutation makes each eigenspace of one matrix invariant under the other.
  • Use the Spectral Theorem on invariant eigenspaces to construct a common orthonormal eigenbasis.
  • Verify common eigenvectors and commutation by exact matrix calculations.
  • Identify why symmetry alone does not guarantee simultaneous diagonalization.

One Orthonormal Basis for Two Matrices

A real symmetric matrix can be diagonalized in an orthonormal basis. For two matrices, the stronger question is whether one orthonormal basis works for both at once. The key condition is that the matrices commute: their products in the two possible orders are equal. The reason this condition matters is that it forces one matrix to preserve the eigenspaces of the other. Within each such eigenspace, the second matrix can be diagonalized without leaving the space.

Throughout, let \(\mathbf{A},\mathbf{B}\in\mathbb{R}^{n\times n}\), with \(n\geq 1\). A matrix \(\mathbf{A}\) is symmetric if \(\mathbf{A}^{\top}=\mathbf{A}\), and the matrices commute if \(\mathbf{A}\mathbf{B}=\mathbf{B}\mathbf{A}\). An orthonormal eigenbasis for a matrix is an orthonormal basis of \(\mathbb{R}^n\) whose vectors are eigenvectors of that matrix. A common orthonormal eigenbasis consists of vectors that are eigenvectors of both matrices.

Standard result (real Spectral Theorem): Every real symmetric matrix on \(\mathbb{R}^n\) has an orthonormal basis of eigenvectors. Equivalently, it can be diagonalized by an orthogonal change of basis. This result is established in the earlier material on the Spectral Theorem.

For an eigenvalue \(\lambda\) of \(\mathbf{A}\), its eigenspace is \(E_{\lambda}=\{\mathbf{x}\in\mathbb{R}^n:\mathbf{A}\mathbf{x}=\lambda\mathbf{x}\}\). An eigenspace is a subspace, and its vectors are exactly the vectors on which \(\mathbf{A}\) acts as multiplication by \(\lambda\). If an eigenvalue is repeated, its eigenspace can have dimension greater than one. That larger space is where the second matrix has room to act while preserving the first matrix’s eigenvalue equation.

Why Commutation Preserves Eigenspaces

Lemma: If \(\mathbf{A}\mathbf{B}=\mathbf{B}\mathbf{A}\), then for every eigenvalue \(\lambda\) of \(\mathbf{A}\), the matrix \(\mathbf{B}\) maps \(E_{\lambda}\) into \(E_{\lambda}\). In other words, \( \mathbf{x}\in E_{\lambda}\) implies \(\mathbf{B}\mathbf{x}\in E_{\lambda}\).

Proof. Assume \(\mathbf{x}\in E_{\lambda}\), so \(\mathbf{A}\mathbf{x}=\lambda\mathbf{x}\). Using commutation gives \(\mathbf{A}(\mathbf{B}\mathbf{x})=\mathbf{B}(\mathbf{A}\mathbf{x})=\mathbf{B}(\lambda\mathbf{x})=\lambda(\mathbf{B}\mathbf{x})\). This is the defining equation for membership in \(E_{\lambda}\). It also covers the case \(\mathbf{B}\mathbf{x}=\mathbf{0}\), since \(\mathbf{A}\mathbf{0}=\lambda\mathbf{0}\), so \(\mathbf{B}\mathbf{x}\) still belongs to the eigenspace. \(\square\)

The lemma gives invariance, not necessarily that \(\mathbf{B}\mathbf{x}=\mathbf{x}\) or that \(\mathbf{B}\mathbf{x}\) is a scalar multiple of \(\mathbf{x}\). If \(E_{\lambda}\) has dimension greater than one, \(\mathbf{B}\) may send one vector in that space to a different vector in the same space. Symmetry of \(\mathbf{B}\) is what lets us choose an orthonormal eigenbasis for its action within each preserved eigenspace.

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

Proof. First suppose that \(\mathbf{A}\) and \(\mathbf{B}\) commute. By the real Spectral Theorem, \(\mathbb{R}^n\) is the orthogonal direct sum of the eigenspaces of \(\mathbf{A}\). For each eigenvalue \(\lambda\) of \(\mathbf{A}\), the lemma shows that \(E_{\lambda}\) is invariant under \(\mathbf{B}\), so the restriction of \(\mathbf{B}\) to \(E_{\lambda}\) maps that space into itself. This restriction is symmetric: for \(\mathbf{x},\mathbf{y}\in E_{\lambda}\), the standard inner product satisfies \(\langle\mathbf{B}\mathbf{x},\mathbf{y}\rangle=\langle\mathbf{x},\mathbf{B}\mathbf{y}\rangle\), because \(\mathbf{B}^{\top}=\mathbf{B}\). Applying the real Spectral Theorem to this symmetric restriction gives an orthonormal basis of \(E_{\lambda}\) consisting of eigenvectors of \(\mathbf{B}\). Every vector in \(E_{\lambda}\) is already an eigenvector of \(\mathbf{A}\), so this is a common orthonormal eigenbasis for that eigenspace. Taking these bases over all eigenspaces of \(\mathbf{A}\) gives an orthonormal basis of \(\mathbb{R}^n\): the eigenspaces are mutually orthogonal, and together they span \(\mathbb{R}^n\). Thus the combined basis is common to \(\mathbf{A}\) and \(\mathbf{B}\). Conversely, suppose there is a common orthonormal eigenbasis, and let \(\mathbf{Q}\) be the matrix whose columns are its vectors. Then \(\mathbf{Q}^{\top}\mathbf{A}\mathbf{Q}=\mathbf{D}_A\) and \(\mathbf{Q}^{\top}\mathbf{B}\mathbf{Q}=\mathbf{D}_B\) are diagonal matrices. Diagonal matrices commute, so \(\mathbf{D}_A\mathbf{D}_B=\mathbf{D}_B\mathbf{D}_A\). Since \(\mathbf{Q}\mathbf{Q}^{\top}=\mathbf{I}_n\), this implies \(\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}\). Therefore the matrices commute. \(\square\)

Constructing the Shared Basis

The proof gives a practical construction. First find the eigenspaces of one matrix, say \(\mathbf{A}\). Commutation guarantees that each is preserved by \(\mathbf{B}\). Then, within each eigenspace, find an orthonormal eigenbasis for the restriction of \(\mathbf{B}\). The resulting vectors are eigenvectors of both matrices. This method does not require the eigenvalues of \(\mathbf{A}\) or \(\mathbf{B}\) to be distinct. In particular, repeated eigenvalues of \(\mathbf{A}\) create larger invariant spaces on which to diagonalize \(\mathbf{B}\).

Worked Example: Diagonalizing Within a Repeated Eigenspace

Consider the symmetric matrices

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

The eigenspaces of \(\mathbf{A}\) are \(E_1=\operatorname{span}\{(1,0,0)^{\top},(0,1,0)^{\top}\}\) and \(E_3=\operatorname{span}\{(0,0,1)^{\top}\}\). The repeated eigenvalue \(1\) gives a two-dimensional space. The first two columns of \(\mathbf{B}\) have zero third entry, so \(\mathbf{B}\) maps \(E_1\) into itself; it also maps \(E_3\) into itself.

Check commutation directly:

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

Within \(E_1\), choose \(\mathbf{q}_1=\frac{1}{\sqrt{2}}(1,1,0)^{\top}\) and \(\mathbf{q}_2=\frac{1}{\sqrt{2}}(1,-1,0)^{\top}\). Their norms are both \(1\), and their inner product is \((1-1)/2=0\). Multiplying by \(\mathbf{A}\) and \(\mathbf{B}\) gives

$$ \mathbf{A}\mathbf{q}_1=\mathbf{q}_1,\quad \mathbf{A}\mathbf{q}_2=\mathbf{q}_2,\quad \mathbf{B}\mathbf{q}_1=3\mathbf{q}_1,\quad \mathbf{B}\mathbf{q}_2=\mathbf{q}_2. $$

For \(\mathbf{q}_3=(0,0,1)^{\top}\), the computations are \(\mathbf{A}\mathbf{q}_3=3\mathbf{q}_3\) and \(\mathbf{B}\mathbf{q}_3=4\mathbf{q}_3\). This vector has norm \(1\), and it is orthogonal to both \(\mathbf{q}_1\) and \(\mathbf{q}_2\), whose third coordinates are zero. Thus \((\mathbf{q}_1,\mathbf{q}_2,\mathbf{q}_3)\) is a common orthonormal eigenbasis. The checks above verify each claimed eigenvalue by substitution.

This example shows why it is useful to work with eigenspaces rather than individual eigenvectors of \(\mathbf{A}\). The standard basis vectors in \(E_1\) are not eigenvectors of \(\mathbf{B}\), but their whole plane is invariant, and within that plane we can choose the needed eigenvectors.

Worked Example: Two Matrices in a Shared Rotated Basis

Let

$$ \mathbf{A}=\begin{bmatrix}\frac52&\frac32\\\frac32&\frac52\end{bmatrix}, \qquad \mathbf{B}=\begin{bmatrix}\frac12&\frac32\\\frac32&\frac12\end{bmatrix}. $$

Both matrices are symmetric. Multiplication in either order gives

$$ \mathbf{A}\mathbf{B} =\begin{bmatrix} \frac54+\frac94&\frac{15}{4}+\frac34\\ \frac34+\frac{15}{4}&\frac94+\frac54 \end{bmatrix} =\begin{bmatrix}\frac72&\frac92\\\frac92&\frac72\end{bmatrix}, $$ $$ \mathbf{B}\mathbf{A} =\begin{bmatrix} \frac54+\frac34&\frac34+\frac{15}{4}\\ \frac{15}{4}+\frac34&\frac94+\frac54 \end{bmatrix} =\begin{bmatrix}\frac72&\frac92\\\frac92&\frac72\end{bmatrix}. $$

Set \(\mathbf{q}_1=\frac{1}{\sqrt{2}}(1,1)^{\top}\) and \(\mathbf{q}_2=\frac{1}{\sqrt{2}}(1,-1)^{\top}\). Each has norm \(1\), and their inner product is \((1-1)/2=0\). For \(\mathbf{q}_1\), the first row of \(\mathbf{A}\) gives \((5/2+3/2)/\sqrt{2}=4/\sqrt{2}\), and the second row gives the same value. For \(\mathbf{q}_2\), the corresponding row values are \((5/2-3/2)/\sqrt{2}=1/\sqrt{2}\) and \((3/2-5/2)/\sqrt{2}=-1/\sqrt{2}\). Hence \(\mathbf{A}\mathbf{q}_1=4\mathbf{q}_1\) and \(\mathbf{A}\mathbf{q}_2=\mathbf{q}_2\). Repeating the row calculations for \(\mathbf{B}\) gives \(\mathbf{B}\mathbf{q}_1=2\mathbf{q}_1\) and \(\mathbf{B}\mathbf{q}_2=-\mathbf{q}_2\). These substitutions verify the eigenvalue claims, and the two orthonormal vectors form a common eigenbasis.

When Symmetry Is Not Enough

The theorem requires both matrices to be symmetric and to commute. Symmetry alone does not guarantee a common eigenbasis. If the matrices do not commute, the invariant-eigenspace argument can fail: an eigenvector of one matrix may be sent outside its eigenspace by the other.

Worked Example: Symmetric Matrices That Do Not Share an Eigenbasis

Take \(\mathbf{A}=\begin{bmatrix}1&0\\0&2\end{bmatrix}\) and \(\mathbf{B}=\begin{bmatrix}0&1\\1&0\end{bmatrix}\). Both are symmetric. Their 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 do not commute. The eigenspaces of \(\mathbf{A}\) are the two coordinate lines, spanned by \((1,0)^{\top}\) and \((0,1)^{\top}\). But \(\mathbf{B}(1,0)^{\top}=(0,1)^{\top}\) and \(\mathbf{B}(0,1)^{\top}=(1,0)^{\top}\), so neither coordinate vector is an eigenvector of \(\mathbf{B}\). Every eigenvector of \(\mathbf{A}\) lies on one of those two lines, so there is no common eigenvector and hence no common eigenbasis. This verifies concretely that symmetry without commutation is insufficient.

Common Pitfalls

Do not infer commutation from symmetry. A common incorrect calculation is to use \((\mathbf{A}\mathbf{B})^{\top}=\mathbf{A}^{\top}\mathbf{B}^{\top}\). The correct transpose rule is \((\mathbf{A}\mathbf{B})^{\top}=\mathbf{B}^{\top}\mathbf{A}^{\top}\). For symmetric matrices this says \((\mathbf{A}\mathbf{B})^{\top}=\mathbf{B}\mathbf{A}\); it does not say \(\mathbf{A}\mathbf{B}=\mathbf{B}\mathbf{A}\). In the example above, the two products are explicitly different.

Do not require distinct eigenvalues. The theorem makes no such assumption. When \(\mathbf{A}\) has a repeated eigenvalue, its eigenspace may have dimension greater than one; commutation preserves that entire space, and symmetry of the restriction of \(\mathbf{B}\) supplies an orthonormal eigenbasis within it. Conversely, having matching eigenvalues is not the criterion: the condition in the theorem is commutation.

The shared basis makes the action of each matrix easy to interpret: every basis vector is scaled by one eigenvalue for \(\mathbf{A}\) and another for \(\mathbf{B}\). In matrix form, the same orthogonal matrix \(\mathbf{Q}\) diagonalizes both. The result is useful whenever two symmetric transformations act on the same space and their order of application does not matter.

Check Your Understanding

Use the invariance argument and verify computational claims by substitution.

  1. For commuting matrices \(\mathbf{A}\) and \(\mathbf{B}\), prove directly that \(\mathbf{B}\mathbf{x}\in E_{\lambda}\) whenever \(\mathbf{x}\in E_{\lambda}\).
  2. Explain why the restriction of a symmetric matrix \(\mathbf{B}\) to a \(\mathbf{B}\)-invariant subspace is symmetric.
  3. For the first worked example, state the eigenvalues of each matrix corresponding to \(\mathbf{q}_1,\mathbf{q}_2,\mathbf{q}_3\).
  4. Give the two products \(\mathbf{A}\mathbf{B}\) and \(\mathbf{B}\mathbf{A}\) for the noncommuting example and explain what they show.
  5. State both directions of the criterion for two real symmetric matrices to have a common orthonormal eigenbasis.

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