Permute
Details
- Permute works with any nonatomic expressions, operating on the first level of expressions.
- Permute reorders the elements of an expression but never changes its length.
- The permutation perm can be given in disjoint cyclic form or as a permutation list.
- When perm is given in cyclic form Cycles[{cyc1,cyc2,…}], a cycle {p1,p2,…} moves the elements of expr in a cyclic manner so that expr[[pi]] is moved to position pi+1.
- When perm is given as a permutation list, the result is equivalent to the use of Permute[expr,PermutationCycles[perm]].
- A permutation group gr can be specified by generators, with head PermutationGroup, or in named form, with head SymmetricGroup, AlternatingGroup, ….
Examples
open all close allBasic Examples (3)
Cyclic permutation of three elements in a list:
Permute[{a, b, c, d, e}, Cycles[{{1, 3, 2}}]]Equivalent action with a permutation list:
Permute[{a, b, c, d, e}, {3, 1, 2}]alphabet = CharacterRange["a", "z"]Exchange the first and last character:
Permute[alphabet, Cycles[{{1, 26}}]]Permute[alphabet, Cycles[{{1, 6, 18, 2}, {3, 20, 11}}]]Permute an expression under all elements of a group:
Permute[h[a, b, c, d], AlternatingGroup[4]]Scope (3)
Permute the parts of an expression:
Permute[head[a, b, c, d, e], Cycles[{{1, 3}, {2, 4}}]]Permute the parts of an expression under all elements of a group:
Permute[head[a, b, c, d, e], PermutationGroup[{Cycles[{{1, 2}}], Cycles[{{1, 3}, {2, 4}}]}]]Give a permutation in list form. The length of the expression does not change:
Permute[head[a, b, c, d, e], {3, 4, 1, 2}]Permute[head[a, b, c, d, e], {}]Applications (1)
The eight possible rotations and reflections of a square:
square[{c1_, c2_, c3_, c4_}] := Graphics[{{c1, Line[{{0, 0}, {0, 1}}]}, {c2, Line[{{0, 1}, {1, 1}}]}, {c3, Line[{{1, 1}, {1, 0}}]}, {c4, Line[{{1, 0}, {0, 0}}]}}, ImageSize -> 50]square /@ Permute[{Blue, Green, Red, Yellow}, DihedralGroup[4]]Properties & Relations (6)
Permute never changes the number of parts of an expression. It simply reorders them:
expr = head[a, b, c, d, e, f]Permute[expr, Cycles[{{1, 4, 2}}]]However, Part can change the number of parts:
list = PermutationList[Cycles[{{1, 4, 2}}]]expr[[list]]Permute[expr, list]When applied to the identity permutation list, Permute is the inverse of PermutationReplace:
perm = Cycles[{{1, 5, 3}, {4, 2, 8}}];Permute[Range[10], perm]PermutationReplace[%, perm] === Range[10]Another way of inverting the action of Permute is using FindPermutation:
expr = head[c, a, b, d, e, f]newexpr = Permute[expr, Cycles[{{1, 4, 3, 2}}]]When all parts of the expression are different, the permutation can be uniquely recovered:
FindPermutation[expr, newexpr]Permute is a right action with respect to the product of permutations:
expr = F[a, b, c, d, e];
perm1 = Cycles[{{1, 4, 3}, {2, 5}}];
perm2 = Cycles[{{1, 5, 3, 2, 4}}];Permute[Permute[expr, perm1], perm2] === Permute[expr, PermutationProduct[perm1, perm2]]Dimensions[Transpose[array,perm]] is equivalent to Permute[Dimensions[array],perm]:
array = Array[a, {2, 3, 4, 5}];perm = {3, 1, 4, 2};Dimensions[Transpose[array, perm]]Permute[Dimensions[array], perm]Compute the same results with the Cycles form of the permutation:
cperm = PermutationCycles[perm]Dimensions[Transpose[array, cperm]]Permute[Dimensions[array], perm]Applying Permute to a vector is equivalent to multiplying the vector from the right with a permutation matrix:
v = {C[1], C[2], C[3], C[4], C[5]};
perm = Cycles[{{1, 4, 3}, {2, 5}}];Permute[v, perm] === v.PermutationMatrix[perm]Possible Issues (1)
Permute and Part interpret permutation lists in different ways:
perm = {3, 1, 2};Permute places the first object at the third position, the second object at the first position and the third object at the second position:
Permute[{a, b, c}, perm]Part places the third object at the first position, the first object at the second position and the second object at the third position:
Part[{a, b, c}, perm]Those interpretations are effectively the inverse of each other:
Permute[{a, b, c}, InversePermutation[perm]]Part[{a, b, c}, InversePermutation[perm]]Tech Notes
Related Guides
History
Text
Wolfram Research (2010), Permute, Wolfram Language function, https://reference.wolfram.com/language/ref/Permute.html.
CMS
Wolfram Language. 2010. "Permute." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Permute.html.
APA
Wolfram Language. (2010). Permute. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Permute.html
BibTeX
@misc{reference.wolfram_2026_permute, author="Wolfram Research", title="{Permute}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/Permute.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_permute, organization={Wolfram Research}, title={Permute}, year={2010}, url={https://reference.wolfram.com/language/ref/Permute.html}, note=[Accessed: 13-June-2026]}