The dimension of centralizer $\gamma=\{B\in M_n(\mathbb{R}):AB=BA\}$ 
Let $A$ be a $6\times 6$ matrix with charpoly $x(x+1)^2(x-1)^3$. We need to find the dimension of $$\gamma=\{B\in M_n(\mathbb{R}):AB=BA\}.$$

What is the relation of charpoly of $A$ with dimension of the space? Please give me some hints to proceed.
 A: As I commented, Centralizer of a Matrix is very helpful. Let $\mathbb{F}$ be a field and $A\in M_n(\mathbb{F})$. Denote by $C_A=\{B\in M_n(\mathbb{F}) | AB=BA\}$ the centralizer of $A$. the dimension of such space $C_A$ over a field $\mathbb{F}$ is given by
$$
\sum_p (\mathrm{deg}(p)) \sum_{i,j}\min (\lambda_{p,i}, \lambda_{p,j}),
$$
where $p$ is an irreducible polynomial that divides the characteristic polynomial of $A$, and $\lambda_p= \sum \lambda_{p,i}$ with $\lambda_{p,i}$ being the powers of $p$ in the primary decomposition of the $\mathbb{F}[x]$-module $\mathbb{F}^n$ acting by $A$-multiplication. 
In your case, $\mathrm{deg}(p)$ is always $1$,  $n=6$, and $\mathbb{F}=\mathbb{R}$. Then the primary decomposition of $\mathbb{R}[x]$-module acting by $A$-multiplication is one of:
$$
 \frac{\mathbb{R}}{(x)} \oplus \begin{cases} \frac{\mathbb{R}}{(x+1)}\oplus \frac{\mathbb{R}}{(x+1)} \oplus \begin{cases} \frac{\mathbb{R}}{(x-1)}\oplus \frac{\mathbb{R}}{(x-1)}\oplus \frac{\mathbb{R}}{(x-1)} : \mathrm{case \ I}\\ \frac{\mathbb{R}}{(x-1)}\oplus \frac{\mathbb{R}}{(x-1)^2}: \mathrm{case \ II} \\ \frac{\mathbb{R}}{(x-1)^3} : \mathrm{case \ III}\end{cases}\\ \frac{\mathbb{R}}{(x+1)^2} \oplus \begin{cases} \frac{\mathbb{R}}{(x-1)}\oplus \frac{\mathbb{R}}{(x-1)}\oplus \frac{\mathbb{R}}{(x-1)} : \mathrm{case \ IV}\\ \frac{\mathbb{R}}{(x-1)}\oplus \frac{\mathbb{R}}{(x-1)^2} : \mathrm{case \ V}\\ \frac{\mathbb{R}}{(x-1)^3} : \mathrm{case \ VI}\end{cases}\end{cases}
$$
Denote by $J(\lambda, r)$ the Jordan block of size $r\times r$ with eigenvalue $\lambda$. Also, $I_r$ is the identity matrix of size $r\times r$. 
Now, the following characterizes all possibilities: 
Case I: The matrix $A$ is diagonalizable and similar to 
$$
0I_1 \oplus (-1)I_2 \oplus 1I_3. 
$$
The minimal polynomial of $A$ is $x(x+1)(x-1)$. 
The dimension of $\gamma$ is $1+2^2+3^2 = 15$. 
Case II: The matrix $A$ is similar to 
$$
0I_1 \oplus (-1)I_2 \oplus I_1\oplus J(1,2).
$$
The minimal polynomial of $A$ is $x(x+1)(x-1)^2$. 
The dimension of $\gamma$ is $1+2^2+5 = 10$. 
Case III: The matrix $A$ is similar to 
$$
0I_1 \oplus (-1)I_2 \oplus J(1,3).
$$
The minimal polynomial of $A$ is $x(x+1)(x-1)^3$. 
The dimension of $\gamma$ is $1+2^2+3=8$. 
Case IV: The matrix $A$ is similar to 
$$
0I_1\oplus J(-1,2) \oplus I_3.
$$
The minimal polynomial of $A$ is $x(x+1)^2(x-1)$. 
The dimension of $\gamma$ is $1+2+3^2=12$. 
Case V: The matrix $A$ is similar to 
$$
0I_1 \oplus J(-1,2) \oplus I_1 \oplus J(1,2).
$$
The minimal polynomial of $A$ is $x(x+1)^2(x-1)^2$. 
The dimension of $\gamma$ is $1+2+5=8$. 
Case VI: The matrix $A$ is similar to 
$$
0I_1 \oplus J(-1, 2) \oplus J(1,3).
$$
The minimal polynomial of $A$ is $x(x+1)^2(x-1)^3$. 
The dimension of $\gamma$ is $1+2+3=6$. 
This case VI is when the characteristic polynomial and the minimal polynomial coincide. In general, with $A\in M_n(\mathbb{F})$, the centralizer of $A$ has minimal dimension $n$ in case the characteristic polynomial and the minimal polynomial of $A$ are identical. 
