MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Multiplying permutations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg41749] RE: [mg41723] Multiplying permutations
  • From: "David Park" <djmp at earthlink.net>
  • Date: Wed, 4 Jun 2003 08:34:34 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Wolfgang,

Do you want to permute by VALUE or by POSITION?

Permuting by position is easier.

list = {1, 2, 3};
list2 = list[[{3, 1, 2}]]
list3 = list2[[{2, 1, 3}]]
{1, 2, 3}
{3, 1, 2}
{1, 3, 2}

Each element in the permutation list tells which slot from the previous list
to put in that slot. The initial list does not have to be numbers.

list = {a, q, r}
list2 = list[[{3, 1, 2}]]
list3 = list2[[{2, 1, 3}]]
{a, q, r}
{r, a, q}
{a, r, q}

But that is probably not what you want. To permute by value, and if we are
just using values that go from 1 to n, then we can get our rules by

p = {2, 1, 3};
Thread[Range[1, Length[p]] -> p]
{1 -> 2, 2 -> 1, 3 -> 3}

So we can write a definition...

ValPermute[perm_List][list_] := list /. Thread[Range[1, Length[perm]] ->
perm]

This now gives the result you were aiming for.

list = {1, 2, 3}
list2 = list // ValPermute[{3, 1, 2}]
list3 = list2 // ValPermute[{2, 1, 3}]
{1, 2, 3}
{3, 1, 2}
{3, 2, 1}

If you have non-integer values, then you have to write a different
ValPermute.

ValPermute2[perm_List][list_] := list /. Thread[{a, q, r} -> perm]

list = {a, q, r}
list2 = list // ValPermute2[{r, a, q}]
list3 = list2 // ValPermute2[{q, a, r}]
{a, q, r}
{r, a, q}
{r, q, a}

Maybe there is a way from Combinatorica that one of the experts will know.
Generally I think that working with position is better.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



From: Dr. Wolfgang Hintze [mailto:weh at snafu.de]
To: mathgroup at smc.vnet.net


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


  • Prev by Date: RE: Re: help converting mathtype to mathematica
  • Next by Date: Re: HTMLSave and Numbering
  • Previous by thread: RE: Multiplying permutations
  • Next by thread: Re: Multiplying permutations