My youngest daughter asked me this morning whether you can find the number 2013 in the digits of pi. I said it must be possible, then wrote the following Python code to find where 2013 first appears.

from mpmath import mp mp.dps = 100000 digits = str(mp.pi)[2:] digits.find('2013')

I use the multi-precision math package `mpmpath`

to get pi to 100,000 significant figures. I save this as a string and cut off the “3.” at the beginning to have just the string of digits after the decimal point.

The code returns 6275, so “2013” appears in the 6275th position in the string of digits. However, we usually count decimal places starting from 1 but count positions in a string starting from 0, so 2013 starts in the 6276th decimal place of pi.

So π = 3.14159…2013… where the first “…” represents 6,270 digits not shown.

* * *

Now we jump off into deeper mathematical water.

For some purposes, the digits of pi are random. The digits are obviously not random — there are algorithms for calculating them — and yet they behave randomly, and random is as random does.

If the digits of pi were random, then we could almost certainly find any sequence we want if we look long enough. Can we find *any* finite sequence of digits in the decimal expansion of pi? I would assume so, but I don’t know whether that has been proven.

You might expect that not only can you find 2013 in pi, but that if you split the digits of pi into blocks of 4, then 2013 and every other particular block would occur with the same frequency in the limit. That is, one would expect that the expansion of pi is uniform in base 10,000.

More generally, you might conjecture that pi is a *normal number*, i.e. that the digits of pi are uniformly distributed in *every* base. This has not been proven. In fact, no one has proved that any *particular* number is normal [reference]. However, we do know that almost all numbers are normal. That is, the set of non-normal numbers has Lebesgue measure zero.

In particular, it seems like we can claim to be able to find periodic sequences of arbitrary length in the expansion of an irrational number. Which seems true, but strange.

@Patrick Honner, do you think that’s is strange? I guess you never heard of The Book:

The Smartest Man in Babylon

(note: official abstrusegoose is currently in downtime)

Or, in tau, the proper circle constant, “2013” starts at digit 3480 (counting from 0, like a

realprogrammer, 3479.)@Patrick Honner, Not strange, I guess you never heard of The Book .

As you say, if pi truly does continue forever without repeating and is a truly random series of numbers, we would expect to find any finite series of numbers within the digits of pi. Let’s call the number represented by that series of digits x.

There must be no upper limit to the number of digits in x; the only stipulation is that it is finite.

Let f(n) be the integer truncation of pi times 10 to the n. So f(3) is 3,141 and f(5) is 314,159.

For any n, f(n) must appear somewhere in pi. Given the above, this can be trivially proven through induction.

Does this imply that the decimal digits of pi must include pi?

That seems wrong, because it violates the stipulation that the length of x’s digit string must be finite. but if it’s wrong, that means there exists some n where f(n) is not included in the decimal digits of pi.

There’s probably some property of infinite sets that I’m forgetting from college that makes this question silly, and I’ve never been much for higher maths. But I’m having a bit of trouble turning it over in my head.

Hello, John.

Are you aware of this definition?

http://en.wikipedia.org/wiki/Normal_number

In particular “it is widely believed that the numbers √2, π, and e are normal, but a proof remains elusive.”

Awesome. I hear that every knowledge that can be written are contained in pi. Is there any proof of this? I mean, can we proof that any character combination if converted to number are exist on pi?

@Nathan: Such is the nature of infinity.

The fact that almost all numbers are normal helps drive home the fact that the set of numbers humans actually use (or ever will use) has measure zero.

Nitpicking, but wouldn’t it be the 6274th decimal place of pi? You went 1 in the wrong direction. For example, look at the first “5” in pi:

pi = 3.141592…

String position(0-indexed): 5th

Decimal place: 4th

so 6275th string position should be the 6274th decimal, not 6276th?

Or did I misunderstand something?

Funny: I just wrote a function that looks for the first integer that doesn’t appear in digits. Seems to be 10000.

Last I looked into it IIRC, if every particle in the universe was used to encode a digit of pi, there would be a 50% chance of finding an arbitrary 300 digit number therein. Bits instead of digits perhaps, but the point remains: finding particular data of any meaningful length in pi is theoretically assured but practically improbable.

@Mufti: In an infinite sequence of random digits, there will eventually come a sequence of consecutive digits that encodes (say) the complete works of Mark Twain, or Mahler’s 9th symphony, or any other work, using any prespecified encoding.

Using the definition of “normal number” at the link John provided — i.e. a number where the limiting frequency of any sequence of k digits is 1/b^k in base b — this will also be true of any normal number. If the complete works of Mark Twain requires k digits to encode, then once in every b^k subsequences of length k (on average) you will get the complete works of Mark Twain.

So, if pi is normal, then the answer is yes. I’m not clever enough to know whether, if pi is not normal, the answer might still be yes.

That pi is normal only implies that pi contains all *finite* sets of information in it. Pi probably does not contain, for instance, all the digits of sqrt2 or e consecutively. And it can only contain countably many finite sets of information.

About normal numbers, this has to relate to Kolmogorov complexity in some way, no?

Maybe PI is a normal number, but I wonder if it would no longer be true when looking at at a higher statistical moments of the distribution (but maybe I’m misunderstanding the concept of “density” used in the definition of normal number).

It would seem paradoxal that a number with a low Kolmogorov complexity (such as PI) appears as random as a number with a high Kolmogorov complexity (a true random coin flip).

There seems to be some incorrect information floating around in the post and comments. There are many specific numbers known to be normal (in base 10), Champerknowne’s number is a classic example. However, all of the numbers known to be normal are defined by way of their expansion, not through geometry or algebra.

For a number to be normal, it is not enough for every finite string to appear in its expansion, it must appear with the correct frequency! It is quite possible (in the logical sense) that every finite string of digits appears in the expansion of pi, but that pi is not normal. Nobody considers that a realistic possibility, but we are still unable to rule it out. In fact, it is still possible that from some point on the only digits that appear in pi are 0 and 3, say. IIRC, in Carl Sagan’s book Contact, some apparent non-normality of pi is discovered and this has implications for the plot.

There are many numbers known to be irrational but whose expansions are not normal and do not contain every finite string. For example, let a_i be 1 if there is a multiple of sqrt{3} between i and i+1, and let a_i be 0 otherwise. Then the number 0.a_1a_2a_3… is irrational (since it is not repeating and not finite), but you will never see two consecutive 0’s, nor three consecutive 1’s.

Here are some data points regarding the connection between normality and Kolmogorov complexity. The Kolmogorov complexity of x is – more or less – the length of the shortest program that takes input k and returns the k-th binary digit of x). pi is believed to be normal to every base, while it has low Kolmogorov complexity. The 0.a_1a_2… number in my earlier comment is not normal base-10 (but probably is to other bases), and also has low Kolmogorov complexity. Champernowne’s constant is definitely normal base-10, but likely not to other bases, and has low Kolmogorov complexity. In “Absolutely Abnormal Numbers”, Greg Martin gives a low Kolmogorov complexity number that is not normal to any base. A random sequence of 0’s and 1’s, with 0 twice as likely as 1, considered as the binary expansion of x, will have high Kolmogorov complexity will not be normal.

It does “feel” like there should be a connection, but I don’t see what form it could take.

100,000 was a pretty good guess for the precision, because the last 4 digit number that occurs in the fractional part of the decimal expansion of π is 6716, starting at 99,846.

Low level contribution: /mpmpath/mpmath/, link broken.

@Kevin

Last time I asked, was told that normal numbers and Kolmogorov complexity are not necessarily related, and basically are independent definitions of randomness. Certainly Pi is a good candidate for and example of it (if only we could prove it’s normal)

Did you include that bit about “random” and “normal” in the explanation to your daughter? If you kept her attention with that…good for her!

Can you check when will be the second, the third,.. of the occurrence of “2013”?