TITLE: Given a matrix A, how to find  B such that AB=BA
QUESTION [10 upvotes]: Let $A = \begin{pmatrix}
1 &  1& 1\\ 
1 & 2 &3 \\ 
1 &4  & 5
\end{pmatrix}$ and  $D = \begin{pmatrix}
2 &  0& 0\\ 
0 & 3 &0 \\ 
0 &0  & 5
\end{pmatrix}$.
It is found that right-multiplication by D multiplies each column of A by the corresponding diagonal entry of D, whereas left-multiplication by D multiplies each row of A by the corresponding diagonal entry of D.
Construct a 3 x 3 matrix B, not the identity matrix or zero matrix, such that $AB=BA$.

REPLY [3 votes]: Notice that $A$ is diagonalizable, so any matirx with the same eigenvectors will commute with $A$, for example
$$B = \begin{pmatrix}
0.2481 & 0.31385 & -0.034765 \\ 
0.48816 & -0.65821 & 0.76725 \\ 
-0.20907 & 1.0811 & 0.28335
\end{pmatrix}$$