#!/usr/bin/env python
# coding: utf-8
# This is an ipython (jupyter) worksheet with code from the lecture notes for the course
# **Permutation Puzzles: A Mathematical Perspective**, by Jamie Mulholland
#
# Coures webpage: http://www.sfu.ca/~jtmulhol/math302
# Course notes booklet: http://www.sfu.ca/~jtmulhol/math302/notes/302notes.pdf
# # Lecture 4: Permutations: Cycle Notation
#
#
#
# ## Section 4.7 Working with Permutations in SageMath
#
#
#
# SageMath uses **disjoint** cycle notation for permutations, and permutation composition occurs left-to-right, which agrees with our convention. There are two ways to write the permutation $\alpha=(1,3)(2,5,4)$:
#
# 1. As a text string of disjoint cycles (include quotes): `"(1,3)(2,5,4)"`
# 2. As a list of disjoint tuples: `[(1,3), (2,5,4)]`
#
# In[1]:
S5=SymmetricGroup(5) # symmetric group on 5 objects, and names it S5
a=S5("(2,3)(1,4)") # constructs the permutation (2,3)(1,4) in S5
b=S5("") # constructs the identity permutation in S5
c=S5("(2,5,3)") # constructs the 3-cycle (2,5,3) in S5
print a, b, c,
# In[2]:
a*c # compose permutations by using multiplication sign
# In[3]:
c.inverse() # computes inverse
# In[4]:
c.order() # computes order
# In[ ]:
# In[ ]:
# In[ ]:
# In[ ]:
# In[ ]:
# In[ ]:
# In[ ]:
# In[ ]:
# In[ ]:
# In[ ]: