When can a matrix be diagonalized?

If your n x n matrix has n distinct eigenvalues, you know already that the corresponding eigenvectors are linearly independent, so the matrix can be diagonalized.

If your n x n matrix has fewer than n distinct eigenvalues, it may or may not be diagonalizable – it depends on the dimensions of its eigenspaces. Here's how that works.

There are two important numbers associated with each eigenvalue.

For any matrix A with an eigenvalue λk

the algebraic multiplicity of λk is the number of times the factor (λ– λk) appears in the characteristic polynomial of A

the geometric multiplicity of λk is the dimension of its eigenspace.

The relevant point:

The geometric multiplicity of any eigenvalue is always less than or equal to its algebraic multiplicity.

Proof. (omitted)

The algebraic multiplicities of all the eigenvalues (real or complex) of an n x n matrix add up to n, the degree of its characteristic polynomial. To get enough linearly independent eigenvectors, then, none of the eigenvalues can be complex, and each eigenspace must have the maximum possible dimension, equal to the algebraic multiplicity of its eigenvalue. If any eigenspace has geometric multiplicity less than its algebraic multiplicity, then the matrix cannot be diagonalized.

When can a matrix be diagonalized?

A square matrix can be diagonalized if and only if

all its eigenvalues are real

the geometric multiplicity of each eigenvalue equals its algebraic multiplicity.

Proof. (omitted)

For example, suppose the characteristic polynomial of a 7 x 7 matrix is p(λ) = –2(λ – 3)2(λ – 1)5. The eigenvalues are 3 and 1. If the eigenspace for the eigenvalue 1 has dimension 4, the matrix cannot be diagonalized, since the eigenspace for the eigenvalue 3 has dimension at most 2, giving a total of only 6 linearly independent eigenvectors, not 7.