Trace of Matrix Product/General Result

Theorem
Let $\mathbf A_1, \mathbf A_2, \ldots, \mathbf A_m$ be square matrices of order $n$.

Let $\mathbf A_1 \mathbf A_2 \cdots \mathbf A_m$ be the (conventional) matrix product of $\mathbf A_1, \mathbf A_2, \ldots, \mathbf A_m$.

Then:
 * $(1): \quad \displaystyle \operatorname{tr} \left({\mathbf A_1 \mathbf A_2 \cdots \mathbf A_m}\right) = a_1 \left({i_1, i_2}\right) a_2 \left({i_2, i_3}\right) \cdots a_{m-1} \left({i_{m-1}, i_m}\right) a_m \left({i_m, i_1}\right)$

where:
 * $a_1 \left({i_1, i_2}\right)$ (for example) denotes the element of $\mathbf A_1$ whose indices are $i_1$ and $i_2$
 * $\operatorname{tr} \left({\mathbf A_1 \mathbf A_2 \cdots \mathbf A_m}\right)$ denotes the trace of $\mathbf A_1 \mathbf A_2 \cdots \mathbf A_m$.

In $(1)$, the summation convention is used, with the implicit understanding that a summation is performed over each of the indices $i_1$ to $i_m$.

Proof
Let $\mathbf C = \mathbf A_1 \mathbf A_2 \cdots \mathbf A_m$

From Product of Finite Sequence of Matrices, the general element of $\mathbf C$ is given in the summation convention by:
 * $c \left({i_1, j}\right) = a_1 \left({i_1, i_2}\right) a_2 \left({i_2, i_3}\right) \cdots a_{m-1} \left({i_{m-1}, i_m}\right) a_m \left({i_m, j}\right)$

Thus for the diagonal elements:
 * $\displaystyle c \left({i_1, i_1}\right) = a_1 \left({i_1, i_2}\right) a_2 \left({i_2, i_3}\right) \cdots a_{m-1} \left({i_{m-1}, i_m}\right) a_m \left({i_m, i_1}\right)$

which is the summation convention for the trace of $\mathbf C$.