<s>[INST] Commutative matrices of a square matrix Question: Find the all matrice that commute with $B=\begin{pmatrix}  b & 1 & 0 \\ 0 & b & 1 \\  0 & 0  & b \end{pmatrix}$. 
My work: 
Let $A=\begin{pmatrix}  a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \\  a_3 & b_3  & c_3 \end{pmatrix}$. 
Now from $AB=BA$ implies,
$\begin{pmatrix}  a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \\  a_3 & b_3  & c_3 \end{pmatrix} . \begin{pmatrix}  b & 1 & 0 \\ 0 & b & 1 \\  0 & 0  & b \end{pmatrix} 
=\begin{pmatrix}  b & 1 & 0 \\ 0 & b & 1 \\  0 & 0  & b \end{pmatrix}.\begin{pmatrix}  a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \\  a_3 & b_3  & c_3 \end{pmatrix}$
Then,
$\begin{pmatrix}  a_1b & a_1+bb_1 & b_1+c_1b \\ a_2b & a_2+bb_2 & b_2+c_2b \\  a_3b & a_3+bb_3 & b_3+c_3b\end{pmatrix} =\begin{pmatrix}  ba_1+a_2 & bb_1+b_2 & c_1b+c_2 \\ ba_2+a_3 & bb_2+b_3 & c_2b+c_3 \\ ba_3  & bb_3 & bc_3\end{pmatrix}$
Then, solving this,
$ a_1b= ba_1+a_2 \implies a_2=0$ 
$a_1+bb_1=bb_1+b_2 \implies a_1=b_2$
$b_1+c_1b=c_1b+c_2 \implies b_1=c_2$
$a_2b=ba_2+a_3 \implies a_3=0$
$a_2+bb_2=bb_2+b_3 \implies a_2=b_3$
$b_2+c_2b=c_2b+c_3 \implies b_2=c_3$
$a_3b=ba_3$
$a_3+bb_3= bb_3 \implies a_3=0$
$b_3+c_3b= bc_3 \implies b_3=0$.
Then, I am not sure about following setting.  Is it right or wrong?
$A=\begin{pmatrix}  a_1 & b_1 & ? \\ 0 & a_1=b_2 & b_1 \\  0 & 0  & c_3 \end{pmatrix}$. 
I was wondering if you could help to resolve this issue. I appreciate your time.
 [/INST] It is automatically true that $B$ commutes with any matrix of the form
$$  xI + y B + z B^2.  $$ Note that it is not necessary to consider $B^3$ or $B^4,$ as these can be absorbed into the given expression. 
The nontrivial theorem is that, when the minimal polynomial agrees with the characteristic polynomial, then the only matrices commuting with $B$ are those polynomial expressions in $B.$ That applies here, the condition is equivalent to this: each eigenvalue occurs in just one Jordan block.
In sum, you are still a little off. 
</s>