HP Forums

Full Version: Little math problem(s) November 2020
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Reading the library of babel (n1, n2) was a pleasure.
Thinking about it, I was interested to know what one could represent with all the possible permutations of a finite number of symbols in a finite amount of places.

I didn't investigate much on the part where one introduces a protocol external to the representation (that is, a protocol that is not represented within the permutations but it is used to give meaning to a combination of permutations); but without any of this one should not be able to represent infinite processes that are not periodical.

Now let's say we have a book containing 1 million characters (for simplicity, be it those visible on a standard PC US keyboard, not even ASCII). If we want to represent PI we should have at least one book explaining the procedure, then books having all the possible permutations of numbers up to 1 million slots, then indexes of indexes that tell us the order how to read those books one after another to construct PI.

Since PI is infinite and not periodical, if I am not mistaken we should run out of possible valid permutations that could help forming the indexes. In other words we run out of space to construct the tree or chain of indexes to construct PI. If we could have infinite indexes then we could construct PI even with finite permutations because it is how we are doing it currently. Indeed we use only 10 digits, only the order of those needs to have infinite space.

Aside from infinite processes, I thought that finite ones should be representable. But then thinking a bit more I am not sure.

Shrinking the example. Imagine we have 4 bytes, all the permutations of those 4 bytes. Thus we have 2^32 possibilities.
Now imagine we have a protocol (admittedly external to the representation) where we want to represent a large number (thus finite) combining the available permutations of the 4 bytes in a certain order.

To do this we add an external source of data (that we shouldn't add). A collection of 1000 (or 10k or 100k or an arbitrary large finite collection) addresses (could be hex form, decimal, binary or whatever other format) that tell us which of those 2^32 combinations to pick to construct the number, in order. Left to right.

The point being, with 1000 (or any other finite number N) addresses one could map binary numbers up to 2^32000 (accordingly, 2^(32*N) ) but not all of them.

Thus, if I am not mistaken, even with the limits of the library of babel. Having all the permutations of 1 million characters (or more), one can catch a lot of content (indeed even this very comment), but not necessarily all that is possible. Though it is really interesting to see that a vast quantity of things that can be discovered (or "invented" ) is already there. Only it costs less to rediscover them from scracth rather than going through the library itself.

Am I missing something? What is your take on it?

n1: https://www.hpmuseum.org/forum/thread-15921.html
n2: https://en.wikipedia.org/wiki/The_Library_of_Babel
n3: Almost this very comment https://libraryofbabel.info/browse.cgi book -> Volume 2 , page 67 , on Shelf 4 of Wall 2 of Hexagon:


# I know that this is generated on the fly. But had the library been there, like in a platonic world, it had contained that information ab aeterno
You are correct. One quickly runs out of room to store lists like permutations. It's possible to store (for example) 2^32 different symbols in 32 bits. However, there are (2 ^32)! permutations.
It's a pity really, if the best work of fiction ever happens to require 1000001 characters. (1001 Nights springs to mind, and it might well be longer than that...)
I'm sure that this isn't optimal and it certainly doesn't fit into 4 bytes:


It's still a pretty neat formula.

(11-21-2020 10:10 AM)Paul Dale Wrote: [ -> ]\(\pi=\sqrt{6\zeta(2)}\)

I used that here Smile

(11-21-2020 09:59 AM)EdS2 Wrote: [ -> ]It's a pity really, if the best work of fiction ever happens to require 1000001 characters. (1001 Nights springs to mind, and it might well be longer than that...)

Tha wouldn't be a problem as one could use a book as a catalog, and two books for the content.

My point was that even with finite content, one runs out of space to compile the entire catalog even with a very large space.
Ironically, I saw "The Name of the Rose" last night. That was one crazy library. Smile

(11-21-2020 10:45 AM)grsbanks Wrote: [ -> ]
(11-21-2020 10:10 AM)Paul Dale Wrote: [ -> ]\(\pi=\sqrt{6\zeta(2)}\)

I used that here Smile


Instead of random number simulation, we can also do brute force.
Probability of a,b co-prime to each other (1 ≤ a,b ≤ n) = (number of co-primes pairs) / n^2

Number of co-prime pairs = sum(sum(gcd(x,y)==1, y=1 .. n), x=1 .. n)

We can simplify with symmetry: gcd(x,y) = gcd(y,x), gcd(x,x) = x:

XCAS> sum(sum(gcd(x,y)==1, y=1 .. x-1), x=1 .. n) * 2 + 1             (*)

+1 is due to under-counted gcd(1,1) = 1 (1 is co-prime to all integers)
We could also include the diagonal, and remove the over-counted gcd(1,1).

XCAS> sum(sum(gcd(x,y)==1, y=1 .. x), x=1 .. n) * 2 - 1

Inside sum is Euler totient function. (ref: "C++ for Mathematicians", page 67)

XCAS> P(n) := (sum(Phi(x), x=1 .. n) * 2. - 1) / n^2
XCAS> estimated_Pi(n) := sqrt(6./P(n))

XCAS> estimated_Pi(200)      → 3.13220921695, error = 0.2987%
XCAS> estimated_Pi(1e3)      → 3.14041534038, error = 0.0375%       (**)
XCAS> estimated_Pi(1e4)      → 3.14153423902, error = 0.0019%
XCAS> estimated_Pi(1e5)      → 3.14158477584, error = 0.0003%       // on my laptop, this take 2 seconds

(*) XCas sum(f(x), x=a .. b) had weird meaning if a > b+1
If a = b+1, result is 0
If a > b+1, result is -sum(f(x), x=b+1 .. a-1)       // see XCas sum limit confusion

(**) the blog wrongly stated for n=1000, error = 0.06%
Reference URL's