Is centralizer of diagonalizable $A \in GL_n(\mathbb R)$ dense in the linear subspace $\{B: (AB-BA)e_1 = 0\}$ Let $A \in GL_n(\mathbb R)$ be a diagonalizable matrix. Let $C_A = \{B \in M_n(\mathbb R): AB=BA\}$ denote the set of centralizers of $A$. Let $\phi: M_n(\mathbb R) \to \mathbb R^n$ be a linear map defined by $C \mapsto (CA-AC)e_1$ where $e_1 = (1, 0, \dots, 0)^T$. Let $M_A = \text{ker}(\phi) = \{B \in M_n(\mathbb R): (BA-AB)e_1 = 0\}$. Then $C_A \subseteq M_A$. Is it possible that $C_A$ is dense in $M_A$?
 A: The dimension of $M_A := \ker(\phi)$ is at least $n^2-n$ by rank-nullity theorem applied to $\varphi: M_{n}(\mathbb{R})\to \mathbb{R}^n$. On the other hand, if $A$ is diagonalizable with eigenvalues $\lambda_1$, ..., $\lambda_r$ with respective multiplicities $n_1, ..., n_r$ (so $n_1 + n_2 + ... + n_r = n$), then the dimension of the centralizer:
$$
\dim C_A = n_1^2 + n_2^2 + ... + n_{r}^2
$$
This can be proved from the observation that any matrix $B$ which commutes with $A$ must leave each eigenspace of $A$ invariant (so $B$ can be represented as a block-diagonal matrix with $r$ blocks of size $n_1, n_2, ..., n_r$, and it is clear that the number of such matrices is $n_1^2+n_2^2+...+n_r^2$). 
If $r=1$, then $A$ is a scalar multiple of identity and the problem is easy to solve -- in this case $C_A=M_n(\mathbb{R})$. Suppose $r>1$. Then there at least 2 distinct eigenvalues, and
$$
n_1^2+n_2^2+...+n_r^2 \leq (n-1)^2+1^2 = n^2 - 2n + 2 < n^2-n
$$
for $n>2$. So $\dim(C_A) < \dim(M_A)$, and hence $C_A$ cannot be dense in $M_A$ (because it has a lower dimension).
When $n=2$ and $r=2$, then $\dim(C_A)=1^2+1^2 = 2 = n^2 - n\leq \dim(M_A)$, so there is a chance that the dimensions could coincide. I bet if you take a generic enough $2\times 2$ diagonalizable matrix (which will have distinct eigenvalues), then $\dim(M_A)$ will equal to $n^2-n=2$ which coincides with dimension of $C_A$, so in that case $C_A=M_A$. 
