# 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?

Before proving $AB$ and $BA$ have the same characteristic polynomials show that if $A_{m\times n}$ and $B_{n\times m}$ then characteristic polynomials of $AB$ and $BA$ satisfy following statement: $$x^n|xI_m-AB|=x^m|xI_n-BA|$$ therefore easily conclude if $m=n$ then $AB$ and $BA$ have the same characteristic polynomials.
Define $$C = \begin{bmatrix} xI_m & A \\B & I_n \end{bmatrix},\ D = \begin{bmatrix} I_m & 0 \\-B & xI_n \end{bmatrix}.$$ We have
\begin{align*} \det CD &= x^n|xI_m-AB|,\\ \det DC &= x^m|xI_n-BA|. \end{align*}
and we know $\det CD=\det DC$ if $m=n$ then $AB$ and $BA$ have the same characteristic polynomials.