<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] I believe there is a simpler way, a path which makes the calculations easier.
Write $B$ in the form
$B = \begin{bmatrix} b & 1 & 0 \\
0 & b & 1 \\ 0 & 0 & b \end {bmatrix} = bI + N, \tag 1$
where
$N = \begin{bmatrix} 0 & 1 & 0 \\
0 & 0 & 1 \\ 0 & 0 & 0 \end {bmatrix}; \tag 2$
then
$AB = BA \tag 3$
becomes
$A(bI + N) = (bI + N)A \Longrightarrow bA + AN = bA + NA \Longrightarrow AN = NA; \tag 4$
with
$A = \begin{bmatrix} a_1 & a_4 & a_7 \\
a_2 & a_5 & a_8 \\ a_3 & a_6 & a_9 \end {bmatrix}, \tag 5$
equation
$AN = NA \tag 6$
yields
$\begin{bmatrix} a_1 & a_4 & a_7 \\
a_2 & a_5 & a_8 \\ a_3 & a_6 & a_9 \end {bmatrix} \begin{bmatrix} 0 & 1 & 0 \\
0 & 0 & 1 \\ 0 & 0 & 0 \end {bmatrix} = \begin{bmatrix} 0 & 1 & 0 \\
0 & 0 & 1 \\ 0 & 0 & 0 \end {bmatrix} \begin{bmatrix} a_1 & a_4 & a_7 \\
a_2 & a_5 & a_8 \\ a_3 & a_6 & a_9 \end {bmatrix}, \tag 7$
or
$\begin{bmatrix} 0 & a_1 & a_4 \\
0 & a_2 & a_5 \\ 0 & a_3 & a_6 \end {bmatrix} = \begin{bmatrix} a_2 & a_5 & a_8 \\ a_3 & a_6 & a_9 \\ 0 & 0 & 0 \end {bmatrix}; \tag 8$
comparing entries of these two matrices we find
$a_2 = a_3 = a_6 = 0, \tag 9$
$a_1 = a_5 = a_9, \; a_4 = a_8, \tag{10}$
and $a_7$ unconstrained (that is, arbitrary).
Thus we have $A$ taking the form
$A = \begin{bmatrix} a & c & d \\
0 & a & c \\ 0 & 0 & a \end {bmatrix} = aI + cN + dN^2, \tag{11}$
for
$N^2 = \begin{bmatrix} 0 & 1 & 0 \\
0 & 0 & 1 \\ 0 & 0 & 0 \end {bmatrix} \begin{bmatrix} 0 & 1 & 0 \\
0 & 0 & 1 \\ 0 & 0 & 0 \end {bmatrix} = \begin{bmatrix} 0 & 0 & 1 \\
0 & 0 & 0 \\ 0 & 0 & 0 \end {bmatrix}; \tag{12}$
again, $a$, $c$, and $d$ may be freely selected.  It is evident that matrices of the form (12) commute with $B$, since each is a polynomial in $N$.
</s>