Given an element g
of your group G
, you can write it as a product of the generators of G
by using the word_problem
method:
sage: G = PermutationGroup([(4,5,6,7,8), (1,2,3)])
sage: g = G.an_element() ; g
(1,2,3)(4,5,6,7,8)
sage: g.word_problem(G.gens())
x2*x1
[['(1,2,3)', 1], ['(4,5,6,7,8)', 1]]
('x2*x1', '(1,2,3)*(4,5,6,7,8)')
If you want to get the decomposition for every element of G
, you can do something like:
sage: for i in G:
....: print('{} can be written as {}'.format(i, i.word_problem(G.gens(), as_list=True, display=None)))
....:
() can be written as [['<identity ...>', 1]]
(4,8,7,6,5) can be written as [['(4,5,6,7,8)', -1]]
(4,7,5,8,6) can be written as [['(4,5,6,7,8)', -2]]
(4,6,8,5,7) can be written as [['(4,5,6,7,8)', 2]]
(4,5,6,7,8) can be written as [['(4,5,6,7,8)', 1]]
(1,3,2) can be written as [['(1,2,3)', -1]]
(1,3,2)(4,8,7,6,5) can be written as [['(1,2,3)', -1], ['(4,5,6,7,8)', -1]]
(1,3,2)(4,7,5,8,6) can be written as [['(1,2,3)', -1], ['(4,5,6,7,8)', -2]]
(1,3,2)(4,6,8,5,7) can be written as [['(4,5,6,7,8)', 2], ['(1,2,3)', -1]]
(1,3,2)(4,5,6,7,8) can be written as [['(1,2,3)', -1], ['(4,5,6,7,8)', 1]]
(1,2,3) can be written as [['(1,2,3)', 1]]
(1,2,3)(4,8,7,6,5) can be written as [['(1,2,3)', 1], ['(4,5,6,7,8)', -1]]
(1,2,3)(4,7,5,8,6) can be written as [['(1,2,3)', 1], ['(4,5,6,7,8)', -2]]
(1,2,3)(4,6,8,5,7) can be written as [['(4,5,6,7,8)', 2], ['(1,2,3)', 1]]
(1,2,3)(4,5,6,7,8) can be written as [['(1,2,3)', 1], ['(4,5,6,7,8)', 1]]