Re: Multiplying permutations
- To: mathgroup at smc.vnet.net
- Subject: [mg41838] Re: Multiplying permutations
- From: "Dr. Wolfgang Hintze" <weh at snafu.de>
- Date: Fri, 6 Jun 2003 09:51:16 -0400 (EDT)
- References: <bbhvu4$75u$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
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
>
>