nested * and ** (rules for commutative quantities)

*To*: mathgroup at smc.vnet.net*Subject*: [mg7658] nested * and ** (rules for commutative quantities)*From*: mabi at solidmr.kun.nl (Marlies Brinksma)*Date*: Thu, 26 Jun 1997 01:36:45 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

Hello everybody, I'm having the following problem. I have a set of operators (let's call them Op[index_,arg2_]). Two of these operators commute when their indices are different and they are noncommutative otherwise. All operators commute with any scalar quantity. I would like to define some rules such that expressions like: Op[3,a] ** Op[2,v] ** 4 ** Op[6,s] ** Op[2,x] ** Op[1,t] will be automatically changed to: Times[4, Op[1,t],NonCommutativeMultiply[Op[2,v],Op[2,x]],Op[3,a],Op[6,s]] It seems to be very simple but I just cannot come to a set of rules which are general enough and don't lead to infinite recursion. Can anyone please help me? Thanks in advance for any help! Marlies Brinksma