Function Repository Resource:

EvenPermutations

Source Notebook

Get even permutations of a list

Contributed by: Ed Pegg Jr

ResourceFunction["EvenPermutations"][list]

returns the even permutations of list.

ResourceFunction["EvenPermutations"][list,count]

returns count even permutations of list.

Details

An even permutation is a permutation created by an even number of two-element swaps.
If the list has length 9 or less, all even permutations will be returned. If the list has length longer than 9, a random sampling of even permutations will be returned.

Examples

Basic Examples (2) 

The even permutations of {1,2,3,4}:

In[1]:=
ResourceFunction["EvenPermutations"][Range[4]]
Out[1]=

The even permutations of {2,1,3,4}:

In[2]:=
ResourceFunction["EvenPermutations"][{2, 1, 3, 4}]
Out[2]=

The even permutations of an odd permutation have signature -1:

In[3]:=
Signature /@ %
Out[3]=

Ten even permutations of {1,…,15}:

In[4]:=
ResourceFunction["EvenPermutations"][Range[15], 10]
Out[4]=

Possible Issues (1) 

For a list of 12 items, rather than returning 12!/2 = 239500800 items, a sampling of even permutations is given:

In[5]:=
ResourceFunction["EvenPermutations"][Range[12]]
Out[5]=

Neat Examples (1) 

Use even permutations to embed an icosahedron within a tetrahedron:

In[6]:=
p = {0, 1/2, 1/4 (3 - Sqrt[5]), 1/4 (-1 + Sqrt[5])};
tet = {{-1, 1, 1}, {1, -1, 1}, {1, 1, -1}, {-1, -1, -1}};
ico = RootReduce[
   ResourceFunction["Areal"][tet, #] & /@ ResourceFunction["EvenPermutations"][p]];
edge1 = ResourceFunction["FindExtraordinaryLines"][Join[ico, tet]];
edge2 = Select[Subsets[Range[12], {2}], Quiet@RootReduce[EuclideanDistance @@ ico[[#]]] == 3 - Sqrt[5] &];
Graphics3D[{Tube[Join[ico, tet][[#]], .06] & /@ Join[edge1, edge2], Opacity[.5], Simplex[tet]}, Boxed -> False, SphericalRegion -> True]
Out[6]=

Version History

  • 1.0.1 – 26 May 2021

Related Resources

License Information