This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
 MATHEMATICA TUTORIAL Related Tutorials »| Functions »

# Permutation Lists

A possible way of working with permutations is by relating them to the reorderings of the elements of a list. This is the standard point of view in the combinatorial approach to permutations, which shifts the emphasis to the permuted expressions, rather than the permutations themselves. This has always been an implicit interpretation of permutation lists in Mathematica, reorderings of Range[n] for some non-negative integer n. Several standard functions in Mathematica allow basic manipulation of permutation lists and now other functions have been added to work with permutation lists and convert them into their disjoint cyclic form.
 PermutationListQ validate a list of integers as reordering of PermutationSupport points moved by a permutation

Basic functionality for permutation lists.

This is a list of 10 integers.
 Out[1]=
Check that it is indeed a reordering of consecutive integers starting at 1.
 Out[2]=
The support of the permutation list is the list of points not at their natural positions.
 Out[3]=
If the list of integers is sorted, its support is empty.
 Out[4]=
Permutation lists can be converted into disjoint cyclic form and vice versa. This is similar to the functions ToCycles and FromCycles in the Combinatorica package in improved form.
 PermutationCycles convert permutation into disjoint cyclic form PermutationList convert permutation into a permutation list

Conversion to and from cyclic form.

Take a permutation list.
 Out[5]=
Construct the cyclic form of the permutation list. By default, singletons are removed.
 Out[6]=
Choosing any other head keeps singletons.
 Out[7]=
Compare with the following. Note that the cycles are returned in reversed form.
 Out[9]=
Vice versa, you can convert a cyclic object into a permutation list of any length.
 Out[10]=
By default the length is taken to be the largest integer present in the cycles.
 Out[11]=
The same function allows changing the length of a permutation list without changing its support.
 Out[12]=
 Out[13]=
Permutation lists can be used to permute the parts of an expression with the functions Part and Permute. The difference is that, depending on the length of the permutation list, Part may change the number of arguments of the expression, but Permute never changes it.
 Part return a subexpression, possibly reordering its elements Permute permute elements of an expression as given by a permutation FindPermutation compute the permutation that takes the first list to the second

Permuting expressions.

Take an expression and a permutation list.
Permute the elements of the expression, as indicated by the permutation list. Part can change the number of elements.
 Out[15]=
But Permute never changes the length of an expression.
 Out[16]=
Permute also accepts cyclic notation in its second argument.
 Out[17]=
It is also possible to use a permutation group, interpreted as a set of permutations.
 Out[18]=
 Out[19]=
 Out[20]=
The action of Permute can be reverted with FindPermutation, which returns cyclic notation.
 Out[21]=
 Out[22]=
If you reverse the arguments you obtain the inverse permutation.
 Out[23]=
 Out[24]=
It is possible to perform permutation operations with permutation lists using standard commands of Mathematica.
 Part permutation list product Ordering permutation list inverse Range identity permutation list RandomSample pseudorandom generation of permutation lists

Standard commands reinterpreted for permutation lists.

Take two permutation lists of the same length.
This is their product, computed with Part.
 Out[26]=
It corresponds to the product of permutations, if placed in the same order.
 Out[27]=
 Out[27]=
 Out[28]=
 Out[29]=
The inverse of a permutation list can be computed with Ordering.
 Out[30]=
 Out[31]=
The product of the two permutation lists gives the identity permutation list.
 Out[32]=
The identity permutation list of any length can be expressed with Range.
 Out[33]=
Random reorderings of the identity list are valid permutation lists.
 Out[34]=