Finding all matrices $B$ such that $AB=BA$ for a fixed matrix $A$

Let

$$A=\begin{pmatrix} 1 & 0 & 0 \\ 0& 1 & 0 \\ 3 & 1 & 2 \end{pmatrix}$$

Find all matrices $B$ such that $AB=BA$.

Attempt at solution: I can show that $A$ is invertible so its inverse must be one of the elements. But how do I go about showing there are more of them? or not?. I can set set up the unknown matrix to be a matrix with 9 unknowns and then (at least in principle) try to solve or this system. But I think this is not a very productive way to do this. If these were $2 \times 2$ matrces that would be ok. How should I proceed? Any hints?

Thanks for your time and help.

-
I'm afraid that there aren't many options here...but I really hope I'm wrong. – DonAntonio Feb 7 '13 at 3:26
There are cleaner ways to do this but they require more theory. – Qiaochu Yuan Feb 7 '13 at 3:35
@QiaochuYuan: Do you mean like, Diagonalizability, Jordan Canonical forms etc or something even more evil? – Jack Dawkins Feb 7 '13 at 3:43
Yes, diagonalizing $A$ makes everything much cleaner. (I didn't check whether $A$ had nontrivial Jordan blocks; if that was the case then those would need to be taken into account as well.) – Qiaochu Yuan Feb 7 '13 at 3:55
@user54755 For the given matrix, i.e. a $3 \times 3$ upper triangular matrix, it is not hard to actually work it out explicitly. You will get $7$ trivial equations and only $2$ relevant equations. – user17762 Feb 7 '13 at 3:58

Here's another approach. Notice that if $A$ and $B$ commute and if $C$ is any invertible matrix, then $C^{-1}AC$ and $C^{-1}BC$ commute. This is because $$(C^{-1}AC)( C^{-1}BC) = C^{-1}ABC = C^{-1}BAC = (C^{-1}BC)(C^{-1}AC).$$

If we let $C$ be the matrix consisting of eigenvectors of $A$, then one can calculate that $$CAC^{-1} = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0\\ 0 & 0& 2\end{bmatrix}.$$

So, what commutes with $CAC^{-1}$? Multiplying a matrix on the left by $CAC^{-1}$ multiplies the rows by $1$, $1$, and $2$ respectively. Multiplying a matrix on the right by $CAC^{-1}$ multiplies the columns by $1$, $1$, and $2$ respectively. The only way these can be equal is if the spots which are multiplied by both $1$ and $2$ are $0$. It follows that all of the matrices which commute with $CAC^{-1}$ have the form $$\begin{bmatrix} a & b & 0\\ c&d&0\\ 0&0&e\end{bmatrix}$$ and one easily checks that all of these do in fact commute with $C^{-1}AC$.

To turn this back into an answer for $A$ (instead of $C^{-1}AC$), multiply this general form on the left by $C$ and on the right by $C^{-1}$.

Doing this on maple, I find that the matrices which commute with $A$ are precisely those of the form $$\begin{bmatrix} a+c & \frac{1}{3}(a+c-b-d) & 0 \\ -3c & -c+d & 0 \\ -3a+3e & -a+b+e & e\end{bmatrix}.$$

-

Let $$B = \begin{bmatrix}b_{11} & b_{12} & b_{13}\\ b_{21} & b_{22} & b_{23}\\ b_{31} & b_{32} & b_{33} \end{bmatrix}$$ We have $$A = \begin{bmatrix}1 & 0 & 0\\ 0 & 1 & 0\\ 3 & 1 & 2 \end{bmatrix}$$ Hence, \begin{align} AB & = \begin{bmatrix}1 & 0 & 0\\ 0 & 1 & 0\\ 3 & 1 & 2 \end{bmatrix}\begin{bmatrix}b_{11} & b_{12} & b_{13}\\ b_{21} & b_{22} & b_{23}\\ b_{31} & b_{32} & b_{33} \end{bmatrix}\\ & = \begin{bmatrix}b_{11} & b_{12} & b_{13}\\ b_{21} & b_{22} & b_{23}\\ 3b_{11} + b_{21} +2b_{31} & 3b_{12} + b_{22} +2b_{32} & 3b_{13} + b_{23} +2b_{33} \end{bmatrix} \end{align} \begin{align} BA & = \begin{bmatrix}b_{11} & b_{12} & b_{13}\\ b_{21} & b_{22} & b_{23}\\ b_{31} & b_{32} & b_{33} \end{bmatrix}\begin{bmatrix}1 & 0 & 0\\ 0 & 1 & 0\\ 3 & 1 & 2 \end{bmatrix}\\ & = \begin{bmatrix}b_{11} + 3b_{13} & b_{12} + b_{13} & 2b_{13}\\ b_{21} + 3b_{23} & b_{22} + b_{23} & 2b_{23}\\ b_{31} + 3b_{33} & b_{32} + b_{33} & 2b_{33}\end{bmatrix} \end{align} Hence, we get that $$\begin{bmatrix}b_{11} & b_{12} & b_{13}\\ b_{21} & b_{22} & b_{23}\\ 3b_{11} + b_{21} +2b_{31} & 3b_{12} + b_{22} +2b_{32} & 3b_{13} + b_{23} +2b_{33} \end{bmatrix} = \begin{bmatrix}b_{11} + 3b_{13} & b_{12} + b_{13} & 2b_{13}\\ b_{21} + 3b_{23} & b_{22} + b_{23} & 2b_{23}\\ b_{31} + 3b_{33} & b_{32} + b_{33} & 2b_{33}\end{bmatrix}$$ This gives us $$b_{13} = b_{23} = 0$$ Hence, we have $$B = \begin{bmatrix} b_{11} & b_{12} & 0\\ b_{21} & b_{22} & 0 \\ 3(b_{33} - b_{11})-b_{21} & b_{33} - b_{22} - 3b_{12} & b_{33}\end{bmatrix}$$ where $b_{ij} \in \mathbb{R}$.

-
Hardly more productive than what the OP knew could be done...and "Nice hint", as requested.... :-/ – amWhy Feb 7 '13 at 3:54
@amWhy For the given matrix, i.e. a $3 \times 3$ upper triangular matrix, it is not hard to actually work it out explicitly. You will get $7$ trivial equations and only $2$ relevant equations. Right tools for the right task. – user17762 Feb 7 '13 at 4:00
I think there's some value in demonstrating to OP that the method they rejected as too difficult may not be as difficult as they expected. – MJD May 15 '13 at 1:10

$$A=\begin{pmatrix} 1 & 0 & 0 \\ 0& 1 & 0 \\ 3 & 1 & 2 \end{pmatrix}$$ $$A=\begin{pmatrix} 1 & 0 & 0 \\ 0& 1 & 0 \\ -3 & -1 & 1 \end{pmatrix}\begin{pmatrix} 1 & 0 & 0 \\ 0& 1 & 0 \\ 0 & 0 & 2 \end{pmatrix}\begin{pmatrix} 1 & 0 & 0 \\ 0& 1 & 0 \\ 3 & 1 & 1 \end{pmatrix}$$

This is the diagonalization of $A$, $A=PDP^{-1}$. Any diagonal matrix in place of $D$ gives a matrix that commutes with $A$. Using $B =PD_0P^{-1}$ : \begin{align} AB &= PDP^{-1}PD_0P^{-1} \\ &= PDD_0P^{-1} & \text{($P^{-1}P = I$)}\\ & = PD_0DP^{-1} &\text{(since diagonal matrices commute)}\\ & = PD_0P^{-1}PDP^{-1} \\ & = BA \end{align}

Lets now look at the full variable form: $$\begin{pmatrix} 1 & 0 & 0 \\ 0& 1 & 0 \\ -3 & -1 & 1 \end{pmatrix}\begin{pmatrix} \lambda_1 & 0 & 0 \\ 0& \lambda_2 & 0 \\ 0 & 0 & \lambda_3 \end{pmatrix}\begin{pmatrix} 1 & 0 & 0 \\ 0& 1 & 0 \\ 3 & 1 & 1 \end{pmatrix} = \begin{pmatrix} \lambda_1 & 0 & 0 \\ 0& \lambda_2 & 0 \\ -3\lambda_1 & -\lambda_2 & \lambda_3 \end{pmatrix}\begin{pmatrix} 1 & 0 & 0 \\ 0& 1 & 0 \\ 3 & 1 & 1 \end{pmatrix}$$ $$\begin{pmatrix} \lambda_1 & 0 & 0 \\ 0& \lambda_2 & 0 \\ -3\lambda_1 & -\lambda_2 & \lambda_3 \end{pmatrix}\begin{pmatrix} 1 & 0 & 0 \\ 0& 1 & 0 \\ 3 & 1 & 1 \end{pmatrix}= \begin{pmatrix} \lambda_1 & 0 & 0 \\ 0& \lambda_2 & 0 \\ -3\lambda_1+3\lambda_3 & -\lambda_2 + \lambda_3& \lambda_3 \end{pmatrix}$$

This gives $B$ as a function of the three variables $\lambda_1, \lambda_2$, and $\lambda_3$: $$B=\begin{pmatrix} \lambda_1 & 0 & 0 \\ 0& \lambda_2 & 0 \\ -3\lambda_1+3\lambda_3 & -\lambda_2 + \lambda_3& \lambda_3 \end{pmatrix}$$

And this general $B$ commutes with $A$.

-
But you assume that $B$ has the same eigenvectors as $A$ does. Why should this be true? – awllower Feb 7 '13 at 3:59
Yes, the $2 \times 2$ block identity does indeed give a non-trivial eigenspace... I maybe should not have implied that this is the only $B$ that may commute with $A$. – adam W Feb 7 '13 at 4:04

The matrix $A$ has eigenvalues $2,1,1$ and clean eigenvectors (one of them is $[0, 0, 1]$). This allows you to reduce the problem to $\Lambda \tilde{B} = \tilde{B} \Lambda$ where $\Lambda = \text{diag}(2,1,1)$. Since $\Lambda \tilde{B} \Lambda^{-1}$ seems simple enough you might try to directly solve this version.

A general solution seems to be \begin{align*} U \begin{pmatrix} & 0 & 0 \\ 0 & \\ 0 \end{pmatrix} U^{-1} \end{align*} where the unspecified parts are arbitrary and columns of $U$ are eigenvectors of $A$. Here is one possibility for $$U = \begin{pmatrix} 0 & -1/3 & -1/3 \\ 0 & 1 & 0 \\ 1 & 0 & 1\end{pmatrix}$$

-