The dimension of centralizer of a Matrix. 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.
 A: I don't think there's an easy way to do this.  I agree with the above comment that you should play with different matrices yourself.  I'm adding this mostly so you have a reference.  See: Nilpotent Orbits in Semisimple Lie Algebras by Collingwood, McGovern, Theorem 6.1.3.  The statement is:
Let $A$ be a nilpotent matrix, i.e. eigenvalues are all zero.  Its Jordan normal form is given by a partition of $n$, say $d_1 + \cdots + d_k$.  Then, one has that the dimension of the centralizer is 
$$\sum s_i^2$$
where $s_i = |\{j \mid d_j \geq i\}|$.  You can generalize this formula now to a general matrix $A$ in Jordan normal form (the blocks with different eigenvalues don't interact -- you can check quickly if you think of $A$ as acting by column/row operations), to get
$$\sum_\lambda \sum_i s_{i, \lambda}^2$$
where $\lambda$ ranges over all eigenvalues (generalized) and $s_{i, \lambda}$ as above.
Edit for experts: Okay, so, the way I would do this in general, is for a nilpotent element $x$, find $h$ such that $[h, x] = 2x$.  One can do this separately for each Jordan block; if $x$ is a Jordan block, then $h = diag(k, k-2, k-4, \ldots, 4-k, 2-k, -k)$.  One can complete this to an $\mathfrak{sl}_2$ triple by taking $y = x^t$, i.e. $(x, y, h)$ is a copy of $\mathfrak{sl}_2$.  Then, we can decompose $\mathfrak{g}$ into into eigenspaces for $ad(h)$, and note that in fact these are eigenspaces for various $\mathfrak{sl}_2$-representations, and the highest weights are killed by $x$ (i.e. in the centralizers).  So, we want to count representations, which one can do with some combinatorics (yielding the above formula) or just directly.  For example, in the above (or below) answer, $h = diag(1,-1,1,-1)$, and one has
$$\left(\begin{array}{cccc}0&2&0&2\\-2&0&-2&0\\0&2&0&2\\-2&0&-2&0\end{array}\right)$$
where the number is the $h$-weight of that eigenspace.  We count 4 weight 2 eigenspaces, 4 weight -2 eigenspaces, and 8 weight 0 eigenspaces, giving us a total of $4 + (8-4) = 8$ representations.  Explicitly, one has the decomposition $\mathfrak{g} = V(2)^{\oplus 4} \oplus V(0)^{\oplus 4}$ as $\mathfrak{sl}_2$ representations.
A: 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.
A: Here is an example with two Jordan blocks that have the same eigenvalue. If we had only a single Jordan block, the dimension resulting would be exactly $4,$ but this comes out a little bigger.  
$$
\left(
\begin{array}{rr|rr}
0 & 1 & 0 & 0 \\
0 & 0 & 0 & 0 \\ \hline
0 & 0 & 0 & 1 \\
0 & 0 & 0 & 0
\end{array}
\right)
\left(
\begin{array}{rrrr}
a & b & c & d \\
e & f & g & h \\
i & j & k & l \\
m & n & o & p
\end{array}
\right) =
\left(
\begin{array}{rrrr}
e & f & g & h \\
0 & 0 & 0 & 0 \\
m & n & o & p \\
0 & 0 & 0 & 0 
\end{array}
\right)
$$
$$
\left(
\begin{array}{rrrr}
a & b & c & d \\
e & f & g & h \\
i & j & k & l \\
m & n & o & p
\end{array}
\right) 
\left(
\begin{array}{rr|rr}
0 & 1 & 0 & 0 \\
0 & 0 & 0 & 0 \\ \hline
0 & 0 & 0 & 1 \\
0 & 0 & 0 & 0
\end{array}
\right) =
\left(
\begin{array}{rrrr}
0 & a & 0 & c \\
0 & e & 0 & g \\
0 & i & 0 & k \\
0 & m & 0 & o 
\end{array}
\right)
$$
At first glance, I get eight linear equations required for equality,
$$e,g,m,o = 0, \; a=f, c=h, i=n,k=p.  $$
Out of $16,$ what is left is dimension $8.$
$$
\left(
\begin{array}{rr|rr}
a & b & c & d \\
0 & a & 0 & c \\ \hline
i & j & k & l \\
0 & i & 0 & k
\end{array}
\right)
$$
Dimension $8$ for four little 2 by 2 Jordan blocks scattered about.
