TITLE: The dimension of centralizer of a Matrix.
QUESTION [11 upvotes]: Let $A$ be a $n\times n$ matrix with characteristic polynomial 
 $$(x-c_{1})^{{d}_{1}}(x-c_{2})^{{d}_{2}}...(x-c_{k})^{{d}_{k}}$$ where $c_{1},c_{2},...,c_{k}$ are distinct. Let $V$ be the space of $n\times n$ matrics $B$ such that $AB=BA$. How to find dimension of this vector space? Clearly it is easy to find dimension if the matrix $A$ is given diagonalizable  but how to find dimension if matrix $A$ is not diagonalizable. I tried it by using Jordan canonical form but its very lengthy and only gives possible dimensions. Can some one suggest how to find by giving a particular  matrix.

REPLY [4 votes]: And, in case you were wondering, here's the case for two Jordan blocks of sizes $3$ and $2$.
The centralizer of
$$ \left[ \begin {array}{ccccc} \lambda&1&0&0&0\\0&\lambda&1&0&0
\\ 0&0&\lambda&0&0\\ 0&0&0&\lambda&1
\\ 0&0&0&0&\lambda\end {array} \right] 
$$
consists of matrices of the form
$$ \left[ \begin {array}{ccccc} b_{{3,3}}&b_{{2,3}}&b_{{1,3}}&b_{{2,5}}&
b_{{1,5}}\\ 0&b_{{3,3}}&b_{{2,3}}&0&b_{{2,5}}
\\ 0&0&b_{{3,3}}&0&0\\0&b_{{5,3}}
&b_{{4,3}}&b_{{5,5}}&b_{{4,5}}\\0&0&b_{{5,3}}&0&b_{
{5,5}}\end {array} \right] 
$$
More generally, if you have Jordan blocks with the same
eigenvalue for indices $i, \ldots, j$ and $k, \ldots, l$, for
a matrix in the centralizer  the block formed by rows $i,\ldots, j$ and columns 
$k, \ldots, l$ will be "upper triangular" (i.e. $0$ for $row - column > \min(i-k, j-l)$) and constant on diagonals.  The dimension for this block
is then $\min(l-k+1,j-i+1)$, and you have to add this up for all blocks.