Blog of Andrés Aravena

# La Biblioteca de Babel de Borges

04 May 2020

Some definitions from the story. Each line has 80 characters, there are 40 lines on each page and 410 pages on each book. This allow us to calculate the number of characters on each book.

pages_per_book = 410
char_per_book = 80*40*pages_per_book
char_per_book
1312000

A little over 1.3 million characters on each book. Each character can be any of 25 symbols. The total number of books is $$25^{1312000}$$ which is not easy to calculate without the proper tools. We have good tools, such as the BigNum library.

from BigNum import BigNum
books = BigNum(25) ** char_per_book
books
1.95604 e 1834097

This is a really big number. Is like 2 followed by 1.8 million zeros.

A quick “back-of-the-envelop” calculation can confirm this result. We have $25^n = 5^{2n} ≈ 4^{2n}=2^{4n}$ Thus we are speaking about s little more than 5.2 million bits. Using the rule of thumb $$2^{10}≈10^3$$ we get $$10^{1.6\text{ million}}$$ books.

The difference between $$5^{2n}$$ and $$4^{2n}$$ is important, so we will try better. We have

$25^n = 5^{2n} = 4^{2n\log_4(5)}$

We have that $$\log_4(5)≈1.16$$ so to change from base 5 to base 4 we need to increase the exponent by 16%. So 1.3 millions become 1.5 millions, and so we have near $$4^{3\text{ million}}=2^{6\text{ million}}$$ books.

In fact it may be easier just t, $$\log_2(5)$$ is a little more than 2, in fact near 2.32, thus $25^n = 2^{2n\log_2(5)}≈ 2^{4.64 n}$ When $$n$$ is 1.3 million, then $$4.64 n$$ is about 6 million. We need 6 megabits just to count the number of books in The Library. Now, $$2^n ≈10^{3n/10},$$ therefore there are near 101800000 books.

We need to work with orders-of-magnitude of orders-of-magnitude.

Using more data from the story, we can calculate how many books fit on each room, and therefore how many rooms are in the Library.

books_per_shelves = 32
shelves_per_wall= 5
walls_per_room = 4
books_per_room = books_per_shelves * shelves_per_wall * walls_per_room
books_per_room
rooms = books / books_per_room
rooms
3.05631 e 1834094

Again a very big number. Let’s try to put it in context. First, let’s calculate the area of each room. The area of a hexagon of side $$s$$ is $\frac{3\sqrt{3}·s²}{2}$ Thus, we need to know the width of each wall. We know that there are 32 books on each shelf, so we need to estimate the width of each book.

We need to make some assumptions.

• Paper thickness is around 0.0001m, that is, 10 pages per millimeter. This is based on the fact that a pack of 500 page takes more or less 5cm.
• Each sheet has 2 pages
• The covers are 1 mm each
paper_width = 1e-4
book_width = paper_width * (pages_per_book/2) + 2e-3
book_width
0.0225

Therefore, the wall width is

wall_width = book_width * books_per_shelves
wall_width
0.72

Now we calculate the area of one room

from math import sqrt, pi
room_area = 3*sqrt(3)/2 * wall_width*wall_width
round(room_area, 4)
1.3468

and then the area of the whole library

room_area * rooms
4.11637 e 1834094

Let’s compare this area with the surface of Earth

earth_radius = BigNum(6371e3)
earth_area
1.27516 e 14
room_height = 1.6
book_height = room_height / shelves_per_wall
book_height
0.32
aspect_ratio = 0.75
page_area = aspect_ratio*book_height*book_height
page_area
0.0768
paper_weight = 50e-3
page_weight = page_area*paper_weight
book_weight = pages_per_book*page_weight
round(book_weight, 4)
1.5744
room_weight = books_per_room * book_weight
round(room_weight, 6)
1007.616