Going past the float size limits?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sat Oct 27 15:12:29 CEST 2007


On Sat, 27 Oct 2007 10:24:41 +0200, Hendrik van Rooyen wrote:

> So 0.002625**200000 is a number so small that its about as close as you
> can practically get to bugger-all, as it is less than 10 ** -400000, and
> more than 10**-600000

If you read the rest of the thread, you'll see I give a much more 
accurate estimate. It's approaching 10**-520000.


> Now I have heard rumours that there are approximately 10**80 elementary
> particles in the universe, so this is much less than one of them, even
> if my rumour is grossly wrong.
> 
> A light year is of the order of 9.46*10**18 millimetres, and no human
> has ever been that far away from home.  Call it 10**19 for convenience. 
> So your number slices the last millimetre in a light year into more than
> 10**399981 parts.

Numbers like 10**520000 (the reciprocal of the product found) is a 
perfectly reasonable number if you're dealing with (say) permutations. 
Admittedly, even something of the complexity of Go only has about 10**150 
possible moves, but Go is simplicity itself compared to (say) Borges' 
Library of Babel or the set of all possible genomes.

It's not even what mathematicians call a "large number" -- it can be 
written using ordinary notation of powers. For large numbers that can't 
be written using ordinary notation, see here:

http://en.wikipedia.org/wiki/Large_number
http://www.scottaaronson.com/writings/bignumbers.html

For instance, Ackermann's Sequence starts off quite humbly:

2, 4, 27 ...

but the fourth item is 4**4**4**4 (which has 10,154 digits) and the fifth 
can't even be written out in ordinary mathematical notation.


Calculating numbers like 10**520000 or its reciprocal is also a very good 
exercise in programming. Anyone can write a program to multiply two 
floating point numbers together and get a moderately accurate answer:

product = X*Y # yawn

But multiplying 200,000 floating point numbers together and getting an 
accurate answer somewhere near 10**-520000 requires the programmer to 
actually think about what they're doing. You can't just say:

A,T,C,G = (0.35, 0.30, 0.25, 0.10)
product = map(operator.mul, [A*T*C*G]*200000)

and expect to get anywhere.

Despite my fear that this is a stupid attempt by the Original Poster's 
professor to quantify the old saw about evolution being impossible 
("...blah blah blah hurricane in a junk yard blah blah Concorde blah blah 
blah..."), I really like this homework question.



-- 
Steven.



More information about the Python-list mailing list