<s>[INST] How can I find all the matrices that commute with this matrix? 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.
 [/INST] If
$B:= \left( \begin{matrix} 0 & 0 & 0 \\ 0 & 0 & 0 \\ 0 & 0 & 1 \end{matrix} \right)$, 
then your matrix becomes $A = 2I + B$. Thus a matrix $C$ will commute with $A$ if and only if $C$ commutes with $B$. But note
$BC = \left( \begin{matrix} 0 & 0 & 0 \\ 0 & 0 & 0 \\ 0 & 0 & 1 \end{matrix} \right)\left( \begin{matrix} a & b & c \\ d & e & f \\ g & h & i \end{matrix} \right) = \left( \begin{matrix} 0 & 0 & 0 \\ 0 & 0 & 0 \\ g & h & i \end{matrix} \right)$
and 
$CB = \left( \begin{matrix} a & b & c \\ d & e & f \\ g & h & i \end{matrix} \right) \left( \begin{matrix} 0 & 0 & 0 \\ 0 & 0 & 0 \\ 0 & 0 & 1 \end{matrix} \right) = \left( \begin{matrix} 0 & 0 & c \\ 0 & 0 & f \\ 0 & 0 & i \end{matrix} \right)$.
It follows that $BC = CB$ if and only if $c=f = g = h = 0$
</s>