Find all matrices that commute with $A$

By just writing out the matrix multiplication and simplifying you get: \begin{align*} AB &= BA\\ \begin{bmatrix} 3 & 1 &0 \\ 0 &3 & 1\\ 0 &0 & 3 \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} \\ b_{31} & b_{32} & b_{33} \\ \end{bmatrix} \begin{bmatrix} 3 & 1 &0 \\ 0 &3 & 1\\ 0 &0 & 3 \end{bmatrix}\\ \begin{bmatrix} 3b_{11} + b_{21} & 3b_{12} + b_{22} & 3b_{13}+b_{23} \\ 3b_{21} + b_{31} & 3b_{22} + b_{32} & 3b_{23}+b_{33} \\ 3b_{31} & 3b_{32} & 3b_{33} \end{bmatrix} &= \begin{bmatrix} 3b_{11} & b_{11}+3b_{12} & b_{12} + 3b_{13} \\ 3b_{21} & b_{21}+3b_{22} & b_{22} + 3b_{23} \\ 3b_{31} & b_{31}+3b_{32} & b_{32} + 3b_{33} \end{bmatrix} \\ \begin{bmatrix} b_{21} & b_{22} & b_{23} \\ b_{31} & b_{32} & b_{33} \\ 0 & 0 & 0 \end{bmatrix} &= \begin{bmatrix} 0 & b_{11} & b_{12} \\ 0 & b_{21} & b_{22} \\ 0 & b_{31} & b_{32} \end{bmatrix} \end{align*} Hence, $b_{21},b_{31},b_{32}=0$, $b_{11}=b_{22}=b_{33}$ and $b_{12}=b_{23}$, confirming the solutions are exactly those given by Robert.


Since$$A=3\operatorname{Id}_3+\begin{pmatrix}0&1&0\\0&0&1\\0&0&0\end{pmatrix}$$and every matrix commutes with $3\operatorname{Id}_3$, you're after the matrices that commute with$$\begin{pmatrix}0&1&0\\0&0&1\\0&0&0\end{pmatrix}.\tag1$$A simple computation shows that\begin{multline}\begin{pmatrix}a&b&c\\d&e&f\\g&h&i\end{pmatrix}\begin{pmatrix}0&1&0\\0&0&1\\0&0&0\end{pmatrix}-\begin{pmatrix}0&1&0\\0&0&1\\0&0&0\end{pmatrix}\begin{pmatrix}a&b&c\\d&e&f\\g&h&i\end{pmatrix}=\\=\begin{pmatrix}d & e-a & f-b \\ g & h-d & i-e \\ 0 & -g & -h\end{pmatrix}\end{multline}and therefore the matrix$$\begin{pmatrix}a&b&c\\d&e&f\\g&h&i\end{pmatrix}$$commutes with $(1)$ if and only if$$\left\{\begin{array}{l}d=g=h=0\\a=e=i\\f=b.\end{array}\right.$$Therefore, the answer to your question is:$$\left\{\begin{pmatrix}a&b&c\\0&a&b\\0&0&a\end{pmatrix}\,\middle|\,a,b,c\in\mathbb{R}\right\}.$$


Polynomials in $A$ always commute with $A$. In this case these will be upper triangular with constant diagonals, i.e. $$ \pmatrix{a & b & c\cr 0 & a & b\cr 0 & 0 & a}$$ You'll want to show that these are all the solutions.