Trace of Product of Matrices

Theorem
Let $\struct {R, +, \circ}$ be a commutative ring.

Let $\mathbf A = \sqbrk a_{m n}$ be an $m \times n$ matrix over $R$.

Let $\mathbf B = \sqbrk b_{n m}$ be an $n \times m$ matrix over $R$.

Then:
 * $\map \tr {\mathbf A \mathbf B} = \map \tr {\mathbf B \mathbf A}$

where $\map \tr {\mathbf A}$ denotes the trace of $\mathbf A$.

Proof
Let $\mathbf A \mathbf B = \mathbf C = \sqbrk c_{m}$.

Let $\mathbf B \mathbf A = \mathbf D = \sqbrk d_{n}$.

Then by definition of matrix products:
 * $\ds \forall i, j \in \closedint 1 m: c_{i j} = \sum_{k \mathop = 1}^n a_{i k} \circ b_{k j}$
 * $\ds \forall i, j \in \closedint 1 n: d_{i j} = \sum_{k \mathop = 1}^m b_{i k} \circ a_{k j}$

Therefore: