I'm trying to prove $P(\rho)={\rm tr}((\rho \otimes \rho')S)$, where $P(\rho)={\rm tr}(\rho^2)$ is the purity and $S$ is the swap operator. My question is that since ${\rm tr}(AB)={\rm tr}(BA)$, do we have $${\rm tr}((\rho \otimes \rho')S)={\rm tr}(S(\rho \otimes \rho'))={\rm tr}(\rho' \otimes \rho)={\rm tr}(\rho'){\rm tr}(\rho)\,?$$
However, I just cannot get a result that matches ${\rm tr}(\rho^2)$ by expanding $\rho$ in ${\rm tr}((\rho \otimes \rho')S)$ or ${\rm tr}(\rho'){\rm tr}(\rho)$.
