TITLE: Are there non-commuting matrices for which $\mathrm{tr}(ABC)=\mathrm{tr}(BAC)$?
QUESTION [6 upvotes]: For linear operators $A,B$ acting on $\mathbb{C}^n$ the fact that $\text{tr}(AB)=\text{tr}(BA)$ follows from the cyclic property of the trace, which says more generally that if $A,B,C$ are linear operators acting on $\mathbb{C}^n$ we have that $$\text{tr}(ABC)=\text{tr}(CAB)=\text{tr}(BCA)=\text{tr}(ABC).$$
My question is whether there are specific conditions on $A$, $B$, and $C$ such that $$\text{tr}(ABC)=\text{tr}(BAC)?$$ Clearly, its true if $A$ and $B$ commute, but its also sufficient for either $A$ or $B$ to commute with $C$, but are these necessary for this property to hold?
I should mention that I am primarily interested in the case that $A,B,C$ are invertible, since clearly if $A,B,C$ have zero divisors the property can be satisfied in a trivial sort of way.

REPLY [3 votes]: it's worth mentioning an important special case that comes up e.g. in semi-definite programming.
Suppose $A,B,C$ are arbitrary real symmetric matrices, then
$\text{trace}\Big(ABC\Big)$
$=\text{trace}\Big(BCA\Big)$
$=\text{trace}\Big(\big(BCA\big)^T\Big)$
$=\text{trace}\Big(A^TC^TB^T\Big)$
$=\text{trace}\Big(ACB\Big)$
$=\text{trace}\Big(BAC\Big)$
(This proof of course formally works the same when all 3 are complex symmetric)