TITLE: Prove that $\operatorname{trace}(ABC) = \operatorname{trace}(BCA) = \operatorname{trace}(CAB)$
QUESTION [9 upvotes]: Prove that $\operatorname{trace}(ABC) = \operatorname{trace}(BCA) = \operatorname{trace}(CAB)$ if $A,B,C$ matrices have the same size.

REPLY [2 votes]: I will help you by proving that $\text{tr}(AB) = \text{tr}(BA)$ for a $m \times n$ matrix $A$ and a $n \times m$ matrix $B$  first. Let $C = AB$ and $D = BA$. Then using the definition of matrix multiplication we find that $c_{ij} = \sum_{k=1}^{n} a_{ik}b_{kj}$ and $d_{ij} = \sum_{m=1}^{n} b_{im}a_{mj}$. Then, 
\begin{align*}
\text{tr}(C) & = \sum_{m = 1}^n c_{mm} \\ & = \sum_{m=1}^n\sum_{k=1}^na_{mk}b_{km} \\ & =
\sum_{k=1}^n\sum_{m=1}^nb_{km}a_{mk} \\ & = 
\sum_{k=1}^nd_{kk} \\ & = \text{tr}(D).
\end{align*}
Now, for $ABC$ take $AB = A_1$ and $C = A_2$ and apply the idenity proven above.