Ask Your Question
0

How do I get the classical N1 object rather than N*? (NN)

asked 2010-08-27 22:33:14 +0100

ccanonc gravatar image

updated 2015-01-17 22:40:46 +0100

FrédéricC gravatar image

Sage's global "NN" is the modern definition of the natural numbers (N0, which includes zero); how do I get instead an object representing the classical definition (N1 a.k.a. N*, which excludes zero)?

http://en.wikipedia.org/wiki/Natural_...

sage: NN

Non negative integer semiring

If I want to make further set subtractions, how do I do so? What trade-offs might I encounter typically with such operations?

edit retag flag offensive close merge delete

Comments

sage: Set(NN) - Set([0]) Set-theoretic difference between Set of elements of Non negative integer semiring and {0}

ccanonc gravatar imageccanonc ( 2010-08-27 23:28:37 +0100 )edit

If I were to make further set subtractions, what operations would become slow?

ccanonc gravatar imageccanonc ( 2010-08-27 23:31:41 +0100 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2010-08-28 15:10:16 +0100

Mike Hansen gravatar image

You can get the set of positive integers with PositiveIntegers:

sage: PP = PositiveIntegers(); PP
Positive integers
sage: PP.cardinality()
+Infinity
sage: iter(PP).next()
1

In addition for any given range of integers, you can use the IntegerRange class to get an objects representing them. In fact, PositiveIntegers is just a specialized subclass of IntegerRange.

sage: NN1 = IntegerRange(1, oo); NN1
{1, 2, ..}

What types of operations are looking to do with this set?

edit flag offensive delete link more

Comments

All kinds. =) Showing my math ignorance: Is it impossible for NN1 to be a semi-ring instead?

ccanonc gravatar imageccanonc ( 2010-08-28 17:31:00 +0100 )edit

Yes, it is impossible since semirings contain an additive identity (0) which NN1 lacks.

Mike Hansen gravatar imageMike Hansen ( 2010-08-28 17:35:08 +0100 )edit

Thanks. I noticed in the tab-completion-dropdown for "NN1." there are some methods which aren't implemented, such as "random_element()", which raise the NotImplemented Exception. It would be a cool UI feature if these methods were grayed-out (indicating unavailability).

ccanonc gravatar imageccanonc ( 2010-08-28 17:47:55 +0100 )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

Stats

Asked: 2010-08-27 22:33:14 +0100

Seen: 477 times

Last updated: Aug 28 '10