Prove:$A B$ and $B A$ has the same characteristic polynomial. [duplicate]
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$.
If $A$ is not invertible, $A_t=A+tI_n$ is invertible except for finitely many values of $t$. In particular, there is $\varepsilon > 0$ such that $A_t$ is invertible for every $t\in ]0,\varepsilon[$.
We therefore have $P(A_tB)=P(BA_t)$. Making $t\to 0$, we deduce $P(AB)=P(BA)$.
One way to do this is to note that $P(AB)-P(BA)$ is a polynomial in the entries of $A$ and $B$. You have shown that this vanishes for all invertible $A$, and want to show that it is precisely the zero polynomial. It suffices to note that the set of invertible $n\times n$ matrices over $\mathbb R$ or $\mathbb C$ is dense, and since polynomials are continuous it follows that $P(AB)-P(BA)$ is zero everywhere and thus the zero polynomial.