1

Suppose I have a word $\{1,2\}$, then $l(\{1,2\}) = \{[1,2]\} = \{1,2\} - \{2,1\}:=12-21$ and for the word with length $3$, (I will omit bracket), the $l$-operation is defined as $ l(1,2,3) = [[1,2],3] = [12-21,3]=123-312-213+321$ thus for general $n$ word $l(1,2,3,4,5,\cdots n) = [[[1,2],3],4] \cdots, n]$ How one can implement through mathematica?

Similar way, I can define $r-$operation as $r(1,2,3,\cdots, n) = [1,[2,[3,\cdots, [n-1,n]\cdots ]]]$

For small number, I can do by hand but for large number, I mean for given arbitrary array, Is there a way to implement commutators?

phy_math
  • 873
  • 4
  • 9

1 Answers1

3

We can use Fold and use ExpandNCM follow Expansion on sums of NonCommutativeMultiply

ExpandNCM[expr_] := 
  expr /.
   {(h : NonCommutativeMultiply)[a___, b_Plus, c___] :> 
     Distribute[h[a, b, c], Plus, h, Plus, 
      ExpandNCM@*h], (h : NonCommutativeMultiply)[a___, b_Times, 
      c___] :> Most[b] ExpandNCM[h[a, Last[b], c]]};
Fold[#1 ** #2 - #2 ** #1 &, Range[3]] // ExpandNCM

1 ** 2 ** 3 - 2 ** 1 ** 3 - 3 ** 1 ** 2 + 3 ** 2 ** 1

cvgmt
  • 72,231
  • 4
  • 75
  • 133
  • How about $r-$ operations? I am trying to build $r-$ operations from Fold, but having trouble understanding fold operations.. – phy_math Mar 18 '21 at 07:47
  • 1
    I figured out! I noticed the relation between $l-$ operations and $r-$ operations, so construct functions >> l[x_] := ExpandNCM[Fold[#1 ** #2 - #2 ** #1 &, x]] and r[x_] based on your ExpandNCM! – phy_math Mar 18 '21 at 08:22