Let $K$ be a field and $A\in M_n(K)$ be a Jordan canonical form.
I tried to find the dimension of $C(A)$ where $C(A)$ is the space of all matrices that commutes with $A$.
I think I solved this question, but I'm not confident. Could someone see my answer below and tell me if it is correct? If this is correct, what can be said about $\dim C(A)$ when $A$ is not necessarily triangularizable?
Let $a$ be an eigenvalue of $A$. Then, the generalized eigenspace corresponding to $a$ is stable under the transformation of $B$. Actually, if $(A-a)^nx=0$, $(A-a)^nBx=B(A-a)^nx=0$.
Because of this, we only have to consider the case where $A$ has only one eigenvalue. Moreover, we can assume that the only eigenvalue is zero, because $C(A)=C(A+a)$ for $a\in K$.
Now, $A$ is the form $\operatorname{diag}\{J_{d_1}, \ldots, J_{d_k}\}$ where $J_p$ is the nilpotent Jordan block of dimension $p$. Each $J_{d_s}(s=1,\ldots, k)$ has a corresponding subspace $V_s=\operatorname{span}\{e_{d_1+\ldots+d_{s-1}+1},\ldots, e_{d_1+\ldots+d_{s}}\}\subset K^n$ of dimension $d_s$ and obviously, $K^n=\oplus V_s$. Let $i_s$ be an inclusion $V_s\rightarrow K^n$ and $p_s$ be a projection $K^n\rightarrow V_s$.
$B\in C(A)$ is equivalent to $p_s\circ B\circ i_t\circ J_{d_t}$ and $J_{d_s}\circ p_s\circ B\circ i_t$ for all $s, t=1,\ldots, k$. Since the space of possible $p_s\circ B\circ i_t$ has a dimension $\min\{d_s, d_t\}$, $\dim C(A)=\Pi \min\{d_s, d_t\}$
I used these two pages as references: How to find the set of all matrices that commute with a given matrix? and What commutes with a matrix in Jordan canonical form?.