Ask Your Question
0

How th work with enumerable and infinite set

asked 2014-07-18 08:51:01 -0500

anonymous user

Anonymous

updated 2014-07-19 04:21:12 -0500

Hello,

I am trying to do following: construct the set B that is the difference between QQ and the set of the prime numbers (note that B is a countable set). Within Sage, I tried the following

X = Set(QQ)
Y = Set(Primes())
B = Set(X.difference(Y))
B.cardinality()

then I press evaluate. I am expecting that the cardinality of B is +Infinity. But Sage does not bring any result.

I tried this also initializing B like

B = InfiniteEnumeratedSets(RR).

Could anybody please give me a hint what I am doing wrong?

Thank you very much and regards.

vbk

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2014-07-18 09:25:06 -0500

Luca gravatar image

You just found a bug in Sage. Sage does not have enough knowledge to know that the set of rationals that are not prime numbers is infinite. If there was no bug, you'd have an error saying something like "Sage cannot compute the cardinality of B".

However, if you type B.cardinality??, you'll notice that what the function does is simply return len(list(self)), i.e. it constructs the list of ALL rationals that are not prime numbers, and returns its length. You get no answer because it's entered an infinite loop.

edit flag offensive delete link more

Comments

Luca gravatar imageLuca ( 2014-07-18 09:37:45 -0500 )edit

Thank you for the reply. vbk

Vasile gravatar imageVasile ( 2014-07-21 01:42:06 -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

Stats

Asked: 2014-07-18 08:51:01 -0500

Seen: 97 times

Last updated: Jul 19 '14