Computing the dimension of a vector space of matrices that commute with a given matrix B, This is part $2$ of the question that I am working on.
For part $1$, I showed that the space of $5\times 5$ matrices which commute with a given matrix $B$, with the ground field = $\mathbb R$ , is a vector space.
But how can I compute its dimension?
Thanks,

Alternative approach. The space you are looking at is the kernel of the commutator map at $B$
$$\mathrm{Mat}_{5×5}(ℝ) → \mathrm{Mat}_{5×5}(ℝ),~A ↦ AB - BA,$$
which is $ℝ$-linear. You can easily compute the rank of this map by throwing in a basis of $\mathrm{Mat}_{5×5}(ℝ)$ and see what dimension the space is that their images generate. Then you can use the rank–nullity theorem. So it comes down to computing the dimension of the linear hull of some system of matrices.
