# Trace permutation of product of symmetric matrices

It is well known that the trace of a product of matrices is invariant under cyclic permutations. However, in general this is not true for arbitrary permutations. So, if $A,B,C$ are $n \times n$ matrices then $\mathrm{Tr}(ABC)$ is not necessarily equal to $\mathrm{Tr}(ACB)$.

However, if we assume $A,B,C$ to also be symmetric, then using the fact that the trace is invariant to taking transpose (as well as cyclic permutations) we obtain $$\mathrm{Tr}(A^TB^TC^T) = \mathrm{Tr}(A^T(CB)^T) = \mathrm{Tr}((CB)^TA^T) =\mathrm{Tr}((ACB)^T) = \mathrm{Tr}(ACB).$$ And, in fact, this allows us to show that the trace of a product of 3 matrices is preserved by taking any permutation of the product.

For products of more than 4 matrices, some permutations will not preserve the trace. Still, when all matrices involved in the product are symmetric there are more permutations preserving the trace, than just the cyclic permutations.

Is there a complete characterization for which permutations preserve the trace of a product of $n$ symmetric matrices?

Fix $n\geq 3$ and for $1\leq i\leq n$ let $s^i$ denote the $n\times n$ matrix whose $(i,i+1)$ and $(i+1,i)$ entries are $1$, taking $i+1=1$ for $i=n$, and whose other entries are $0$. Then $$\operatorname{Tr}(s^{1,2} s^{2,3} \cdots s^{n-1, n} s^{n, 1})=1.$$
Note $s^{i}s^{j}=0$ unless $j\in\{i-1,i,i+1\}$ modulo $n$. If a permutation $\pi$ fixes the trace, then $\pi(i+1)=\pi(i)\pm 1$ modulo $n.$ This force $\pi$ to be a dihedral pemutation.