GroupElementToWord[group,g]
decomposes the group element g as a product of generators of group.
GroupElementToWord
GroupElementToWord[group,g]
decomposes the group element g as a product of generators of group.
Details and Options
- The group element g must belong to the given group.
- GroupElementToWord[group,g] gives the word of g in the form of a list of nonzero integers {m1,…,mk} representing generators in the list returned by GroupGenerators[group]. A positive integer
in the word represents the 
generator, and a negative integer
represents the inverse of the 
generator. - GroupElementToWord takes the following options:
-
GroupActionBase Automatic group action base MaxIterations Automatic maximum number of iterations Method Automatic method to use
Examples
open all close allBasic Examples (1)
Take a permutation g in a group G:
g = Cycles[{{1, 6, 4}, {2, 3, 5}}];
G = PermutationGroup[{Cycles[{{1, 2, 3}}], Cycles[{{1, 2, 3, 4, 5, 6, 7}}]}];Decompose g as a product of generators of G (negative integers represent inverse generators):
word = GroupElementToWord[G, g]Reconstruct the permutation from the word:
GroupElementFromWord[G, word]Scope (2)
Decompose a permutation as a product of the default generators of a symmetric group:
GroupElementToWord[SymmetricGroup[6], Cycles[{{1, 2}, {3, 6}, {4, 5}}]]Decompose the same permutation using a different set of generators for the same group:
GroupElementToWord[PermutationGroup[{Cycles[{{1, 2}}], Cycles[{{2, 3}}], Cycles[{{3, 4}}], Cycles[{{4, 5}}], Cycles[{{5, 6}}]}], Cycles[{{1, 2}, {3, 6}, {4, 5}}]]The returned words are usually not optimal:
g = Cycles[{{1, 6, 4}, {2, 3, 5}}];
G = PermutationGroup[{Cycles[{{1, 2, 3}}], Cycles[{{1, 2, 3, 4, 5, 6, 7}}]}];word = GroupElementToWord[G, g]optimalword = {1, 2, -1, -2, -2, -2, -1}g === GroupElementFromWord[G, word]g === GroupElementFromWord[G, optimalword]Options (3)
GroupBaseAction (1)
The algorithm uses a table of coset representatives of the group stabilizers associated to a given base. The choice of this base might strongly affect the resulting word:
G = PermutationGroup[{Cycles[{{1, 5, 7, 10, 4, 6, 8, 9}, {2, 3}}], Cycles[{{1, 3, 4}}]}];
g = Cycles[{{2, 5}, {3, 7, 8}, {6, 10}}];Length[GroupElementToWord[G, g]]Length[GroupElementToWord[G, g, GroupActionBase -> {1, 2, 3, 4, 8, 6, 5}]]MaxIterations (1)
Frequently, it is possible to improve the result by allowing the internal algorithm to perform a number of additional iterations:
G = PermutationGroup[{Cycles[{{1, 7, 2, 6, 5, 9, 4, 10, 3, 8}}], Cycles[{{1, 2, 3, 4}}]}];
g = Cycles[{{1, 2, 4, 5}, {6, 8, 7, 9}}];GroupElementToWord[G, g]GroupElementToWord[G, g, MaxIterations -> 10 ^ 4]Method (1)
GroupElementToWord uses the Minkwitz algorithm, with a number of parameters:
G = PermutationGroup[{Cycles[{{1, 5, 10, 4, 19, 7, 17, 12, 2, 8, 18}, {6, 20, 16, 15, 11, 9, 14, 13}}], Cycles[{{1, 4}}]}];
g = Cycles[{{1, 19, 2, 12}, {4, 10, 5, 17, 8, 18}}];Fine-tuning of those parameters may produce shorter words:
Length[GroupElementToWord[G, g]]Length[GroupElementToWord[G, g, Method -> {"Minkwitz", "InitMaxLength" -> 8}]]Length[GroupElementToWord[G, g, Method -> {"Minkwitz", "ImprovementPeriod" -> 75}]]Applications (1)
Check that the mapping relating respective generators of these two groups is a homomorphism:
G1 = PermutationGroup[{Cycles[{{1, 2}}], Cycles[{{1, 2, 3, 4}}]}];G2 = PermutationGroup[{Cycles[{{1, 2}, {3, 5}, {4, 6}, {7, 8}}], Cycles[{{1, 2, 3, 4}, {5, 6, 7, 8}}]}];This implements the homomorphism, extending the mapping of generators to all elements:
hom[g_] := GroupElementFromWord[G2, GroupElementToWord[G1, g]]Check that for any two elements of G1, the homomorphism property is obeyed:
With[{
g = RandomPermutation[G1],
gg = RandomPermutation[G1]
},
hom[ggg] == hom[g]hom[gg]
]In this case, the homomorphism is actually an isomorphism:
Sort[hom /@ GroupElements[G1], Less] === GroupElements[G2]Properties & Relations (4)
GroupElementFromWord reconstructs the original group element from the word:
G = DihedralGroup[8];
g = Cycles[{{1, 6, 3, 8, 5, 2, 7, 4}}];
word = GroupElementToWord[G, g]GroupElementFromWord[G, word]% === gIdentity generators are not used, but affect the indexing of the other generators:
G = PermutationGroup[{Cycles[{{1, 2}}], Cycles[{}], Cycles[{}], Cycles[{{2, 3}}]}];GroupElementToWord[G, Cycles[{{1, 3}}]]The identity permutation always corresponds to the empty word:
G = PermutationGroup[{Cycles[{{1, 2}}], Cycles[{{2, 3}}]}];GroupElementToWord[G, Cycles[{}]]The element must belong to the group:
G = DihedralGroup[6];
g = Cycles[{{1, 2, 3}, {4, 5, 6}}];GroupElementQ[G, g]GroupElementToWord[G, g]Neat Examples (1)
The group of a 3×3×3 Rubik's cube is usually given in terms of six generators:
rot1 = Cycles[{{1, 3, 8, 6}, {2, 5, 7, 4}, {9, 48, 15, 12}, {10, 47, 16, 13}, {11, 46, 17, 14}}];
rot2 = Cycles[{{6, 15, 35, 26}, {7, 22, 34, 19}, {8, 30, 33, 11}, {12, 14, 29, 27}, {13, 21, 28, 20}}];
rot3 = Cycles[{{1, 12, 33, 41}, {4, 20, 36, 44}, {6, 27, 38, 46}, {9, 11, 26, 24}, {10, 19, 25, 18}}];
rot4 = Cycles[{{1, 24, 40, 17}, {2, 18, 39, 23}, {3, 9, 38, 32}, {41, 43, 48, 46}, {42, 45, 47, 44}}];
rot5 = Cycles[{{3, 43, 35, 14}, {5, 45, 37, 21}, {8, 48, 40, 29}, {15, 17, 32, 30}, {16, 23, 31, 22}}];
rot6 = Cycles[{{24, 27, 30, 43}, {25, 28, 31, 42}, {26, 29, 32, 41}, {33, 35, 40, 38}, {34, 37, 39, 36}}];
RubikGroup6 = PermutationGroup[{rot1, rot2, rot3, rot4, rot5, rot6}];However, one of them is redundant, and the group can actually be constructed with only five face rotations:
RubikGroup5 = PermutationGroup[{rot1, rot2, rot3, rot4, rot5}];RubikGroup6 == RubikGroup5This is a possible word expressing the sixth rotation in terms of the first five and their inverses:
word = GroupElementToWord[RubikGroup5, rot6]GroupElementFromWord[RubikGroup5, word] === rot6After removing the generators corresponding to opposite faces, the remaining four still move all facelets, but now they only generate a subgroup of index 2048:
RubikGroup4 = PermutationGroup[{rot2, rot3, rot4, rot5}];(GroupOrder[RubikGroup6]/GroupOrder[RubikGroup4])This is because there are two disconnected sets of edge facelets:
GroupOrbits[RubikGroup4]Compare with the original situation:
GroupOrbits[RubikGroup6]Tech Notes
Related Guides
History
Text
Wolfram Research (2012), GroupElementToWord, Wolfram Language function, https://reference.wolfram.com/language/ref/GroupElementToWord.html.
CMS
Wolfram Language. 2012. "GroupElementToWord." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/GroupElementToWord.html.
APA
Wolfram Language. (2012). GroupElementToWord. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GroupElementToWord.html
BibTeX
@misc{reference.wolfram_2026_groupelementtoword, author="Wolfram Research", title="{GroupElementToWord}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/GroupElementToWord.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_groupelementtoword, organization={Wolfram Research}, title={GroupElementToWord}, year={2012}, url={https://reference.wolfram.com/language/ref/GroupElementToWord.html}, note=[Accessed: 13-June-2026]}