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}_{(i_1, i_2)} {a_2}_{(i_2, i_3)} \cdots {a_{m-1}}_{(i_{m-1}, i_m)} {a_m}_{(i_m, i_1)}$

where $\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_{(i_1, j)} = {a_1}_{(i_1, i_2)} {a_2}_{(i_2, i_3)} \cdots {a_{m-1}}_{(i_{m-1}, i_m)} {a_m}_{(i_m, j)}$

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

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