# Hermitian matrices that commute

My question is:

If $A$ and $B$ are two Hermitian matrices, and $AB$ is also a Hermitian matrix, then how do prove that both $A$ and $B$ are diagonalizable through the same unitary matrix (i.e the unitary matrix that diagonalizes $A$, diagonalizes $B$ as well).

It is obvious that in order for $AB$ to be Hermitian, $A$ and $B$ have to commute, i.e: $AB=BA$. Can anyone tell me how to prove that the same unitary matrix that diagonalizes $A$, diagonalizes $B$ as well?

-
It's not quite true as you stated. For a stupid example, if $A$ is $I$ and $B$ is any non-diagonal Hermitian matrix, then $I$ diagonalizes $A$, but won't diagonalize $B$. What is true is that some matrix will diagonalize both. In the generic case when $A$ and $B$ both have distinct eigenvalues, then I think it's true that if a matrix diagonalizes $A$ it must diagonalize $B$, but I'll have to think about it a bit more. – Jason DeVito Feb 29 '12 at 2:39
@Jason: Yes, if $A$ has all distinct eigenvalues, then a matrix that diagonalizes $A$ will also diagonalize $B$. A matrix that commutes with a diagonal matrix with distinct diagonal entries is diagonal. A slight generalization of this came up here and a somewhat more general version is here. – Jonas Meyer Mar 8 '12 at 18:31

The orthogonal projections on eigenspaces of $A$ and of $B$ can be written as polynomials in $A$ and $B$ respectively, so they commute with each other and with $A$ and $B$. The nonzero products of an orthogonal eigenspace projection for $A$ and an eigenspace projection for $B$ are orthogonal projections on subspaces of ${\mathbb C}^n$ where $A$ and $B$ both act as multiples of the identity matrix. Take an orthonormal basis whose members are all in those subspaces, and the matrices for $A$ and $B$ in that basis will both be diagonal.