TITLE: How can I find all the matrices that commute with this matrix?
QUESTION [9 upvotes]: I would like to find all the matrices that commute with the following matrix
$$A = \begin{pmatrix}2&0&0\\ \:0&2&0\\ \:0&0&3\end{pmatrix}$$
I set $AX = XA$, but still can't find the solutions from the equations.

REPLY [4 votes]: Block matrices provide an immediate insight. Let
$$A = \left[\begin{array}{l}2&0&0\\0&2&0\\0&0&3\end{array}\right] = \left[\begin{array}{l|l}a&0\\\hline0&3\end{array}\right]$$
The submatrix $a = 2I_2$. Now define the block matrix 
$$X = \left[\begin{array}{l|l}b&0\\\hline0&c\end{array}\right]$$ with conformal block sizes. That is, $c=constant$ and 
$$b = \left[\begin{array}{l}b_{11}&b_{12}\\b_{21}&b_{22}\end{array}\right] $$
has arbitrary complex elements.
The equation to solve is
$$[A,X] = AX - XA = \left[\begin{array}{l|l}a&0\\\hline0&3\end{array}\right] \left[\begin{array}{l|l}b&0\\\hline0&c\end{array}\right] - \left[\begin{array}{l|l}b&0\\\hline0&c\end{array}\right] \left[\begin{array}{l|l}a&0\\\hline0&3\end{array}\right] =  \left[\begin{array}{l|l}0&0\\\hline0&0\end{array}\right]$$
We have two equations:
$$ b a =  a b$$
$$ 3c = 3c$$
The second equation is trivial: $c$ is arbitrary. The first equation is just
$$ 2bI_{2} = 2 I_{2} b$$
Since the identity matrix commutes with every matrix, the $b$ matrix is arbitrary.
To conclude, the solution matrix has five arbitrary complex numbers arranged so:
$$X = \left[\begin{array}{ll|l}b_{11}&b_{12}&0\\b_{21}&b_{22}&0\\\hline0&0&c \end{array}\right] $$
One sees the benefit of this form in analyzing matrices of the form
$$A = \left[\begin{array}{l}c_{i} I_{i}&0&0 & 0\\0&c_{j}I_{j}&0 & 0\\0&0&c_{k}I_{k} & 0 \\ 0 & 0 & 0 & \ddots\end{array}\right]$$