# Matrices commuting with diagonal matrix, 3 distinct diagonal entries.

Hopefully I have the right idea?

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

What is the dimension of the vector space over $\mathbb{C}$ of matrices $B\in\mathbb{C}^{4\times4}$ such that $AB=BA$? If $B\in\mathbb{C}^{4\times4}$ is a diagonal matrix with exactly 3 distinct entries on its main diagonal, is $B$ similar to a polynomial in $A$?

Another way to formulate this is to let $T_A\colon\mathbb{C}^4\to\mathbb{C}^4$ via $T_A(B) = AB-BA,$ and we wish to find the dimension of the null space $N$ of $T_A.$

For example, let's say

$$A = \left[\begin{array}{cc|cc} a&&&\\ &a&&\\ \hline &&b&\\ &&&c \end{array}\right].$$

Then we need $B$ to commute with each $2\times 2$ block. In the upper left block, we have a scalar multiple of the identity, so everything commutes and this has dimension $4$. For the lower right block, we need $B$ to be diagonal there (dimension $2$). So then $\dim N = 6.$

As for the second question, I feel like the answer is no, but I am struggling to come up with a counterexample.

## 1 Answer

Let us call the distinct elements that lie on the diagonal of $B$ by $a',b',c'$ (where $a'$ appears twice on the diagonal of $B$). We can find a polynomial $p \in \mathbb{C}[X]$ such that $p(a) = a', p(b) = b', p(c) = c'$. Then

$$p(A) = \operatorname{diag}(p(a),p(a),p(b),p(c)) = \operatorname{diag}(a',a',b,c)$$

is diagonal with the same values on the diagonal as $B$, possibly in different order. Hence, $p(A)$ is similar to $B$ via a permutation matrix.