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.Wed, 04 Oct 2023 22:32:34 +0200Bug finding subgroups of the class group?https://ask.sagemath.org/question/73758/bug-finding-subgroups-of-the-class-group/ This is potentially a bug, but I want to check whether I'm just doing something wrong here:
When I try to find the subgroups of the class group of a number field, I am often (though not always) getting a list of only the trivial subgroup repeated many times. Here is some example code:
This first example works as expected:
sage: K.<a> = NumberField(x^2 + 191)
sage: clG = K.class_group()
sage: clG
Class group of order 13 with structure C13 of Number Field in a with defining polynomial x^2 + 191
sage: clG.subgroups()
[Multiplicative Abelian subgroup isomorphic to C13 generated by {Fractional ideal class (2, 1/2*a + 1/2)},
Trivial Abelian subgroup]
This second example, however, does not:
sage: K.<a> = NumberField(x^2 + 21)
sage: clG = K.class_group()
sage: clG
Class group of order 4 with structure C2 x C2 of Number Field in a with defining polynomial x^2 + 21
sage: clG.subgroups()
[Trivial Abelian subgroup,
Trivial Abelian subgroup,
Trivial Abelian subgroup,
Trivial Abelian subgroup,
Trivial Abelian subgroup]
It looks to me like this bug is occurring whenever the class group is not cyclic. Is this a known issue, or is this something I should report? And if so where/how do I report these bugs (I haven't done any development before)?stillconfusedWed, 04 Oct 2023 22:32:34 +0200https://ask.sagemath.org/question/73758/Quotients of multiplicative groups of integers modulo nhttps://ask.sagemath.org/question/70054/quotients-of-multiplicative-groups-of-integers-modulo-n/ I am studying multiplicative groups of integers modulo $n$; in particular, this is the group $G=\mathbb{Z}_n^\ast$. I am particularly interested in studying the structure of quotient groups of the form $G=\mathbb{Z}_n^\ast/\langle p \rangle$. I know that I can work with finite Abelian groups as follows:
Zn = Zmod(n)
G = Zn.unit_group()
Given an element $x$ of $G$, I then create a subgroup generated by an element of G, like so:
H = G.subgroup(x)
But I can't create a quotient group from G and H:
Q = G.quotient(H)
File /private/var/tmp/sage-9.8-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/groups/group.pyx:239, in sage.groups.group.Group.quotient (build/cythonized/sage/groups/group.c:3453)()
237 NotImplementedError
238 """
--> 239 raise NotImplementedError
240
241 cdef class AbelianGroup(Group):
Is there any other way I can work with quotient groups of multiplicative Abelian groups? I'm trying to peek at their structure (we know that any finite Abelian group can be written as the direct product of cyclic groups). I can probably implement multiplicative quotient groups myself but I'd rather not do this of course.
Thank you! eluossFri, 14 Jul 2023 14:56:31 +0200https://ask.sagemath.org/question/70054/How to generate the cosets in this specific group (Zn*)https://ask.sagemath.org/question/69519/how-to-generate-the-cosets-in-this-specific-group-zn/I see the answers to the multiplicative group of units (a class), in [here](https://ask.sagemath.org/question/29639/easiest-way-to-work-in-the-multiplicative-group-of-zmodn/), as well as the answer to how to generate cosets in [here](https://ask.sagemath.org/question/7984/how-to-list-cosets/).
But I don't know how to blend them together into a chunk of code that illustrates the cosets when the group is partitioned by the subgroup generated, for example, by the element 5 in the multiplicative group mod 13:
Zn = Zmod(13)
G = Zn.unit_group()
H = G.subgroup(5)
H.cosets()
---
A possible workaround after the comment below could be as follows:
def cosets(p,g):
R = Integers(p)
a = R(g)
sub = uniq([a^i for i in range(p - 1)])
diff = list(set(R) - set(sub))
m = []
for k in range(1, len(diff)): m.append(sorted(set([diff[k] * i for i in sub])))
costs = list(set(tuple(map(tuple, m))))
print("The elements of the multiplicative subgroup generated by", g, "modulo", p, "are", sub, "and the cosets are", costs)
So the call `cosets(13,5)` would yield:
`The elements of the multiplicative subgroup generated by 5 modulo 13 are [1, 5, 8, 12] and the cosets are [(2, 3, 10, 11), (4, 6, 7, 9)]`
Would this work?toniMon, 26 Jun 2023 17:13:44 +0200https://ask.sagemath.org/question/69519/How to define Z(1/sqrt(2),I)https://ask.sagemath.org/question/64638/how-to-define-z1sqrt2i/ Hello,
I'm kinda new to sage maths and I would like to define the ring generated by 1/sqrt(2) and i .
I've been looking on internet and I found nothing.
pierrick BournezThu, 27 Oct 2022 11:36:52 +0200https://ask.sagemath.org/question/64638/Minimal Faithful Degree code not working.https://ask.sagemath.org/question/62089/minimal-faithful-degree-code-not-working/I'm making code to find the minimal faithful degree of reflection groups. There are two things that are going wrong as of now:
When I run for Reflection Groups, I get:
> ValueError: the input data (2) is not valid for reflection groups.
The code is as below:
def getSocle(G):
Z=G.center()
gens=Z.gens()
genK=[]
while len(gens) == 0:
ExtractRep(~gens, ~gen)
ord=Order(gen)
p=Factorization(ord)[1][1]
n=Factorization(ord)[1][2]
gen2=gen^(p^(n-1))
genK.append(gen2) #gen2 is the element of order p in <gen>
K= G.subgroup([genK]) #(?)
return K
def getMinimalFaithfulDegree(G):
Inter=getSocle(G)
subs=G.subgroups()
F=[]
j=len(subs)
while j >= 1:
sub = subs[j-1]
if Inter.is_subgroup(sub) is False:
F.append(sub)
j -= 1
return F
def mu(F):
alph=0
for i in range(1,len(F)):
alph+= 1/F[i].order()
return alph
def abelianFactors(G):
orders=[]
gens=G.gens()
for i in gens:
orders.append(i.order())
return orders
def aplhaAbelian(G):
orders=abelianFactors(G)
return (sum(orders))/(prod(orders)) #sum of orders of cyclic groups/the product of orders, look into syntax
def Alpha(G):
if G.is_abelian(): #(?)
return alphaAbelian(G)
else:
F=getMinimalFaithfulDegree(G)
return mu(F)
Alpha(SymmetricGroup(4))
This gives 0, i don't know why.Zander KThu, 21 Apr 2022 22:51:24 +0200https://ask.sagemath.org/question/62089/Finding generators of subgroups of free abelian groups.https://ask.sagemath.org/question/61497/finding-generators-of-subgroups-of-free-abelian-groups/Let $N$ be a finitely generated abelian group. Let $M$ be a subgroup of $N$ with the same rank as that of $N$. Given an $\mathbb{Z}$-basis $v_1,\ldots,v_m$ of $M$ and an element $v\in N$, find a basis of the group generated by $v_1,\ldots,v_m,v$.
I am fairly certain that doing so is possible, but I cannot come up with an effective algorithm. Does anyone have code that is similar to this?GalvanizedPlutoniumMon, 14 Mar 2022 11:56:34 +0100https://ask.sagemath.org/question/61497/Rounding up to the nearest integer that’s congruent to k mod Nhttps://ask.sagemath.org/question/56766/rounding-up-to-the-nearest-integer-thats-congruent-to-k-mod-n/I'm trying to perform so kind of calculation. I think you can help me.
Task :
> Rounding up to the nearest integer
> that’s congruent to k mod N during halfing by 2
We have curve:
The elliptic curve domain parameters over Fp associated with a Koblitz curve secp256k1 are specified by the sextuple T = (p,a,b,G,n,h) where the finite field Fp is defined by:
p = FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE FFFFFC2F
= 2256 - 232 - 29 - 28 - 27 - 26 - 24 - 1
The curve E: `y2 = x3+ax+b` over Fp is defined by:
a = 0
b = 7
The base point G form is:
G = (Gx,Gy)
Gx = 79BE667E F9DCBBAC 55A06295 CE870B07 029BFCDB 2DCE28D9 59F2815B 16F81798
Gy = 483ADA77 26A3C465 5DA4FBFC 0E1108A8 FD17B448 A6855419 9C47D08F FB10D4B8
Finally the order n of G :
n = FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE BAAEDCE6 AF48A03B BFD25E8C D0364141
and the cofactor is:
h = 01
Explanation of task:
Example and code:
Code:
p_string = 'FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE FFFFFC2F'
p = ZZ( '0x' + p_string.replace(' ', ''))
p
E = EllipticCurve( GF(p), [0, 7] )
E
n_string = 'FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE BAAEDCE6 AF48A03B BFD25E8C D0364141'
n = ZZ( '0x' + n_string.replace(' ', '') )
half_mod_n = 1 / GF(n)(2)
half_mod_n = ZZ(half_mod_n)
#first point on curve and Generator of curve
xP = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
yP = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
P = E.point( (xP, yP) )
#Point no 10 of the curve is multiply Generator and 10
P_10 = P * 10
#Point no 9 of the curve is multiply Generator and 9
P_9 = P * 9
# test halfing Point by 2
P_10_half = P_10 * half_mod_n
print("is P_10 after halfed by 2 is equal P5 : ",(P*5)==P_10_half)
P_9_half = P_9 * half_mod_n
# it is P_9_half = P_4 + P_05
P_4 = P*4
P_05 = P * half_mod_n
print("is P_9 after halfed by 2 is equal P4 + P_05 : ",(P_4+P_05)==P_9_half)
print(" it is possibiliy mult generator with float point P *1.5 : ",P*1.5)
**question: how to round Point after halfing to full integer ? example : P_9 / 2 = P*5 not P_4 + P_05?**
MiroslawThu, 22 Apr 2021 15:15:32 +0200https://ask.sagemath.org/question/56766/How to draw the following graphhttps://ask.sagemath.org/question/47594/how-to-draw-the-following-graph/I want to write the following code in sagemath but unable to write it:
Suppose we consider the group $\Bbb Z_n$.
We consider an element $a\in \Bbb Z_n$ and form the subgroup generated by $a$ i.e. $\langle a\rangle =\{a,2a,3a,\ldots 0\}.$
We form a graph $G$ whose vertices are $\langle a\rangle $ and $\langle a\rangle $ and $\langle b\rangle $ are adjacent if either $\langle a\rangle \subset \langle b\rangle $ or $\langle b\rangle \subset \langle a\rangle $ .
How to plot the graph $G$ is Sagemath?
I am giving an example to clear the question:
Consider $\Bbb Z_4$ then consider $\langle 0\rangle $, $ \langle 1\rangle$ , $ \langle 2\rangle$, $ \langle 3\rangle$
Clearly $\langle 0\rangle =\{0\}$, $ \langle 1\rangle=\{1,2,3,0\}$ , $ \langle 2=\{2,0\}\rangle$, $ \langle 3=\{0,1,2,3\}\rangle$.
Thus the graph $G$ has vertices as $\langle 0\rangle $, $ \langle 1\rangle$ , $ \langle 2\rangle$, $ \langle 3\rangle$ and
$\langle 0\rangle $ is adjacent to $ \langle 1\rangle$ , $ \langle 2\rangle$, $ \langle 3\rangle$,
$\langle 1\rangle $ is adjacent to $ \langle 2\rangle$ , $ \langle 0\rangle$,
$\langle 2\rangle $ is adjacent to $ \langle 1\rangle$ , $ \langle 0\rangle$, $ \langle 3\rangle$
and $\langle 3\rangle $ is adjacent to $ \langle 0\rangle$, $ \langle 2\rangle$
Thus $G$ becomes
https://imgur.com/Ef9P4uzCaptchaMon, 26 Aug 2019 16:02:04 +0200https://ask.sagemath.org/question/47594/Build the Cayley graph of this group on a given subset S2 – Cay(Γ2,S2),https://ask.sagemath.org/question/46720/build-the-cayley-graph-of-this-group-on-a-given-subset-s2-cayg2s2/Γ2 = C5 ×S3, S2 = {(3,(1,2,3)),(2,(3,2,1)),(1,(1,2)),(4,(1,2))}.
my code
G = PermutationGroup(['(3,(1,2,3))','(2,(3,2,1))','(1,(1,2))','(4,(1,2))'])
G
someone tell me how to set the group please codefunin13Thu, 30 May 2019 17:01:29 +0200https://ask.sagemath.org/question/46720/group algebrahttps://ask.sagemath.org/question/46218/group-algebra/Can anyone help in writing code to find the list of idempotent and primitive elements of a group algebra?
The examples goes like this. Let $p$ be an odd prime such that $\bar2$ generates $U(Z_{p^2})$ and let $G =(\text{ideal generated by }a) ∗ (\text{ideal generated by }b)$ an abelian group, with $o(a)=p^2$ and $o(b)=p$.
Then $F_2G$ has four inequivalent minimal codes, namely, the ones generated by the idempotents:
$$e_0 = \hat{G}$$
$$e_1=\hat{b}−\widehat{(\text{ideal generated by }a)∗ (\text{ideal generated by }b)}$$
$$e_2=\widehat{a−G}$$
$$e_3=\widehat{(\text{ideal generated by }a_p)∗ (\text{ideal generated by }b)}−\hat{G}$$bandanaTue, 16 Apr 2019 11:04:47 +0200https://ask.sagemath.org/question/46218/Power set with group operation as symmetric differencehttps://ask.sagemath.org/question/43507/power-set-with-group-operation-as-symmetric-difference/ My apologies for the novice question but I know that for a set X the powerset P(X) along with the symmetric difference (denoted by D) forms a group (P(X), D). I would like to form this group with sage and then build up a module over F = {0,1}. I've googled everywhere on how to go about this but I am having trouble. I can show these by hand and I would love to be able to formulate them in Sage. Thanks for your help. Samsam nazariWed, 29 Aug 2018 01:36:14 +0200https://ask.sagemath.org/question/43507/Routines for Pell's equationshttps://ask.sagemath.org/question/40202/routines-for-pells-equations/Hi,
I am interested in finding solutions to Pell's equations in finite fields. Are there Sagemath routines that I could use or should I create my own routines? I am interested in finding out solutions to the general equation x^2 - Dy^2 = 1 (mod p). Solutions to this form an closed Abelian group and the points form a cyclic subgroup.
Any suggestions/pointers would be deeply appreciated.
Thank you,
Rahul RahulKrishnanSun, 17 Dec 2017 17:21:54 +0100https://ask.sagemath.org/question/40202/How to compute a cyclic subgroup of a class group?https://ask.sagemath.org/question/38198/how-to-compute-a-cyclic-subgroup-of-a-class-group/ Hello, I am quite new to computing in Sage and I am stuck at this point. Please help me out. I am going to use algebraic number theory notation without explaining them in detail. All computations are in quadratic fields.
What I have :
- $\Delta_p=p^2\Delta_K$ where $p$ is a prime, $\Delta_K=-pq$ and $\Delta_K\equiv 1$ mod $4$
- I computed the class group, $C(\Delta_p)$ in Sage
What I want :
- Set $f=[(p^2,p)]$ in $C(\Delta_p)$ where $(p^2,p)$ is the standard representation of an ideal of norm $p^2$
- Set $F=\langle f \rangle$
My question is :
- How to get that cyclic subgroup $F$?
I have been looking at AbelianGroup and ClassGroup in Sage but I am not quite understanding how to use these to actually get what I want.
Any help in this matter would be greatly appreciated.jakkeonSat, 08 Jul 2017 19:52:42 +0200https://ask.sagemath.org/question/38198/Group of units of number field mod idealhttps://ask.sagemath.org/question/35499/group-of-units-of-number-field-mod-ideal/I am wondering whether Sage has a built-in function that takes an ideal $\mathfrak{a}$ of a number field and returns the unit group of the quotient ring $(\mathcal{O}_K / \mathfrak{a})^{\times}.$
More specifically the problem is to iterate through the characters of $(\mathcal{O}_K / \mathfrak{a})^{\times}$ (essentially Hecke characters) and apply them to a given element of $\mathcal{O}_K$. I am at a bit of a loss as to how to do this in Sage.user58293Thu, 10 Nov 2016 08:33:57 +0100https://ask.sagemath.org/question/35499/Get vector from abelian grouphttps://ask.sagemath.org/question/32436/get-vector-from-abelian-group/ I want to represent the Cayley graph of an abelian group (let's say $A=Z_5^2$) is a way that the element $g=a^i b^j$ is in the position $[i,j]$. I need a method `.pos()`such that:
A= groups.presentation.FGAbelian([n,n]);
g=A[2]
---> g = a*b*a^-1
g.pos()
---> [0,1]
How could I do that?
MLainzThu, 04 Feb 2016 02:30:48 +0100https://ask.sagemath.org/question/32436/Get abelian group element powers.https://ask.sagemath.org/question/32435/get-abelian-group-element-powers/ I have the abelian group (let's say, $Z_5^2$). I want to represent its Cayley graph as a grid, in which the element $a^i b^j$ occupies the $[i,j]$ position in the plane. For that, I need would need a method `.pos()`. which did the following.
A = groups.presentation.FGAbelian([n,n]);
e=A[2]
-->e=a*b*a^-1
e.pos()
--> [0,1]
How can I create something like that?MLainzThu, 04 Feb 2016 02:22:33 +0100https://ask.sagemath.org/question/32435/