Ask Your Question
3

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

asked 2023-06-17 12:04:25 +0100

Rafal Mi gravatar image

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-06-18 09:35:56 +0100

rburing gravatar image

updated 2023-06-18 12:08:57 +0100

slelievre gravatar image

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

sage: d = 5
sage: K.<a> = QuadraticField(d)
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 = QuadraticField(d)
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?
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2023-06-17 12:04:25 +0100

Seen: 173 times

Last updated: Jun 18 '23