# Simultaneous diagonalization of two matrices if one does not has $n$ independent eigenvectors

I have a small confusion. Suppose there are two $$n \times n$$ matrices $$A$$ and $$B$$ such that $$A$$ does not has $$n$$ independent eigenvectors. The $$A$$ is not diagonalizable. But $$A$$ and $$B$$ commute and I can find a matrix that diagonalizes $$B$$. Doesn't this violate that $$A$$ is diagonalizable because the same matrix also diagonalizes $$A$$ which diagonalizes $$B$$.

Two such matrices are:

$$A$$ $$\begin{matrix} 1 & 0 & 1 \\ 0 & 0 & 0 \\ 1 & 0 & 1 \\ \end{matrix}$$

$$B$$ $$\begin{matrix} 2 & 1 & 1 \\ 1 & 0 & -1 \\ 1 & -1 & 2 \\ \end{matrix}$$

• Sorry, but I don't see what the problem is here. – Lord Shark the Unknown Oct 2 '18 at 17:17
• The problem is that A is not diagonalizable but the fact that A commutes with B allows me to diagonalize A using the matrix which diagonalizes B. – Ankur Singh Oct 2 '18 at 17:23
• But your $A$ has three independent eigenvectors. Why did you say it didn't? – Lord Shark the Unknown Oct 2 '18 at 17:25
• If the rank of an $n\times n$ matrix is $n-k$, that just gives us $k$ independent eigenvectors to the eigenvalue $0$: the basis of the nullspace. – Misha Lavrov Oct 2 '18 at 17:34
• real symmetric matrices are always diagonalizable. They are also congruence diagonalizable, in that there is a real matrix $P$ with $\det P = 1$ and $P^T A P = D$ is diagonal. The diagonal entries of $D$ will not usually be eigenvalues of $A,$ but do obey Sylvester Inertia. – Will Jagy Oct 2 '18 at 17:55

In your example, matrices $$A$$ and $$B$$ are both diagonalizable (and both have $$n$$ independent eigenvectors), so it's not an instance of the thing you're describing:

• $$A$$ has eigenvector $$(1,0,1)$$ to the eigenvalue $$2$$, and eigenvectors $$(0,1,0)$$ and $$(1,0,-1)$$ to the eigenvalue $$0$$.
• $$B$$ has eigenvector $$(1,-2,-1)$$ to the eigenvalue $$-1$$, eigenvector $$(1,1,-1)$$ to the eigenvalue $$2$$, and eigenvector $$(1,0,1)$$ to the eigenvalue $$3$$.

(Also, since $$A$$ and $$B$$ are both symmetric in this example, we know in advance that they should be diagonalizable.)

But in general, no: just because $$A$$ commutes with $$B$$ and $$B$$ is diagonalizable, doesn't mean that $$A$$ is diagonalizable (in the same basis that diagonalizes $$B$$, or otherwise). For instance, any matrix (diagonalizable or otherwise) commutes with the zero matrix and the identity matrix.

Also, the Jordan form of a matrix lets us write it as $$D + N$$ in some basis, where $$D$$ is diagonal, $$N$$ is nilpotent (and therefore not diagonalizable in general) and $$D$$ commutes with $$N$$, giving us a whole slew of counterexamples.

• The eigenvalues are 2 and 0 with multiplicity 1 and 2 respectively. – Ankur Singh Oct 2 '18 at 17:40
• Thanks for the correction. – Misha Lavrov Oct 2 '18 at 17:40