Does equality of characteristic polynomials guarantee equivalence of matrices?

I have a qualifying exam coming up in a couple days and I am just trying to understand some pathological examples I have in my notes. I will list a similar problem which I know the solution to and then the question.

True or False: let $A,B \in \mathbb{Q}^{n \times n }$ Suppose $xI-A$ and $xI-B$ are equivalent then $\det(xI-A) = \det(xI-B)$.

I wrote in my notes this is true because any two matrices are equivalent in $\mathbb{Q[x]}^{n \times n}$ if and only if they have the same invariant factors. Since the characteristic polynomial is a product of the invariant factors it follows that $\det(xI-A) = \det(xI-B)$.

True or False: let $A,B \in \mathbb{Q}^{n \times n }$. If $\det(xI-A) = \det(xI-B)$ (in $\mathbb{Q}[x]$) then $xI-A$ and $xI-B$ are equivalent in $\mathbb{Q}[x]^{n \times n}$

I think this is false because of the fact that equality of determinants is not strong enough to guarantee all invariant factors are equal but I do not have an example.

-
$\begin{pmatrix}1&0\\0&1\end{pmatrix}$ and $\begin{pmatrix}1&1\\0&1\end{pmatrix}$ have the same characteristic polynomial, but are not similar. – J. M. Aug 10 '11 at 9:00
The characteristic polynomial is not preserved by these operations. – Pierre-Yves Gaillard Aug 10 '11 at 9:08
@user7980: Under that notion of equivalence, two matrices are equivalent if and only if they have the same rank. – Jonas Meyer Aug 10 '11 at 9:20
In the same vein as J. M.’s comment, I suggest, dear user7980, the following exercise: Which n by n matrices have the same characteristic polynomial as the zero matrix? – Pierre-Yves Gaillard Aug 10 '11 at 9:39
No, you cannot. If $A$ and $B$ are the two example matrices from the comment by J.M., then the characteristic polynomials are the same. The invariant factors of $xI-A$ are both $x-1$, but the invariant factors of $xI-B$ are $1$ and $(x-1)^2$. Hence $xI-A$ and $xI-B$ are not in that relation $B=PAQ$ for any invertible matrices $P,Q$ with entries in $\mathbf{Q}[x]$. – Jyrki Lahtonen Aug 10 '11 at 10:02

You've been given easy examples to show that the characteristic polynomial does not suffice to determine similarity of matrices. Here's a nice related problem:

Proposition. If $n\leq 3$, then two matrices are similar if and only if they have the same characteristic polynomial and the same minimal polynomial.

Proof. That similar matrices have the same characteristic and minimal polynomials is immediate. Assume now that $A$ and $B$ are $n\times n$ matrices with the same minimal and characteristic polynomials; we aim to show that $A$ and $B$ are similar.

The result is trivial for $n=1$.

If the characteristic polynomial splits, then we have three cases: either the characteristic polynomial splits into distinct linear factors, in which case both matrices are diagonalizable with the same eigenvalues, hence similar; or the characteristic polynomial has repeated factors. If the characteristic polynomial is equal to a pure power (either $(x-a)^2$ or $(x-a)^3$, then the minimal polynomial completely determines the Jordan canonical form of the matrix: diagonalizable if the minimal polynomial is $(x-a)$; a block of size $2\times 2$ (and one of size $1\times 1$ if $n=3$) if the minimal polynomial is $(x-a)^2$; and a single Jordan block of size $3\times 3$ if the minimal polynomial is $(x-a)^3$; hence the two matrices have the same Jordan canonical form, and so they are similar. If the minimal polynomial is of the form $(x-a)^2(x-b)$ with $a\neq b)$, then the two matrices are diagonalizable if the minimal polynomial is $(x-a)(x-b)$; and both have a Jordan canonical form consisting of a $2\times 2$ block associated to $a$ and a $1\times 1$ block associated to $b$ if the minimal polynomial is $(x-a)^2(x-b)$. Either way, the two matrices have the same Jordan canonical form, hence they are similar.

If the characteristic polynomial does not split, then it is either irreducible cubic, or a product of an irreducible quadratic and a linear factor; either way, the characteristic polynomial must equal the minimal polynomial, so the two matrices have the same rational canonical form, hence they are similar. QED

However, as soon as you get to $4\times 4$ matrices, the result is no longer true. Specifically, the matrices $$\left(\begin{array}{cccc} 0 & 1 & 0 & 0\\ 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 1\\ 0 & 0 & 0 & 0 \end{array}\right)\qquad\text{and}\qquad \left(\begin{array}{cccc} 0 & 1 & 0 & 0\\ 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 \end{array}\right)$$ both have characteristic polynomial $x^4$ and minimal polynomial $x^2$, but since their Jordan canonical forms are different, they are not similar.

So: the characteristic polynomial by itself suffices to determine similarity only in the trivial $1\times 1$ case; the characteristic and the minimal together determine similarity in the $2\times 2$ and $3\times 3$ cases. After that, the minimal and characteristic may completely determine similarity in some instances, but generally do not suffice.

As for equivalence, as noted, two matrices are equivalent if and only if they have the same rank. The $4\times 4$ matrices above have different ranks, hence they are not equivalent, but the same characteristic and minimal polynomials,

-