<s>[INST] Do matrices $ AB $ and $ BA $ have the same minimal and characteristic polynomials? 
Let $ A, B $ be two square matrices of order $n$. Do $ AB $ and $ BA $ have same minimal and characteristic polynomials?

I have a proof only if $ A$ or $ B $ is invertible. Is it true for all cases?
 [/INST] Yes, $AB$ and $BA$ have the same characteristic polynomial.
Basic facts: $\det(A^T) = \det(A)$, $\det(AB) = \det(A) \det(B)$

*

*$A$ and $A^T$ share the same characteristic polynomial.

\begin{align*}
\det(xI-A) = \det((xI-A)^T) = \det(xI-A^T)
\end{align*}


*Similar matrices have the same characteristic polynomial. If $B = PAP^{-1}$,

\begin{align*}
\det(xI - B) &= \det(xI - PAP^{-1}) \\
&= \det(P(xI - A)P^{-1}) \\
&= \det(P)\det(xI - A)\det(P^{-1}) \\
&= \det(xI - A)
\end{align*}


*Determinant of a block triangular matrix:

\begin{align*}
\det \begin{pmatrix}A & B \\0 & C\end{pmatrix} = \det(A) \det(C)
\end{align*}
Using block multiplication, please verify that $\begin{pmatrix}I & -A \\0 & I\end{pmatrix} \begin{pmatrix}AB & 0 \\B & 0\end{pmatrix} = \begin{pmatrix}0 & 0 \\B & BA\end{pmatrix} \begin{pmatrix}I & -A \\0 & I\end{pmatrix}$.
Therefore, the matrices $\begin{pmatrix}AB & 0 \\B & 0\end{pmatrix}$ and $\begin{pmatrix}0 & 0 \\B & BA\end{pmatrix}$ are similar, and have the same characteristic polynomial.
\begin{align*}
\det\left[x\begin{pmatrix}I & 0 \\0 & I\end{pmatrix} - \begin{pmatrix}AB & 0 \\B & 0\end{pmatrix}\right] &= \det(xI - AB) \det(xI)
\end{align*}
\begin{align*}
\det\left[x\begin{pmatrix}I & 0 \\0 & I\end{pmatrix} - \begin{pmatrix}0 & 0 \\B & BA\end{pmatrix}\right] &= \det(xI) \det(xI - BA)
\end{align*}
And there it is. But $AB$ and $BA$ do not need to have the same minimal polynomial. See Jim's answer for a counterexample.
</s>