# Python class for the ring $\mathbb{Z}[\sqrt{d}]$ ?

How to define and use the ring $\mathbb{Z}[\sqrt{d}]$ in Python? Is there a class for it? The purpose is to use Sage to verify some long calculations in an ideal generated by two elements. I don't know the name of the ring so it is difficult to declare proper tags.

edit retag close merge delete

Sort by ยป oldest newest most voted

This is an order in the number field $\mathbb{Q}(\sqrt{d})$:

sage: d = 5
sage: R = K.order(a)
sage: R.basis()
[1, a]
sage: OK = K.ring_of_integers()
sage: OK.basis()
[1/2*a + 1/2, a]
sage: R.index_in(OK)
2


Other options:

sage: d = 5
sage: ZZ[sqrt(d)]
Order in Number Field in sqrt5 with defining polynomial x^2 - 5 with sqrt5 = 2.236067977499790?

sage: d = 5
sage: ZZ[AA(d).sqrt()]
Order in Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790?

sage: d = 5
sage: K
Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790?
sage: ZZ[K.gen()]
Order in Number Field in a0 with defining polynomial x^2 - 5 with a0 = 2.236067977499790?

more