Working with the set of real numbers

Steven D'Aprano steve at pearwood.info
Thu Feb 13 04:31:09 CET 2014


On Wed, 12 Feb 2014 21:07:04 +1100, Ben Finney wrote:

> Chris Angelico <rosuav at gmail.com> writes:
> 
>> On Wed, Feb 12, 2014 at 7:56 PM, Ben Finney
>> <ben+python at benfinney.id.au> wrote:
>> > So, if I understand you right, you want to say that you've not found
>> > a computer that works with the *complete* set of real numbers. Yes?
>>
>> Correct. […] My point is that computers *do not* work with real
>> numbers, but only ever with some subset thereof […]
> 
> You've done it again: by saying that “computers *do not* work with real
> numbers”, that if I find a real number – e.g. the number 4 – your
> position is that, since it's a real number, computers don't work with
> that number.

That answer relies on the assumption that "computers do not work with X" 
implies:

    for each element x in X:
        it is true that "computers do not work with x"

that is to say, a single counter-example of computers working with an 
element of X, even if it is a fluke, is enough to disprove the rule.

To give a real-world, non-programming example:

"The former South African apartheid government did not respect the 
Universal Human Rights of blacks."

Under your strict interpretation, we would have to say that even a single 
example of the apartheid government respecting even a single human rights 
of a single black person would be sufficient to disprove the claim.

But there's another interpretation available to us, one which is more 
suited to natural language statements as made by Chris: we interpret 
"computers do not work with X" as meaning:

    there is at least one element x, such that it is true that
    "computers do not work with x"


In the case of real numbers, there is an *uncountably infinite* number of 
such elements x. In fact, we can pick any two distinct numbers, no matter 
how close together, say:

    1
    1.000000000001

and be sure that there are an uncountably infinite number of real numbers 
which computers do not work with between those two values.

For the record, "uncountable infinite" is not just me emphasising that 
infinity is too big to count. It's a technical term from mathematics. In 
a nutshell it means that not only are there too many elements to count, 
but even in an infinite amount of time you couldn't count them all, not 
even if you counted infinitely fast.

In fact, it isn't just that there are *specific* real numbers which 
computers cannot represent (say, irrationals like pi or e, really tiny 
numbers like 1/(googleplex**googleplex**googleplex), or really huge ones 
like Graham's Number), but that the fundamental mathematical laws of the 
reals are violated by computers.

For example, it is not true that for every number x, 1/1(x)) == x.

py> 1/(1/93.0) == 93.0
False


Nor is it always true that a*(b+c) equals a*b + a*c, or that a+b+c is 
necessarily equal to b+c+a.


So it isn't even that floats are merely a subset of reals. They're 
actually not reals at all, since the fundamental properties of real 
numbers do not always apply to floating point calculations.



-- 
Steven



More information about the Python-list mailing list