Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

First, as mentioned by John, "your" integer ring should be defined by

sage: Z = IntegerRing() # or Z = Integers() or Z = ZZ

Question 1: There is no direct way in SageMath to ask for "the second element of I" when I = Z.ideal(2). Actually, it is not clear at all what should be "the second element". What you can do is test whether a given element belongs to I or not, or find the generator (note that this generator is an integer):

sage: I = Z.ideal(2)
sage: 2 in I
True
sage: 3 in I
False
sage: I.gen()
2
sage: type(I.gen())
<type 'sage.rings.integer.Integer'>

There is no such type as "the type of elements of an ideal" or something approaching.

Question 2: I am not definitive on this question, but I do not think you can define $2\mathbb Z/6\mathbb Z$ in SageMath. It is isomorphic to $\mathbb Z/3\mathbb Z$ that you can define.

One reason is that $2\mathbb Z$ is not considered as a ring in SageMath, but only as an ideal:

sage: I in Rings
False

First, as mentioned by John, "your" integer ring should be defined by

sage: Z = IntegerRing() # or Z = Integers() or Z = ZZ

Question 1: There is no direct way in SageMath to ask for "the second element of I" when I = Z.ideal(2). Actually, it is not clear at all what should be "the second element". What you can do is test whether a given element belongs to I or not, or find the generator (note that this generator is an integer):

sage: I = Z.ideal(2)
sage: 2 in I
True
sage: 3 in I
False
sage: I.gen()
2
sage: type(I.gen())
<type 'sage.rings.integer.Integer'>

There is no such type as "the type of elements of an ideal" or something approaching.

Question 2: I am not definitive on this question, but I do not think you can define $2\mathbb Z/6\mathbb Z$ in SageMath. It is isomorphic to $\mathbb Z/3\mathbb Z$ that you can define.

One reason is that $2\mathbb Z$ is not considered as a ring in SageMath, but only as an ideal:ideal of $\mathbb Z$:

sage: I in Rings
False
sage: I in Ideals(Z)
True