matrix – Making Mathematica use the cyclicity of the trace to simplify expressions

You can try the following formulation of the trace and dot product that can be simplified using TensorReduce

Assuming(Element(a | b, Matrices({n, n})), 
 TensorReduce(
  TensorContract(TensorProduct(a,b), {{2, 3}, {1, 4}}) - 
   TensorContract(TensorProduct(b,a), {{2, 3}, {1, 4}})))
(*0*)

This proves $$mathrm{Tr}(acdot b)=mathrm{Tr}(bcdot a).$$

A more complicated example would be

Assuming(Element(a | b | c, Matrices({n, n})), 
 TensorReduce(
  TensorContract(TensorProduct(a, b, c), {{2, 3}, {4, 5}, {1, 6}}) - 
   TensorContract(TensorProduct(b, c, a), {{2, 3}, {4, 5}, {1, 6}})))
(*0*)

which proves

$$mathrm{Tr}(acdot bcdot c)=mathrm{Tr}(bcdot ccdot a).$$