I am interested in defining a function, say $\mathrm{Tra}$, that imply operators without build-in meaning, say it involves products with the $\cdot$ (Esc . Esc
), not assumed commuatative.
I want to mimic a trace for it, the main property being cyclic invariance, which I expect to use to simplify expressions. Now I face a syntax problem: the last two operators being the same, as is in general, when one wants to impose some invariance.
esq[A_CenterDot] := RotateLeft@A (*rotates to the CenterDot-product*)
Tra[A_Plus] :=Tra[#] & /@ A (*make Tra additive*)
Tra[A_CenterDot] := Tra[esq[A]]
Second line I've learnt from this answer by Jules Lamers, mutatis mutandis.
With last command I was expecting $ \mathrm{Tra}(x\cdot y\cdot y\cdot x\cdot y\cdot x) $ to yield $ \mathrm{Tra}(x\cdot x \cdot y\cdot y\cdot x\cdot y)$ (with only one left shift, but see below the aimed lexicographic order).
But this of course gives a loop instead. In general,
how does one correct this?
if possible: how to deal with situations when "the two last arrows of the commutative diagram are the same operation"?
is there an way out to defining relations at the level of the algebra just before evaluating this "trace"? What is meant is: assuming that $\mathrm{Tra}: A \to \mathbb k$, for any $n$, here there is a commuting pentagon (joining the first and last $A^n$ at the same node)
$A^n \stackrel{left-shift}{\to} A^n \stackrel{\cdot}{\to} A \stackrel{Tra}{\to} \mathbb k\stackrel{Tra}{\leftarrow } A \stackrel{\cdot}{\leftarrow} A^n $
Edit: After the comment(s): I wish the routine to stop, say, after the lexicographic-like order is reached. All x
before y
and the highest power of x
showing up first, independently of what happens thereafter. So, inside the Tra-operator:
- $ x \cdot y\cdot x \cdot x \to x\cdot x \cdot x \cdot y $ (cyclicity allows here to group all the
x
together) - $ y \cdot y\cdot y \cdot x \to x\cdot y \cdot y\cdot y $
- $ x\cdot y \cdot x\cdot y\cdot y \cdot x \cdot x \to x \cdot x \cdot x\cdot y \cdot x\cdot y\cdot y $ (this cannot be tested with
OrderedQ
, will almost always false)
Output example is then:
$\mathrm{Tra}[ y \cdot y\cdot y \cdot x + x\cdot y \cdot y\cdot y ] \to 2\mathrm{Tra}[x\cdot y \cdot y\cdot y]$
since the second line above makes Tra additive, but need not be. It suffices that $\mathrm{Tra}[ y \cdot y\cdot y \cdot x]$ is replaced by $ \mathrm{Tra}[x\cdot y \cdot y\cdot y]$ in order to simplify.
The issue with the lexicographic for the non-commutative product order is that the test in the given answer will be always false, unless there is no interlaced y
's and x
's, but that's the exception.
RotateLeft
IF ...” or “it should stop applyingRotateLeft
IF ...”. You say something about “arrows in the commutative diagram” but I don’t know how to relate that to your expressions. In other words, you show the desired output for theTra
sample expression. Can you explain why that should be the desired output and not, say, one that was rotated twice, or not rotated at all? $\endgroup$OrderedQ[RotateLeft[ x\[CenterDot]y\[CenterDot]y\[CenterDot]x\[CenterDot]y\[CenterDot]\ x, #]] & /@ Range[6]
$\endgroup$