TITLE: Prove:$A B$ and $B A$ has the same characteristic polynomial.
QUESTION [9 upvotes]: Suppose $A B$ are all $n\times n$ matrix. Prove:$A B$ and $B A$ has the same characteristic polynomial.

If A is invertible


\begin{align}P(A B)=|\lambda  E-A B|=\left|\lambda  A\cdot A^{-1}-A B\right|=\left|A\left(\lambda  A^{-1}-B\right)\right|=\left|A\left\|\text{$\lambda $A}^{-1}-B\right.\right|\end{align}
\begin{align}P(B A)=|\lambda  E-B A|=\left|\lambda  A^{-1}\cdot A-B A\right|=\left|\left(\lambda  A^{-1}-B\right)A\right|=\left|\left.\text{$\lambda $A}^{-1}-B\right\|A\right|\end{align}

Is it true?


If A is not invertible


How to prove?
Edit:
I found a proof by Block Matrix Multiplication, it's more straightforward, is it right?
\begin{align}\left(
\begin{array}{cc}
 E & 0 \\
 -A & E \\
\end{array}
\right).\left(
\begin{array}{cc}
 \lambda  E & B \\
 \lambda  A & \lambda  E \\
\end{array}
\right)=\left(
\begin{array}{cc}
 \lambda  E & B \\
 0 & \lambda  E-A B \\
\end{array}
\right)\end{align}
\begin{align}\left(
\begin{array}{cc}
 \lambda  E & B \\
 \lambda  A & \lambda  E \\
\end{array}
\right).\left(
\begin{array}{cc}
 E & 0 \\
 -A & E \\
\end{array}
\right)=\left(
\begin{array}{cc}
 \lambda  E-B A & B \\
 0 & \lambda  E \\
\end{array}
\right)\end{align}
Another proof is by Sylvester determinant theorem which uses LU block decomposition.

REPLY [15 votes]: Fill two matrices $A$ and $B$ with $2n^2$ distinct indeterminates. Observe $A$ and $B$ are invertible in the field $F=K(a_{ij},b_{ij})$ formed by adjoining these formal variables. Hence $\chi_{AB}(T)=\chi_{BA}(T)$ holds in the field $F[T]$ and so in the subring $K[a_{ij},b_{ij}][T]$, after which we can simply apply the evaluation map so that $\chi_{AB}(T)=\chi_{BA}(T)$ holds for any two matrices $A$ and $B$ with entries taken in $K$.
The beauty of this "universal" argument is that it bypasses the analytic concept of density, instead working purely algebraically and applying to any desired field $K$.