First time here? Check out the FAQ!

Ask Your Question
0

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

asked 14 years ago

ccanonc gravatar image

updated 10 years ago

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?

Preview: (hide)

Comments

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

ccanonc gravatar imageccanonc ( 14 years ago )

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

ccanonc gravatar imageccanonc ( 14 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 14 years ago

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?

Preview: (hide)
link

Comments

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

ccanonc gravatar imageccanonc ( 14 years ago )

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

Mike Hansen gravatar imageMike Hansen ( 14 years ago )

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 ( 14 years ago )

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: 14 years ago

Seen: 489 times

Last updated: Aug 28 '10