# To prove that the dimension of $V$ is $d_1^2 + \ldots + d_k^2$

Let $A$ be an $n \times n$ diagonal matrix with characteristic polynomial $$(x - c_1)^{d_1} \cdots (x - c_k)^{d_k} ,$$ where $c_1,\ldots,c_k$ are distinct. Let $V$ be the space of $n \times n$ matrices $B$ such that $AB = BA$. Prove that the dimension of $V$ is $d_1^2 + \cdots + d_k^2$.

I am completely stuck on it. Can someone help me please? Thanks for your help.

• For what it is worth, the set $V$ is called the commutant of $A$. And it is a unital subalgebra of $M_n$, in general. Here, it is very easy to determine it as $A$ is diagonal. It is more annoying when $A$ is not diagonalizable. – Julien Apr 27 '13 at 14:57

1. If $AB = BA$, then $B$ maps each eigenspace of $A$ onto itself. (If $A v = c_{i} v$, then $A (B v) = B (A v) = B (c_{i} v) = c_{i} (B v)$.)
2. Restricted to the eigenspace $V_{i}$, of dimension $d_{i}$, relative to $c_i$, $A$ is a scalar matrix, so it commutes with all the $d_{i} \times d_{i}$ matrices on $V_{i}$.
Example Let $d_{1} = 2$, $d_{2} = 3$. Then $$A = \begin{bmatrix} c_1&&&\vert\\&&c_1&\vert\\\hline &&&\vert &c_2\\&&&\vert&&&c_2\\&&&\vert&&&&c_2 \end{bmatrix}.$$ If $B$ commutes with $A$, is has the block form $$B = \begin{bmatrix} H&\vert\\\hline&\vert&K \end{bmatrix},$$ where $H$ is an arbitrary $2 \times 2$ matrix, and $K$ is an arbitrary $3 \times 3$ matrix. So the space of such $B$'s has dimension $d_1^2 + d_2^2 = 2^2 + 3^2 = 13$.