TransWikia.com

l,r-operations on words $[[[1,2],3],4] cdots, n]$, $[1,[2,[3,cdots, [n-1,n]cdots ]]]$

Mathematica Asked on March 26, 2021

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?

One Answer

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

Correct answer by cvgmt on March 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP