Technology

Your Life in Pi

Everything in your past—and future—is encoded in the digits of pi.

Life Encoded in Pi

Illustration by Robert Neubecker

“Pi is an infinite, nonrepeating decimal - meaning that every possible number combination exists somewhere in pi. Converted into ASCII text, somewhere in that infinite string of digits is the name of every person you will ever love, the date, time, and manner of your death, and the answers to all the great questions of the universe. Converted into a bitmap, somewhere in that infinite string of digits is a pixel-perfect representation of the first thing you saw on this earth, the last thing you will see before your life leaves you, and all the moments, momentous and mundane, that will occur between those two points.

All information that has ever existed or will ever exist, the DNA of every being in the universe, EVERYTHING: all contained in the ratio of a circumference and a diameter.”

From what I can tell, this meme comes from Redditor kenfoldsfive’s answer to the question, “Reddit, what’s the most mind-blowing sentence you can think of?” It’s been bouncing around the Internet for several months now and got a little boost recently when George Takei’s Facebook page shared it with nearly 4 million followers earlier this month. It certainly is a mind-blowing idea! Infinity is always hard for our puny finite brains to handle, and I admit that the vastness of irrational numbers blows my mind whenever I accidentally think about it for too long. We’re talking about a number that encodes not only my life story, but also a version in which my fly wasn’t down the first time I taught a class.

The only problem is, it isn’t true. Or, it’s probably true, but we don’t know for sure, and get off my lawn. At least that’s what the Huffington Post said last week. (On Tuesday it posted a more cheerful story about pi with some interesting illustrations.) The article makes some good points, but I think it misses the forest for the trees. If you look at it the right way, pi really does have it all.

The sticking point is the first assertion of the meme: Does pi contain every possible finite combination of digits? All irrational numbers, including pi, have infinite, nonrepeating decimal representations, but this is not enough to ensure that they include all strings. For example, 0.1010010001 … is a perfectly acceptable irrational number, and it never even includes the digit 2.

In an edit to the original post, kenfoldsfive notes that the statement is true if pi is a “normal number,” meaning that every finite string occurs with exactly the frequency you’d expect if the digits were random. For example, 10 percent of digits are 1s, 10 percent are 2s, and so on. (This is for numbers written in base 10. Normality can be defined for binary, hexadecimal, or any other base.) In 1909, mathematician Émile Borel proved that “almost every” real number is normal. The mathematical meaning of “almost every” is more extreme than the typical English meaning. Borel showed that there is basically a 0 percent chance that if you pick a real number truly randomly, you’ll get one that isn’t normal.

For this reason and analysis of the first few trillion digits of pi, most people who care about such things believe that pi is indeed normal. There’s no reason to think it isn’t, except that no one has proved it yet. There’s a lot we don’t know about pi. After all, we only know 10 trillion digits of it, a mere speck in the grand scheme of things. We don’t even know whether every digit appears infinitely often. Maybe there are only 101,000 7s.

But the focus on whether or not pi is normal misses an interesting question: Exactly how would we translate an irrational number into a bunch of text? At its heart, the meme is saying that there is something essentially infinite about irrationality that can be used to represent everything contained in our finite world. And that’s right, if you choose your “code” correctly.

The meme suggests ASCII, a method of rendering characters using either seven or eight binary digits. (There is a decimal version as well.) Ignoring some technical details about how ASCII is really implemented, let’s pretend that every two-digit combination from 00 to 99 encodes a different letter, number, space, or punctuation mark. Then we just go through the digits of pi two at a time and get some string of symbols out. If pi is normal, your life story is in there somewhere.

But there’s nothing essential about this method of coding. My friend David Ralston at the mathematics department of SUNY Old Westbury, told me about a different way to extract text from numbers.

Let’s say you want to find your life story in pi. We’ll assume your life story isn’t going to take up more room than the Bible, around 3.5 million characters in English, according to this guy’s grandfather. Close enough for me. (You can pick any upper limit to the number of characters you think you’ll need; the process can handle any number.) Now you need to make a list of all possible words that are no more than 3.5 million characters long. I’d recommend writing all the one-letter words first, followed by all the two-letter words, and so on, using alphabetical order at each step. This gives you some huge but still finite list of possible words—let’s say K is the number of them.

What we need now is a way to assign each word on this list to a unique chunk of information that appears in pi. In other words, we need to find at least K distinct “things” in the number pi. To do this, we exploit the fact that for any irrational number, there are at least K+1 distinct strings that are K digits long. For example, if you look for strings that are two digits long in the irrational number 0.101001000100001 … , you will find three strings: 10, 01, and 00. For strings of three digits, you will find at least four examples.

Using this fact, we look at the digits of pi in chunks of length K. To the first chunk, assign the first word on your list. To the second distinct chunk (which may overlap with the first; that’s OK), assign the second word, and so on. We “only” have K words on our list, and we have at least K+1 distinct blocks of length K, so we’ll run out of words before we run out of blocks. If we have more distinct blocks than we have words on our list (we will), we can just start over at the beginning of our list of words. There’s nothing wrong with encoding the same word twice. That will happen anyway because some K-digit blocks will show up multiple (and even infinitely many) times.

This process is not as straightforward as ASCII coding, but for any given irrational number, it gives us all possible strings up to some finite length. It might feel like cheating because we’ve specified what we want to find. But I think it’s like finding a needle in a haystack: It’s not going to happen if you’re not looking for needles. And there is no upper limit to how long the things on your list can be, Ralston wrote in an email. It could be, “for example, all strings whose length is not larger than the number of elementary particles in the observable universe, which is (I think) a reasonable restriction to place on ‘all possible words,’ and includes the binary code for a very high-resolution JPEG of that awkward moment from your senior prom.”

We don’t know for sure that pi contains all possible strings of decimal digits, but on a deeper level, the meme is right. And if it gets you pondering the mysteries of infinity, so much the better. You won’t be alone. The idea that monkeys sitting at a typewriter would eventually produce the complete works of Shakespeare has been around for decades. To continue bending your mind, I recommend these variations on the theme. Jorge Luis Borges explores the darker side of the concept in his short story The Library of Babel, and the always entertaining Vi Hart’s video for Pi Day 2012 tackles the question, “Are Shakespeare’s Plays Encoded in Pi?” Enjoy!