# Diagonalizing Matrices

Show that if $A$ and $B$ are two $n \times n$ matrices that both have the same diagonalizing matrix $X$, then $AB = BA$

I have the following answer, I just don't understand it completely. Can someone help explain it to me?

$X^{−1}AX = D$

$X^{−1}BX = E$

$X^{−1}ABX = DE = ED = X^{−1}BAX$ Therefore: $AB = BA$

The third step is where I get confused.

• Here $X$ is a non-singular matrix, then you may multiply $X$ to the left side and multiply $X^{-1}$ to the right. Mar 22 '13 at 2:19
• Checking your title for typos goes a loooooong way to asking a nice question. Mar 22 '13 at 2:20

$$X^{−1}ABX = \underbrace{X^{−1}AX}_{D}\underbrace{X^{−1}BX}_{E}$$

and diagonal matrices commute, so $DE = ED$

• @julien I am not sure what you are saying, I only use that $X$ is non-singular and that $E$ and $D$ are diagonal matrices. Mar 22 '13 at 3:02
• What I am saying actually does not make any sense. My weak English is playing me some tricks tonight. Sorry. Mar 22 '13 at 3:16

Since $ED = DE$, you have $X(ED) X^{-1} = X(DE) X^{-1}$. Also, $I = X^{-1} X$, so we have \begin{eqnarray} X(ED) X^{-1} &=& XEID X^{-1} \\ &=& XEX^{-1} XD X^{-1} \\ &=& BA \\ &=& X(DE) X^{-1} \\ &=& XDIE X^{-1} \\ &=& XDX^{-1} XE X^{-1} \\ &=& AB \end{eqnarray}

($ED = DE$ because any two diagonal matrices commute.)

• Your last $BA$ should be $AB$. Mar 22 '13 at 3:41
• @julien: Thanks! Feel free to edit. My typing skills are pedestrian, so I cut and paste a lot... Mar 22 '13 at 3:44
• You are very welcome! Mar 22 '13 at 5:00

The third step is not right. May not always be true that $X^{-1}ABX={X^{-1}BAX}$.
If $AB\ne{BA}$, then for example if $AB = U$, $BA = V$ and $X^{-1}UX\ne{X^{-1}VX}$.
Also matrices $D$ and $E$ are not diagonal.