Continuing my tradition of writing a blog post every pi day (14th March 3/14 , is celebrated as pi day every year). Today we will be discussing about the decimal expansion of pi and a class of numbers that are known as Normal Numbers. We will also be dealing with some minor biology and information theory. So sit back and enjoy.

I am pretty sure you have heard of it before. It is one of the most famous number in the world. π is a ratio that we come across if we study mathematics even at an elementary Level. You must already know that it has an unending infinite decimal expansion (Explored in previous post on how to calculate pi) . In this post we will talk about the beauty of pi in detail (See last year’s pi day post about surprising places pi appears in), discuss what are normal numbers and show (not prove) that π most probably is a normal number.

I have used python for analysing more than 100 Million Digits of Pi to show the Randomness and behaviour of pi and analysing the “Normalness”  of the Number.

We will also talk about why I believe , you, me and everything in the universe can exist in the unending digits of π.

## $${\pi}$$

### Life of Pi

Defined as the ratio of the circumference of a circle to its diameter, pi, or in symbol form, π, seems a simple enough concept. Although the number and it’s value was calculated way back in 2000 BCE by Early babilonians and Indian philosophers 1

The extent of the decimal expansion for the irrational number has gone up exponentially as more and more advancements have been made to machines. Many computer scientists took part in a race to calculate maximum digits in the expansion of pi. Recently the record is held by Timothy Mullican (USA) who calculated 50,000,000,000,000 digits using old server equipment and a software called y cruncher. 2

Here are first 100 digit of pi in base 10:

3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067

Above you can see I have colored few numbers separately. It is not just for aesthetic purposes(Although the colors do look pretty). I have separately colored digits 1,2,3,and 4 so that you can count the number of times they appear. 1 occurs 8 times, 2 appears 12 times while 3 gets repeated 10 times, and 4 appears 10 times again. If we take mean frequency of each digit appearing, we find it close to 10 times for 100 digits, giving a frequency of 0.1. Infact the table below provides you the value for all 10 digits: And you can see the distribution is more or less flat. Meaning If i were to pick up a digit randomly from the 100 digits written above, chances of the digit being 0 is equally likely than it being any other digit. This is known as uniformly distributed numbers.

+--------+----------------------------+------------+
| Number | Number of times it appears | Percentage |
+--------+----------------------------+------------+
|  ones  |             8              |    8.0     |
|  twos  |             12             |    12.0    |
| threes |             11             |    11.0    |
| fours  |             10             |    10.0    |
| fives  |             8              |    8.0     |
| sixes  |             9              |    9.0     |
| sevens |             8              |    8.0     |
| eights |             12             |    12.0    |
| nines  |             14             |    14.0    |
| zeroes |             8              |    8.0     |
+--------+----------------------------+------------+
Number of Decimal Places Considered: 100


Most of you can already see where this is leading to. Let us now introduce the concept of normal numbers and see how pi fits in there.

### Normal Numbers, Is pi normal?

For a non mathematician, normality of a number or abnormality of a number may sound absurd. It did to me when i first read about it 5 years ago. It was when i started writing this post and started my spiraling obsession with this number. Since then, the world record for expansion of pi has been broken multiple times. And my thirst of curiosity has not yet been quenched. Let us take a step back from the decimal expansion of pi and discuss what Normal Number actually is.

Wolfram Mathworld defines normal number as :

A number is said to be simply normal to base $b$ if its base- $b$ expansion has each digit appearing with average frequency tending to $b^{-1}$ 3

In simple words, if the number in in base 10 (digits 0 to 9), each digit will appear with frequency $\frac{1}{10}$ or 0.1.
Infact the frequency of finding a number that is k digits long is given by $b^{-k}$. So frequency of occurrence of objects like ’12’, ’01’,’99’ ,etc. has a frequency of $\frac{1}{10^2} = 0.01$ in decimal (base 10) system. And numbers like ‘123’,’078′,’569′,etc has a frequency of $\frac{1} {10^3} =0.001$.

It is an unsolved problem in Mathematics to prove that irrational numbers like $\pi$,$\sqrt{2}$, e or $\sqrt{s}$ for any s is a normal number or not. But we can still verify with whatever data that we have got if it is a normal number or not.

A few years ago I started looking at ways to calculate python to large number of digits. Unfortunately, soon i landed on an issue. And the issue (as always) turned out to be money. Or lack thereof. Perhaps this shouldn’t be a surprise, that to calculate pi-to say 100 million or a billion digits- it requires heavy expensive hardware. A few tens of thousand can be calculated in any usual machine. 4.

The internet as usual came to the rescue. You can download the expansion of pi online via multiple resources. If you really want to go crazy there is a 22 trillion digits datasets available online 5. I used this MIT’s database(see the reference) 6 for billion digits of pi.

I wrote a very simple code to count number of digits in the data file.All Codes are in the GitHub repository in the references below 7. (The repository has similar analysis code for $\sqrt{2}$ and e to check normality of the numbers)

Following table shows the result of code that processes a billion digits of pi. It took my not so decent laptop around 727 seconds (more than 12 minutes) to process all billion digits of pi.

The following chart provides results for 10 million, 100 million and 1 Billion digits of Pi. As we increase the number of digits, the percentage gets flattened out. We can do same analysis for finding two digit strings (like ’01’,’12’,etc.) and we will find the same uniform distribution now with probability staying around 1

Let us take it a step ahead. We know that from a uniformly distributed set, if we pick up a number it is equally likely to be any number. Can we say then that it is a completely random distribution. Yes, infact people have shown that digits of pi (with scrambling) can be used as better random number generators than what we already use in our machines. 8.

As we have shown in a normal number any set of k numbers follows the frequency 1/$b^{k}$. By definition, We can find any arbitrary set of number in the decimal expansion of pi (assuming we have appropriate number of digits). To be clear, if frequency of occurrence is 1/x, then we need more than x digits to get the set at least once in the expansion. (The mathematics of finding set of numbers in expansion goes beyond this and deals with binomial distribution) Take some time and let that sink in. It really blew my mind when I first realized it. For example, we can find first few digits of pi in the expansion of pi itself.

I did exactly this in another program, this program searches for a string of number (14159265 to be exact from $\pi ~3.14159265$ ) 9. As expected we get the number ‘1’ ($\frac{1}{10^1} \times 10^7$) almost a million times. String like ‘1415’ is found ~1000 times as expected using $\frac{1}{10^4} \times 10^7 = 10^3=1000$. A 8 digit long string should not exist in the expansion with $10^7$ digits, but here one such string exists. Can you think of reason why? It is quite an obvious one. (Hint: Same reason exists for why a 7 digit long string is occurring twice and not once.)