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.Fri, 25 Nov 2016 05:06:30 +0100PermutationGroupMorphism_im_genshttps://ask.sagemath.org/question/35722/permutationgroupmorphism_im_gens/I'm trying this code (taken from "Adventures in Group Theory"). I get an error, why ?
G=SymmetricGroup(4)
gensG=G.gens()
h=G([(1,3,4,2)]) # a 'random' element of G
gensG_h=[h*g*h^(-1) for g in gensG]
phi = PermutationGroupMorphism_im_gens(G,G,gensG,gensG_h)
phi.image(G)
phi.range()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_78.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("cGhpID0gUGVybXV0YXRpb25Hcm91cE1vcnBoaXNtX2ltX2dlbnMoRyxHLGdlbnNHLGdlbnNHX2gp"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/private/var/folders/gm/z065gk616xg6g0xgn4c7_bvc0000gn/T/tmplbPZy2/___code___.py", line 2, in <module>
exec compile(u'phi = PermutationGroupMorphism_im_gens(G,G,gensG,gensG_h)
File "", line 1, in <module>
TypeError: __init__() takes at most 4 arguments (5 given)
Thu, 24 Nov 2016 17:51:17 +0100https://ask.sagemath.org/question/35722/permutationgroupmorphism_im_gens/Answer by tmonteil for <p>I'm trying this code (taken from "Adventures in Group Theory"). I get an error, why ? </p>
<pre><code>G=SymmetricGroup(4)
gensG=G.gens()
h=G([(1,3,4,2)]) # a 'random' element of G
gensG_h=[h*g*h^(-1) for g in gensG]
phi = PermutationGroupMorphism_im_gens(G,G,gensG,gensG_h)
phi.image(G)
phi.range()
</code></pre>
<p>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_78.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -<em>- coding: utf-8 -</em>-\n" + _support_.preparse_worksheet_cell(base64.b64decode("cGhpID0gUGVybXV0YXRpb25Hcm91cE1vcnBoaXNtX2ltX2dlbnMoRyxHLGdlbnNHLGdlbnNHX2gp"),globals())+"\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module></p>
<p>File "/private/var/folders/gm/z065gk616xg6g0xgn4c7_bvc0000gn/T/tmplbPZy2/___code___.py", line 2, in <module>
exec compile(u'phi = PermutationGroupMorphism_im_gens(G,G,gensG,gensG_h)
File "", line 1, in <module></p>
<p>TypeError: __init__() takes at most 4 arguments (5 given)</p>
https://ask.sagemath.org/question/35722/permutationgroupmorphism_im_gens/?answer=35728#post-id-35728You can get the documentation of `PermutationGroupMorphism_im_gens` (which i admit is pretty poor) as follows:
sage: PermutationGroupMorphism_im_gens?
As you can see, you have only 3 arguments:
1. the group that serves as the domain
2. the group that serves as the codomain
3. the list of images (in the codomain) of "the" generators of the domain by the morphism you want to construct
So in your case, i do not have a copy of the book, but i guess that you want to define the inner automorphism (a.k.a. conjugacy), from G to G that maps $g$ to $hgh^{-1}$.
So the first argument is `G`, the second is `G` and the third is the list of images of `G.gens()` by the inner automorphism, that is `[h*g*h^(-1) for g in gensG]` (which you named `gensG_h`). Hence, you can define your morphism as:
sage: phi = PermutationGroupMorphism_im_gens(G,G,gensG_h)
sage: phi
Permutation group endomorphism of Symmetric group of order 4! as a permutation group
Defn: [(1,2,3,4), (1,2)] -> [(1,3,2,4), (2,4)]
sage: phi.image(G)
Subgroup of (Symmetric group of order 4! as a permutation group) generated by [(2,4), (1,3,2,4)]
However, there is no `range` method (which would have lead to the same result anyway).
Cou can check that `phi` a bijection:
sage: phi.kernel()
Subgroup of (Symmetric group of order 4! as a permutation group) generated by [()]
sage: phi.image(G) == G
True
Thu, 24 Nov 2016 20:46:45 +0100https://ask.sagemath.org/question/35722/permutationgroupmorphism_im_gens/?answer=35728#post-id-35728Comment by fagui for <p>You can get the documentation of <code>PermutationGroupMorphism_im_gens</code> (which i admit is pretty poor) as follows:</p>
<pre><code>sage: PermutationGroupMorphism_im_gens?
</code></pre>
<p>As you can see, you have only 3 arguments:</p>
<ol>
<li>the group that serves as the domain</li>
<li>the group that serves as the codomain</li>
<li>the list of images (in the codomain) of "the" generators of the domain by the morphism you want to construct</li>
</ol>
<p>So in your case, i do not have a copy of the book, but i guess that you want to define the inner automorphism (a.k.a. conjugacy), from G to G that maps $g$ to $hgh^{-1}$.</p>
<p>So the first argument is <code>G</code>, the second is <code>G</code> and the third is the list of images of <code>G.gens()</code> by the inner automorphism, that is <code>[h*g*h^(-1) for g in gensG]</code> (which you named <code>gensG_h</code>). Hence, you can define your morphism as:</p>
<pre><code>sage: phi = PermutationGroupMorphism_im_gens(G,G,gensG_h)
sage: phi
Permutation group endomorphism of Symmetric group of order 4! as a permutation group
Defn: [(1,2,3,4), (1,2)] -> [(1,3,2,4), (2,4)]
sage: phi.image(G)
Subgroup of (Symmetric group of order 4! as a permutation group) generated by [(2,4), (1,3,2,4)]
</code></pre>
<p>However, there is no <code>range</code> method (which would have lead to the same result anyway).</p>
<p>Cou can check that <code>phi</code> a bijection:</p>
<pre><code>sage: phi.kernel()
Subgroup of (Symmetric group of order 4! as a permutation group) generated by [()]
sage: phi.image(G) == G
True
</code></pre>
https://ask.sagemath.org/question/35722/permutationgroupmorphism_im_gens/?comment=35734#post-id-35734thanks for your answer.
the book is quite old (from 2008) so I guess the functions had not the same signature, and some other functions have been removed.Fri, 25 Nov 2016 05:06:30 +0100https://ask.sagemath.org/question/35722/permutationgroupmorphism_im_gens/?comment=35734#post-id-35734