Solution (source code)

= Solution

The definition of <matrix multiplication> gives
$$
\operatorname{Tr}(AB)=\sum_{i,j}a_{ij}b_{ji}=\sum_{j,i}b_{ji}a_{ij}=\operatorname{Tr}(BA).
$$
The middle equality uses commutativity of scalar multiplication in $\mathbb R$ or $\mathbb C$, together with interchange of finite sums. Thus \b[the trace is unchanged by cyclically moving the two factors].