# 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 \ds \map \tr {\mathbf A_1 \mathbf A_2 \cdots \mathbf A_m} = \map {a_1} {i_1, i_2} \map {a_2} {i_2, i_3} \cdots \map {a_{m - 1} } {i_{m - 1}, i_m} \map {a_m} {i_m, i_1}$

where:

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

In $(1)$, the Einstein 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 Einstein summation convention by:

$\map c {i_1, j} = \map {a_1} {i_1, i_2} \map {a_2} {i_2, i_3} \cdots \map {a_{m - 1} } {i_{m - 1}, i_m} \map {a_m} {i_m, j}$

Thus for the diagonal elements:

$\ds \map c {i_1, i_1} = \map {a_1} {i_1, i_2} \map {a_2} {i_2, i_3} \cdots \map {a_{m - 1} } {i_{m - 1}, i_m} \map {a_m} {i_m, i_1}$

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

$\blacksquare$