Function Repository Resource:

SignedPermutations

Source Notebook

Get all signed permutations of a list

Contributed by: Ed Pegg Jr and Jan Mangaldan

ResourceFunction["SignedPermutations"][list]

returns all the signed permutations of list.

ResourceFunction["SignedPermutations"][list,spec]

returns signed permutations of type spec.

Details

Possible settings for spec include:
Allall permutations
"Cyclic"cyclic permutations like {{0,1,2,3},{1,2,3,0},{2,3,0,1},{3,0,1,2}}
"Even"permutations with an even number of transpositions
"Odd"permutations with an odd number of transpositions
"Symmetric"same as All

Examples

Basic Examples (1) 

All signed permutations of the list {1,2,3}:

In[1]:=
ResourceFunction["SignedPermutations"][Range[3]]
Out[1]=

Scope (2) 

All signed even permutations of the list {1,2,3}:

In[2]:=
ResourceFunction["SignedPermutations"][Range[3], "Even"]
Out[2]=

All signed cyclic permutations of the list {1,2,3}:

In[3]:=
ResourceFunction["SignedPermutations"][Range[3], "Cyclic"]
Out[3]=

Applications (2) 

Find the vertices of a rhombic dodecahedron with edge lengths of :

In[4]:=
rhombicdodecahedron = Join @@ (ResourceFunction["SignedPermutations"][#] & /@ {{2 , 0, 0}, {1, 1, 1}})
Out[4]=

Use ConvexHullMesh to generate the rhombic dodecahedron from its vertices:

In[5]:=
ConvexHullMesh[rhombicdodecahedron]
Out[5]=

Properties and Relations (2) 

SignedPermutations[list,All] and SignedPermutations[list,"Symmetric"] are both equivalent to SignedPermutations[list]:

In[6]:=
With[{n = 4}, ResourceFunction["SignedPermutations"][Range[0, n]] === ResourceFunction["SignedPermutations"][Range[0, n], All] === ResourceFunction["SignedPermutations"][Range[0, n], "Symmetric"]]
Out[6]=

Count all signed permutations corresponding to a given list, and compare with the expressions for the explicit counts:

In[7]:=
Table[Length[
  ResourceFunction["SignedPermutations"][Range[0, n - 1], All]], {n, 2, 6}]
Out[7]=
In[8]:=
Table[2^(n - 1) n!, {n, 2, 6}]
Out[8]=
In[9]:=
Table[Length[
  ResourceFunction["SignedPermutations"][Range[0, n - 1], "Even"]], {n, 2, 6}]
Out[9]=
In[10]:=
Table[Length[
  ResourceFunction["SignedPermutations"][Range[0, n - 1], "Odd"]], {n,
   2, 6}]
Out[10]=
In[11]:=
Table[2^(n - 2) n!, {n, 2, 6}]
Out[11]=
In[12]:=
Table[Length[
  ResourceFunction["SignedPermutations"][Range[0, n - 1], "Cyclic"]], {n, 2, 6}]
Out[12]=
In[13]:=
Table[2^(n - 1) n, {n, 2, 6}]
Out[13]=

Possible Issues (2) 

Create the 120 unit icosians that make the vertices of the 600-cell:

In[14]:=
\[Phi] = RootReduce[GoldenRatio]; vecs = Join @@ (ResourceFunction["SignedPermutations"][#, "Even"] & /@ {{2, 0, 0, 0}, {1, 1, 1, 1}, {0, 1, \[Phi]^-1, \[Phi]}}/2);
icosians = ResourceFunction["Quaternion"] @@ # & /@ RootReduce[vecs];
RandomSample[icosians, 8]
Out[15]=

The icosians are a closed group under NonCommutativeMultiply (**), but RootReduce was needed for predictable results:

In[16]:=
product = FunctionRepository`$09b0107d3e974bbf9deb28994f5b02d1`Quaternion[
Rational[-1, 2], 
Rational[-1, 2], 
Rational[1, 2], 
Rational[1, 2]] ** FunctionRepository`$09b0107d3e974bbf9deb28994f5b02d1`Quaternion[
Rational[1, 2], Rational[1, 4] (1 + 5^Rational[1, 2]), Rational[1, 4] (1 - 5^Rational[1, 2]), 0];
Position[icosians, product]
Out[17]=

Neat Examples (3) 

Create vertex sets for all 5 Platonic solids and 13 Archimedean solids with unit edges:

In[18]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/7fc481e1-85ec-4d2c-b951-638205f64926"]

Show these sets with a half-unit sphere around each vertex:

In[19]:=
Grid[Partition[
  Graphics3D[Sphere[#, 1/2], ImageSize -> Tiny, Boxed -> False] & /@ poly, 6]]
Out[19]=

Show the polyhedra:

In[20]:=
Grid[Partition[ConvexHullMesh[N[#], ImageSize -> Tiny] & /@ poly, 6]]
Out[20]=

Version History

  • 1.0.0 – 08 August 2022

Related Resources

License Information