# Change order of multiplication/composition in SymmetricGroup How can I change the order of multiplication/composition of elements in the symmetric group?

Example:

sage: S=SymmetricGroup(4)
sage: a=S((1,2))
sage: b=S((2,3))
sage: c=S((3,4))
sage: a*b*c
(1,4,3,2)


How can I change this behavior so that I can execute a*b*c and the output will be (1,2,3,4)? I want to keep using the star *, not an inconvenient command like a.__rmul__(b).__rmul__(c), otherwise I would have to rewrite all my code.

edit retag close merge delete

There is something like this: Permutations.global_options(mult='r2l')

Thanks, but this command doesn't exist anymore. However, I tried Permutations.options(mult='r2l'), but it doesn't change the order, I still get (1,4,3,2).

slelievre, thanks but is there any solution in the links you are providing? I just need a simple command to switch the behavior. It shouldn't be so complicated.

Sort by » oldest newest most voted Well, not perfect, but something:

sage: S = Permutations(4)
sage: a=S([2,1,3,4])
sage: b=S([1,3,2,4])
sage: c=S([1,2,4,3])
sage: a*b*c
[4, 1, 2, 3]
sage: S.options(mult='r2l')
sage: a*b*c
[2, 3, 4, 1]

more

Thanks, but then S((2,3)) doesn't work anymore. It seems that Permutations doesn't allow the cyclic notation, but I want to keep it.

Permutation can take as input elements of symmetric groups:

sage: Permutation(SymmetricGroup(4)((1,2)))
[2, 1, 3, 4]


Look at

sage: S=SymmetricGroup(4)
sage: T=Permutations(4)
sage: a=T(S((1,2)))
sage: b=T(S((2,3)))
sage: c=T(S((3,4)))
sage: T.options(mult='r2l')
sage: d=a*b*c
sage: d.cycle_string()
'(1,2,3,4)'


Compared to my original code, I think this is a rather inconvenient solution because I have to introduce T and .cycle_string() in the end to get the final result as I wish and as it could be principally done via my original code. Can't it be done with only one additional line like .options(mult='r2l') or some other command?