Ask Your Question

How to define / create a new Ring

asked 2015-03-24 02:58:46 -0500

LRM gravatar image


I just installed the version 6.5 of Sage. Then I saw in the help some page/tutorial about Basic Rings but I could not find an article (I googled) or an answer for the following:

How can I create a new ring? For example: How can I create a kind of ring of Integers (called ZZ in Sage) where I have only , say, even numbers?


sage: sqrt(4) in myZZ True

sage: 3 in myZZ False

Thank you for any help!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-03-24 07:27:29 -0500

tmonteil gravatar image

You can have a look at this thematic tutorial that explains how to implement new algebraic structures in Sage.

To implement the in feature, you have to implement a __contains__ method.

Do not hesitate to post your preliminary code for more questions.

edit flag offensive delete link more


I will take a look now. Thank you for your attention.

LRM gravatar imageLRM ( 2015-03-25 09:33:02 -0500 )edit

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


Asked: 2015-03-24 02:58:46 -0500

Seen: 66 times

Last updated: Mar 24 '15