## All matrices over a field having a given characteristic polynomial are similar if and only if the polynomial is squarefree

Let $F$ be a field and let $p(x)$ be a polynomial over $F$ whose roots all lie in $K$. Prove that all matrices over $F$ having characteristic polynomial $p(x)$ are similar if and only if $p(x)$ is squarefree.

Suppose $p(x)$ has a repeated factor. Then there are at least two possible lists of elementary divisors whose product is $p(x)$; in particular there exist two matrices with characteristic polynomial $p(x)$ which are not similar. So if all matrices with characteristic polynomial $p(x)$ are similar, then $p(x)$ has no repeated factors.

Conversely, suppose $p(x)$ has no repeated factors. then there is only one possible list of elementary divisors, and so any two matrices having characteristic polynomial $p(x)$ are similar.