Given a Hermitian matrix $A$, what is the dimension of the set of all other Hermitian matrices $B$ such that $[A,B] = 0$.
It is clearly not the same for all $A$, but how can one find it for a given $A$.
Given a Hermitian matrix $A$, what is the dimension of the set of all other Hermitian matrices $B$ such that $[A,B] = 0$.
It is clearly not the same for all $A$, but how can one find it for a given $A$.
Let's start with the case where $A = \def\d{\mathrm{diag}}\d(\lambda_1, \ldots, \lambda_n)$ is diagonal. If now $B\in \def\C{\mathbf C}\C^{n \times n}$ is given, we have \begin{align*} AB &= \begin{pmatrix} \lambda_1 b_{11} & \lambda_1 b_{12} & \cdots & \lambda_1 b_{1n}\\ \vdots & & \ddots & \vdots\\ \lambda_n b_{n1} & \lambda_n b_{n2} & \cdots & \lambda_n b_{nn} \end{pmatrix}\\ BA &= \begin{pmatrix} \lambda_1 b_{11} & \lambda_2 b_{12} & \cdots & \lambda_n b_{1n}\\ \vdots & & \ddots & \vdots\\ \lambda_1 b_{n1} & \lambda_2 b_{n2} & \cdots & \lambda_n b_{nn} \end{pmatrix} \end{align*} That is, $B$ and $A$ commute, iff for each $i, j$ we have $$ \lambda_i b_{ij} = \lambda_j b_{ij} $$ That is, for each $i, j$ with $\lambda_i \ne \lambda_j$ we must have $b_{ij} = 0$.
Now suppose $A$ has $d$ of the $\lambda_i$ are different and have multiplicity $k_i$, $i = 1, \ldots, d$. So $\sum_i k_i = n$. For each $1 \le i \le d$, we can choose the corresponding $k_i \times k_i$ block of $B$ as an arbitray $k_i \times k_i$ hermitian matrix, hence for this block we have $2\binom{k_i}2 + k_i$ real dimensions. So alltogether, we have $$2\sum_i \binom{k_i}2 + \sum_i k_i = n + 2\sum_i \binom{k_i}2 $$ dimensions.
If $A$ is arbitrary, diagonalize $A$ by an unitary $U$. That is $U^*AU = D$, $D$ diagonal. Now note, that $B$ commutes with $A$ iff $U^*BU$ commutes with $U^*AU = D$ and $U^*BU$ is hermitian iff $B$ is. Hence, the spaces of matrices commuting with $A$ and with $D$ are isomorphic by means of $B \mapsto U^*BU$. So they have the same dimension. Hence we have proved: