Re: Multiplying permutations
- To: mathgroup at smc.vnet.net
- Subject: [mg41844] Re: Multiplying permutations
- From: "Carl K. Woll" <carlw at u.washington.edu>
- Date: Sat, 7 Jun 2003 00:08:35 -0400 (EDT)
- Organization: University of Washington
- References: <bbhvu4$75u$1@smc.vnet.net> <bbq8rg$d91$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Wolfgang, Just add the attributes Flat and OneIdentity to CenterDot, as follows: SetAttributes[CenterDot,{Flat,OneIdentity}] p_\[CenterDot]q_:=q[[p]] and everything should work nicely. Carl Woll Physics Dept U of Washington "Dr. Wolfgang Hintze" <weh at snafu.de> wrote in message news:bbq8rg$d91$1 at smc.vnet.net... > How can I define multiple products recursively? > > Example permutations > > p = {3, 1, 2}; > q = {2, 1, 3}; > r = {3, 2, 1}; > > Carl's defintion of the product > > p_·q_ := q[[p]] > > works fine for 2 factors: > > In[237]:= > p · q > > Out[237]= > {3, 2, 1} > > Now let's try 3 factors > > In[240]:= > p · q · r > > Out[240]= > {3, 1, 2} · {2, 1, 3} · {2, 3, 1} > > Using brackets we get what we want > > In[265]:= > (p · q) · r > p · (q · r) > > Out[265]= > {1, 3, 2} > > Out[266]= > {1, 3, 2} > > Despite of the associativeness of the product we need brackets. > Hence if we define for 3 factors > > In[242]:= > p_ · q_ · r_ := (p · q) · r > > we can get > > In[278]:= > p · q · r > > Out[278]= > {1, 3, 2} > > But a product of 4 factors still is not defined. > Question: How can a general recursive definition be given? > > Wolfgang > > > > Dr. Wolfgang Hintze wrote: > > > Is there a simple command in Mathematica to multiply two permutations, > > i.e. to carry out one after the other? > > > > I looked at the packages DiscreteMath`Permutations` and > > DiscreteMath`Combinatorica` but couldn't find it. > > > > Example > > > > p = {3,1,2} mapping: 1->3, 2->1, 3->2 > > q = {2,1,3} mapping: 1->2, 2->1, 3->3 > > p.q = mappings (p first, then q) > > [1-p->3-q->3, 2-p->1-q->2, 3-p->2-q->1] > > = {3,2,1} > > > > Any help appreciated > > > > Wolfgang > > > > >