# How to return s1*s2 of a symmetric group in Sage?

I wrote a function and would like to return reduced expressions of the form in Sage.

def LongestPermInDoubleCoset(S1,w,S2): # longest element in S1 w S2, S1,S2 are subgroups of S_n

winner = W.identity()
for u1 in S1:
for u2 in S2:
t1=u1*w*u2
if t1.length()>winner.length():
winner=t1
r=winner

return r

W=SymmetricGroup(6)
[s1,s2,s3,s4,s5] = W.simple_reflections()
S1=[W.identity(), s1]
S2=[W.identity(),s2]
t1=LongestPermInDoubleCoset(S1,s1,S2)
t2=t1.reduced_word()
t2


I obtained t2=[1,2]. But I would like to return s1*s2. How to do that? Thank you very much.

edit retag close merge delete

Sort by » oldest newest most voted

I'm not sure what you mean under "return s1*s2" since s1 and s2 are two transpositions (not symbolic variables) and their product is t1. So, if you want their product, simply take t1. If you want to get them as a list like [s1,s2], then replace t2=t1.reduced_word() with

R = W.simple_reflections()
t2 = [R[s] for s in t1.reduced_word()]

more