ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 22 Jan 2020 06:37:05 -0600symmetric group: get back conjugacy class from its generatorshttps://ask.sagemath.org/question/49641/symmetric-group-get-back-conjugacy-class-from-its-generators/The function below returns a list `r` of elements of the symmetric group that leave a certain polynomial `f` fixed.
I know (by the properties of `f` that I'm not specifiying here) that the list of `g`'s that leave it fixed generate one of the 11 conjugacy subclasses of S(4).
What is the best way to output from my code below a number between 1 and 11 that corresponds to such subclass?
R = PolynomialRing(QQ, 4, ["q1","q2","q3","q4"])
q1,q2,q3,q4 = R.gens()
f = 1 + q1 +q2 # in general, it is a polynomial with unit coefficients in the ring R
G = SymmetricGroup(4)
cl = G.conjugacy_classes_subgroups()
r = []
for g in G:
if (f * g) == f: r.append(g)
return rWed, 22 Jan 2020 04:16:56 -0600https://ask.sagemath.org/question/49641/symmetric-group-get-back-conjugacy-class-from-its-generators/Answer by rburing for <p>The function below returns a list <code>r</code> of elements of the symmetric group that leave a certain polynomial <code>f</code> fixed.
I know (by the properties of <code>f</code> that I'm not specifiying here) that the list of <code>g</code>'s that leave it fixed generate one of the 11 conjugacy subclasses of S(4).
What is the best way to output from my code below a number between 1 and 11 that corresponds to such subclass?</p>
<pre><code>R = PolynomialRing(QQ, 4, ["q1","q2","q3","q4"])
q1,q2,q3,q4 = R.gens()
f = 1 + q1 +q2 # in general, it is a polynomial with unit coefficients in the ring R
G = SymmetricGroup(4)
cl = G.conjugacy_classes_subgroups()
r = []
for g in G:
if (f * g) == f: r.append(g)
return r
</code></pre>
https://ask.sagemath.org/question/49641/symmetric-group-get-back-conjugacy-class-from-its-generators/?answer=49644#post-id-49644Unfortunately the method `conjugacy_classes_subgroups` returns representatives, unlike GAP, which returns objects representing conjugacy classes. It would be nicer to have such objects in SageMath as well.
Fortunately we can still use the underlying interface to GAP:
H = G.subgroup(r)
gap_cl = G.gap().ConjugacyClassesSubgroups()
gap_H = H.gap()
cl_index_of_H = next(k for (k,gap_c) in enumerate(gap_cl) if gap_H in gap_c)
and then (using that the ordering of `cl` is the same as `gap_cl`):
sage: cl[cl_index_of_H]
Subgroup generated by [(3,4), (1,2)(3,4)] of (Symmetric group of order 4! as a permutation group)Wed, 22 Jan 2020 05:26:11 -0600https://ask.sagemath.org/question/49641/symmetric-group-get-back-conjugacy-class-from-its-generators/?answer=49644#post-id-49644Comment by rburing for <p>Unfortunately the method <code>conjugacy_classes_subgroups</code> returns representatives, unlike GAP, which returns objects representing conjugacy classes. It would be nicer to have such objects in SageMath as well.</p>
<p>Fortunately we can still use the underlying interface to GAP:</p>
<pre><code>H = G.subgroup(r)
gap_cl = G.gap().ConjugacyClassesSubgroups()
gap_H = H.gap()
cl_index_of_H = next(k for (k,gap_c) in enumerate(gap_cl) if gap_H in gap_c)
</code></pre>
<p>and then (using that the ordering of <code>cl</code> is the same as <code>gap_cl</code>):</p>
<pre><code>sage: cl[cl_index_of_H]
Subgroup generated by [(3,4), (1,2)(3,4)] of (Symmetric group of order 4! as a permutation group)
</code></pre>
https://ask.sagemath.org/question/49641/symmetric-group-get-back-conjugacy-class-from-its-generators/?comment=49648#post-id-49648That would be `cl_index_of_H + 1`.Wed, 22 Jan 2020 06:37:05 -0600https://ask.sagemath.org/question/49641/symmetric-group-get-back-conjugacy-class-from-its-generators/?comment=49648#post-id-49648Comment by rue82 for <p>Unfortunately the method <code>conjugacy_classes_subgroups</code> returns representatives, unlike GAP, which returns objects representing conjugacy classes. It would be nicer to have such objects in SageMath as well.</p>
<p>Fortunately we can still use the underlying interface to GAP:</p>
<pre><code>H = G.subgroup(r)
gap_cl = G.gap().ConjugacyClassesSubgroups()
gap_H = H.gap()
cl_index_of_H = next(k for (k,gap_c) in enumerate(gap_cl) if gap_H in gap_c)
</code></pre>
<p>and then (using that the ordering of <code>cl</code> is the same as <code>gap_cl</code>):</p>
<pre><code>sage: cl[cl_index_of_H]
Subgroup generated by [(3,4), (1,2)(3,4)] of (Symmetric group of order 4! as a permutation group)
</code></pre>
https://ask.sagemath.org/question/49641/symmetric-group-get-back-conjugacy-class-from-its-generators/?comment=49647#post-id-49647Looking at both your answer and mine, would it be possible to outpu a number between 1 and 11 instead of 'Subgroup generated by...'?Wed, 22 Jan 2020 06:35:22 -0600https://ask.sagemath.org/question/49641/symmetric-group-get-back-conjugacy-class-from-its-generators/?comment=49647#post-id-49647Answer by rue82 for <p>The function below returns a list <code>r</code> of elements of the symmetric group that leave a certain polynomial <code>f</code> fixed.
I know (by the properties of <code>f</code> that I'm not specifiying here) that the list of <code>g</code>'s that leave it fixed generate one of the 11 conjugacy subclasses of S(4).
What is the best way to output from my code below a number between 1 and 11 that corresponds to such subclass?</p>
<pre><code>R = PolynomialRing(QQ, 4, ["q1","q2","q3","q4"])
q1,q2,q3,q4 = R.gens()
f = 1 + q1 +q2 # in general, it is a polynomial with unit coefficients in the ring R
G = SymmetricGroup(4)
cl = G.conjugacy_classes_subgroups()
r = []
for g in G:
if (f * g) == f: r.append(g)
return r
</code></pre>
https://ask.sagemath.org/question/49641/symmetric-group-get-back-conjugacy-class-from-its-generators/?answer=49642#post-id-49642This is my attempt (edit):
R = PolynomialRing(QQ, 4, ["q1","q2","q3","q4"])
q1,q2,q3,q4 = R.gens()
f = 1+q1+q2 # for example
G = SymmetricGroup(4)
r = []
for g in G:
if (f * g) == f: r.append(g)
H = PermutationGroup(r)
return ConjugacyClass(H, G)Wed, 22 Jan 2020 04:55:34 -0600https://ask.sagemath.org/question/49641/symmetric-group-get-back-conjugacy-class-from-its-generators/?answer=49642#post-id-49642Comment by rue82 for <p>This is my attempt (edit):</p>
<pre><code>R = PolynomialRing(QQ, 4, ["q1","q2","q3","q4"])
q1,q2,q3,q4 = R.gens()
f = 1+q1+q2 # for example
G = SymmetricGroup(4)
r = []
for g in G:
if (f * g) == f: r.append(g)
H = PermutationGroup(r)
return ConjugacyClass(H, G)
</code></pre>
https://ask.sagemath.org/question/49641/symmetric-group-get-back-conjugacy-class-from-its-generators/?comment=49646#post-id-49646@rburing Thanks, indeed I corrected.Wed, 22 Jan 2020 06:29:14 -0600https://ask.sagemath.org/question/49641/symmetric-group-get-back-conjugacy-class-from-its-generators/?comment=49646#post-id-49646Comment by rburing for <p>This is my attempt (edit):</p>
<pre><code>R = PolynomialRing(QQ, 4, ["q1","q2","q3","q4"])
q1,q2,q3,q4 = R.gens()
f = 1+q1+q2 # for example
G = SymmetricGroup(4)
r = []
for g in G:
if (f * g) == f: r.append(g)
H = PermutationGroup(r)
return ConjugacyClass(H, G)
</code></pre>
https://ask.sagemath.org/question/49641/symmetric-group-get-back-conjugacy-class-from-its-generators/?comment=49645#post-id-49645Be careful that isomorphism is weaker than conjugacy, so this doesn't always work (it gives "false positives").Wed, 22 Jan 2020 05:28:24 -0600https://ask.sagemath.org/question/49641/symmetric-group-get-back-conjugacy-class-from-its-generators/?comment=49645#post-id-49645