Centralizer of certain matrices Let $M=M_{n}(\mathbb{F}_{q})$, is the $\mathbb{F}_{q}$-algebra of $n\times n$ matrices over the finite field of $q$ elements, $\mathbb{F}_{q}$. Let $X\in M$, be a matrix such that the characteristic polynomial of $X$, is same as its minimal polynomial. Let $f$ be the characteristic polynomial of $X$. Let $C_{M}(X)=\{ A\in M | AX=XA \} $. Clearly $C_{M}(X)$ is a subalgebra of $M$. Prove that 
$$C_{M}(X) \cong \frac{\mathbb{F}_{q}[t]}{(f)} $$
as $\mathbb{F}_{q}$-algebras.
I am having trouble in proving this! I have no clue how to prove this. Any kind of help will be highly appreciated.
Thanks!

Let $\mathbb F$ be the algebraic closure of $\mathbb F_q$. Since the characteristic and minimal polynomial of $X$ are the same over $\mathbb F$, we get that $X$ is diagonalizable: that is, $X=SDS^{-1}$, with $D$ diagonal and all diagonal entries of $D$ are distinct. Now let $A\in C_M(X)$. Let $A'=S^{-1}AS$. Then 
$$
A'D=S^{-1}ASS^{-1}XS=S^{-1}AXS=S^{-1}XAS=DA'. 
$$
From the fact that all diagonal entries of $D$ are distinct, we get that $A'$ is diagonal. Now choose a polynomial $p\in \mathbb F_q[t]$ such that $p(D_{jj})=A'_{jj}$. Then $A'=p(D)$, and 
$$
A=SA'S^{-1}=Sp(D)S^{-1}=p(SDS^{-1})=p(X). 
$$
Thus
$$
C_M(X)=\{p(X):\ p\in\mathbb F_q[t]\}.
$$
Now define $\pi:\mathbb F_q[t]/(f)\to C_M(X)$ by $\pi(p+(f))=p(X)$. We showed above that $\pi$ is surjective. If $\pi(p+(f))=0$, then $p(X)=0$, so $f|p$ and $p+(f)=(f)$; so $\pi$ is injective. It is easy to check that $\pi$ is an algebra homomorphism. 
