[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why float('Nan') == float('Nan') is False

?On Thu, Feb 14, 2019 at 8:24 AM ??????? <uri at speedy.net> wrote:?
> On Wed, Feb 13, 2019 at 10:20 PM Chris Angelico <rosuav at gmail.com> wrote:
>> Why would no two infinities be equal? In mathematics, there's one
>> best-known infinity (aleph null, aka the number of counting numbers),
>> and many many infinities are provably equal to it. (Others are
>> provably NOT equal to it, like the number of real numbers.) There's
>> nothing wrong with saying "there are as many prime numbers as there
>> are odd numbers", or equivalently that "the size/cardinality of the
>> set of primes is equal to the size of the set of odd numbers" [1]. And
>> both Python and IEEE agree:
> There are more integers than odd numbers, and more odd numbers than prime numbers. An infinite set may be a subset of another infinite set although they may both have the same cardinality. Or in other words, the number of elements in each set is not equal. One has more elements than the other. AND, by induction you can also prove that the other one has more elements than the first one. So the number of elements in two infinite sets can't be equal. Even, if you compare the same set to itself.

You can enumerate the odd numbers easily. The first odd number is 1,
the second odd number is 3, the third is 5, the fourth is 7, etc, etc.
Or if you want to include negative odd numbers, the first is 1, the
second is -1, the third is 3, the fourth is -3, the fifth is 5, the
sixth is -5, etc. Thus there is a clear and easy bijection between odd
numbers and counting numbers. You aren't going to run out of counting
numbers before you run out of odd numbers or vice versa.

The same is true of prime numbers. The first prime number is 2, the
second is 3, the third is 5, the fourth 7, the fifth 11, the sixth 13.
You can never "run out" of prime numbers [1], so you can enumerate
them all. Thus there's the same bijection between prime numbers and
counting numbers, and thus there are equally many.

Therefore, since you can take any odd number and find its position in
the list, and then find the same position in the list of primes, it
would be possible (albeit computationally impractical) to find the
corresponding prime number for any odd number. There are just as many
prime numbers as odd numbers.


[1] Proof by contradiction: if there were finitely many primes, you
could multiply them all together and add one. The result is greater
than any number on your list, and can't be a multiple of any of the
primes, ergo it's either prime, or a product of primes not on your
list. QED.