{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This is an ipython (jupyter) worksheet with code from the lecture notes for the course\n",
"**Permutation Puzzles: A Mathematical Perspective**, by Jamie Mulholland\n",
"\n",
"Coures webpage: http://www.sfu.ca/~jtmulhol/math302
\n",
"Course notes booklet: http://www.sfu.ca/~jtmulhol/math302/notes/302notes.pdf"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Lecture 4: Permutations: Cycle Notation\n",
"\n",
"
\n",
"\n",
"## Section 4.7 Working with Permutations in SageMath\n",
"\n",
"
\n",
"\n",
"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)$:\n",
"\n",
"1. As a text string of disjoint cycles (include quotes): `\"(1,3)(2,5,4)\"` \n",
"2. As a list of disjoint tuples: `[(1,3), (2,5,4)]`\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(1,4)(2,3) () (2,5,3)\n"
]
}
],
"source": [
"S5=SymmetricGroup(5) # symmetric group on 5 objects, and names it S5\n",
"a=S5(\"(2,3)(1,4)\") # constructs the permutation (2,3)(1,4) in S5\n",
"b=S5(\"\") # constructs the identity permutation in S5\n",
"c=S5(\"(2,5,3)\") # constructs the 3-cycle (2,5,3) in S5\n",
"print a, b, c,"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"(1,4)(3,5)"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a*c # compose permutations by using multiplication sign"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"(2,3,5)"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"c.inverse() # computes inverse"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"3"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"c.order() # computes order"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "SageMath 7.3",
"language": "",
"name": "sagemath"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
}
},
"nbformat": 4,
"nbformat_minor": 0
}