ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 12 Apr 2022 15:50:40 +0200Multiply Arbitrary Permutationshttps://ask.sagemath.org/question/61930/multiply-arbitrary-permutations/Is there a way to multiply arbitrary permutations?
sage: P=Permutations(var('x y z'));P
Permutations of the set [x, y, z]
sage: P[1];P[2]
[x, z, y]
[y, x, z]
But now
sage: P[1]*P[2]
gives an error:
TypeError: unsupported operand parent(s) for *: 'Permutations of the set [x, y, z]' and 'Permutations of the set [x, y, z]'
I can't even evaluate such a permutation at an element.
sage: P[1](x)
results in
TypeError: 'Permutations_set_with_category.element_class' object is not callableTue, 12 Apr 2022 15:04:36 +0200https://ask.sagemath.org/question/61930/multiply-arbitrary-permutations/Answer by rburing for <p>Is there a way to multiply arbitrary permutations?</p>
<pre><code>sage: P=Permutations(var('x y z'));P
Permutations of the set [x, y, z]
sage: P[1];P[2]
[x, z, y]
[y, x, z]
</code></pre>
<p>But now</p>
<pre><code>sage: P[1]*P[2]
</code></pre>
<p>gives an error:</p>
<pre><code>TypeError: unsupported operand parent(s) for *: 'Permutations of the set [x, y, z]' and 'Permutations of the set [x, y, z]'
</code></pre>
<p>I can't even evaluate such a permutation at an element.</p>
<pre><code>sage: P[1](x)
</code></pre>
<p>results in</p>
<pre><code>TypeError: 'Permutations_set_with_category.element_class' object is not callable
</code></pre>
https://ask.sagemath.org/question/61930/multiply-arbitrary-permutations/?answer=61931#post-id-61931You can define the symmetric group on your set instead:
sage: P = SymmetricGroup(var('x,y,z')); P
Symmetric group of order 3! as a permutation group
The elements are displayed in cycle notation, evaluation is allowed and there is a group structure:
sage: P[2]
(x,y,z)
sage: P[2](x)
y
sage: P[2].tuple()
(y, z, x)
sage: P[3]
(y,z)
sage: P[2]*P[3]
(x,z)
Note that the product is opposite from the more usual one (here `P[2]*P[3]` is `P[3]` after `P[2]`).Tue, 12 Apr 2022 15:38:36 +0200https://ask.sagemath.org/question/61930/multiply-arbitrary-permutations/?answer=61931#post-id-61931Comment by Thrash for <p>You can define the symmetric group on your set instead:</p>
<pre><code>sage: P = SymmetricGroup(var('x,y,z')); P
Symmetric group of order 3! as a permutation group
</code></pre>
<p>The elements are displayed in cycle notation, evaluation is allowed and there is a group structure:</p>
<pre><code>sage: P[2]
(x,y,z)
sage: P[2](x)
y
sage: P[2].tuple()
(y, z, x)
sage: P[3]
(y,z)
sage: P[2]*P[3]
(x,z)
</code></pre>
<p>Note that the product is opposite from the more usual one (here <code>P[2]*P[3]</code> is <code>P[3]</code> after <code>P[2]</code>).</p>
https://ask.sagemath.org/question/61930/multiply-arbitrary-permutations/?comment=61932#post-id-61932Thank you! Somehow I was stuck in my thought that `SymmetricGroup` would allow only integers.Tue, 12 Apr 2022 15:50:40 +0200https://ask.sagemath.org/question/61930/multiply-arbitrary-permutations/?comment=61932#post-id-61932