Saturday 11 May 2013

Why 2^n is so scary in Algorithms

When you see notation like this:
2^64
What does it mean?
Why is 2^64 radically different to 2^128 ? It looks similar.
First let's dissect the notation.
2^64 is another way to write 264.
264 is a doubling of 2, 64 times.
Below, is a table showing 2 raised to the power of exponents from 0 to 128.



20 = 1
21 = 2
22 = 4 = 2 x 2
23 = 8 = 22 x 2 = 2 x 2 x 2 x 2
We can skip a few and state the results of some common low-value results.
28 = 256
210 = 1024
216 = 65536
and now some larger powers of two.
232 = 4,294,967,296  This is in the same ballpark as the human population of the Earth which is currently approaching 7 billion.
242 = 4,398,046,511,104  This is in the range of the number of cells in the human body.
264 = 18,446,744,073,709,551,616
296 = 79,228,162,514,264,337,593,543,950,336
2128 = 340,282,366,920,938,463,463,374,607,431,768,211,456 This would be something like the number of cells in 77,371,252,455,336,267,181,195,264 human bodies.

So although 264 does not look much different in symbols to 2128, the former number is easy to comprehend, and the latter pushes the limits of your imagination.
Yet this number is comprehend-able with a little effort. There are other numbers that are mind-numbing in concept. A number called Graham's number is the largest number ever used in a mathematical proof. It was a proof involving a branch of mathematics as an upper bound in a problem presented in Ramsey Theory.
Graham's number is so large that an ordinary digital representation requires so many bits of information that there are not enough states in the observable universe for it. It cannot even be represented with a 'tower' of powers.
ab where b=cd where d=ef...
and we need to use Knuth's up arrow notation or something equivalent. This is fodder for another article but it's useful to know that the up arrow notation uses iterated exponentiation. This is tetration.

The theoretical (but not practical) upper possible number of internet addresses available in an IPv6 packet header is 2128.  Hopefully when you see this number you will have a reasonable idea what it means.

No comments:

Post a Comment