# What is the dimension of the vector space over C of matrices that such AB = BA?

Let A $\in C^{4 \times 4}$ be a diagonal matrix with exactly three distinct entries on its diagonal.

1) What is the dimension of the vector space W over C of matrices that are polynomial in A?

Attempt: If A = \begin{bmatrix} c_{1} & 0 & 0 & 0 \\ 0 & c_{1} & 0 & 0 \\ 0 & 0 & c_{2} & 0 \\ 0 & 0 & 0 & c_{3} \end{bmatrix}

then g(A) = \begin{bmatrix} g(c_{1}) & 0 & 0 & 0 \\ 0 & g(c_{1}) & 0 & 0 \\ 0 & 0 & g(c_{2}) & 0 \\ 0 & 0 & 0 & g(c_{3}) \end{bmatrix}

So {$E_{11} + E_{22}, E_{33}, E_{44}$} span W, so dim W = 3.

2) What is the dimension of the vector space W over C of matrices B $\in C^{4 \times 4}$ such that AB = BA.

Attempt: If B commutes with A, then the eigenspaces of A must be invariant under B as well. So in the eigenbasis of A, B = \begin{bmatrix} C & 0 & 0 \\ 0 & a & 0 \\ 0 & 0 & b \end{bmatrix}

for a 2$\times$2 matrix C. So dim W $\le$ 6. Can we limit it further?

We cannot limit the subspace $W$ further since any matrix of that form will commute with $A$, as can quickly be verified with block-matrix multiplication $$AB = \pmatrix{c_1I\\&\pmatrix{c_2\\&c_3}} \pmatrix{C\\&\pmatrix{a\\&b}} = \pmatrix{c_1C\\&\pmatrix{c_2a\\&c_3b}} \\ \pmatrix{C\\&\pmatrix{a\\&b}} \pmatrix{c_1I\\&\pmatrix{c_2\\&c_3}} = BA$$
For 1, the answer is simple in general: the degree of the minimal polynomial of $A$.
To prove this you can show that of the degree of the minimal polynomial $\mu$ is $n$ then
• By dividing any polynomial to $\mu(x)$ and plugging $A$ into the the relation you get, you obtain that $I, A,..., A^{n-1}$ span $W$.
• If you have a linear recurrence of $I,A,..., A^{n-1}$ which is zero the corresponding polynomial has to be divisible by $\mu$. This shows linearly independence.
For the given matrix, the minimal polynomial is $\mu(x)=(x-c_1)(x-c_2)(x-c_3)$, so the dimension is $3$.