# Rings, Ideals, Quotient Rings in Sage

Hi everybody. I am new to sage. I want to construct rings, ideals, and quotient rings. I used Z.IntegerRing() to generate the ring of integers.

Question 1: Then I used I = Z.ideal(2) to get the ideal generated by 2 (even numbers). Question: How can I display the Elements. E.g. I(2) does not work in order to display the second element of the ideal.

Question 2: To generate the quotientring Z/2Z i used S = Z.quotient_ring(I). What if I want to generate the quotientring 2Z/6Z ? S = I.quotient_ring(J) does not work (I = Z.ideal(2), J = Z.ideal(6).

Thanks for any help

edit retag close merge delete

1

I think Z is defined as Z = IntegerRing(), not Z.IntegerRing().

Sort by » oldest newest most voted

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 of $\mathbb Z$:

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

more