# Loops in the Digits of Pi

Is $\pi$ special?

Of course, the concept of $\pi$ as the ratio between the diameter and circumference of a circle is more than important – a cursory glance through the arXiv suggests it appears in near 85% of all papers on theoretical physics. What I mean is are the digits of $\pi$ special? Is there anything actually significant hidden in the seemingly random digits of this all-important transcendental number?

This is a well-trodden topic among pseudo-intellectuals and science fiction writers alike. No less then the great Carl Sagan afforded a special significance to the digits of our friend $\pi$ at the very end of Contact (a part which didn’t make it into the movie). But is there any truth to this? Or even any evidence for it? In fact, how would you even go about trying to figure it out?

What got me thinking about this was a website I came across a few weeks back, talking about finding strings of specific numbers in $\pi$ – you can see it here. It’s a very cool page, which lets you do cool things like search for your SS number in the digits of $\pi$ (no joy for me there, I only get 8/9 numbers). However, down at the bottom they define something which I formalize as follows:

Loop Sequences: A loop sequence $\mathcal{L}$ in a string of single-digits integers $\mathcal{S}$ is a set of integers $\mathcal{L}=\{n_1,n_2,...,n_N\}$ such that as a string of single digits, the integer $n_j$ is found at the position $n_{j+1}$ in the string $\mathcal{S}$, and $n_N$ is found at position $n_1$.

This is perhaps best illustrated by an example. Let’s start with $n_1=169$. Turns out, starting at the 35th digit of $\pi$ (counting starting after the decimal point), we have …841971693993…, which contains 169 starting at the 40th position, so $n_2=40$. I continue to do this and find $n_3=70$, $n_4=96$, and so on until you find that you are looking 169 again! This is a loop sequence.

That web page gives a single loop sequence, found by one Dan Sikorski. I wondered if there are more – how common are these loops, and what would it take to find them? Sounding like an interesting computational project (rather than tackling this theoretically, which might be possible but struck me as more difficult), I though I would look for loops in some mathematical constants, along with random numbers, to see if there was any evidence for $\pi$ being special.

In short, no, there is not.

Of course, since these numbers are infinitely long, every number you start with must loop back at some point. What I’m after is how common these loops are. So let’s start with a million digits of $\pi$, and try to find loops that contain any of the numbers 1 to 100000 (rather arbitrary, but my PC can handle this in under an hour so it seems appropriate). The results are as follows:

For $\pi$, I found the following loops:

$\mathcal{L}_1(\pi)=\{1\}$ (this is self-referencing)

$\mathcal{L}_2(\pi)=\{40,70,96,180,3664,24717,15492,84198,65489,3725,16974,41702,3788,5757,1958,14609,62892,44745,9385,169\}$ (this might be called “the Sikorski loop”. And thanks to Jesse Chamberlain for pointing out a typographical error in an old version of this loop!)

$\mathcal{L}_3(\pi)=\{19,37,46\}$ (this is a new loop, but who knows if I’m the first to notice it!)

For $e$, I found the following loops:

$\mathcal{L}_1(e)=\{3624, 810\}$

$\mathcal{L}_2(e)=\{586, 1439, 4227, 19689, 76567, 4846, 16317, 32036\}$

$\mathcal{L}_3(e)=\{2543\}$ (self-referencing)

$\mathcal{L}_4(e)=\{170596\}$ (another self-referencing)

(the original version of this post had an error in the digits of e, which was found by some students who are working on this project with me, D Vadala and J Gormley.)

To see if this distribution is at all unusual, I generated 100 random strings of a million integers and did the same kind of search. The distribution for the random numbers, plotted with the strings I found in $\pi$ and $e$ is:

The random distribution probably looks exactly how one would expect it – smaller loops are far more common, and larger loops (>5 or so) are part of the statistical variation. Due to small number statistics, its very hard to convince yourself that $\pi$ and $e$ are particularly special in terms of the distribution of their loops. It might be tempting to say that the length 20 loop in $\pi$ lies outside the statistical variation, but you can see that I found loops of lengths 17, 18 and 31 in the random sample. For this reason, I would say this study does not suggest anything about the special character of the digits of $\pi$ and $e$.

I suppose one should go further to try and deal with the statistics, and perhaps I’ll just run my laptop for a week and do the 10 million digit version of this, but it’s a little hard to imagine that I will find any evidence to suggest that there are any cyclic patterns in the digits of $\pi$ or $e$.