The symbol π is overloaded in math: depending on context and capitalization, π could be the constant we all know and love (or hate), a projection, a product, or a function. There's plenty of stuff to read about the circle constant, so today I'm writing about one of those other π's.
Today's π is the prime counting function. (A prime number is a whole number whose only divisors are one and itself. A prime can't be written as a product of two other whole numbers in an interesting way.) The function π(x) is pretty easy to understand: for any positive number x, π(x) tells you how many primes there are that are less than or equal to the number x. So π(1) is 0 because there are no primes smaller than 2, π(2)=1 because 2 is prime, π(3)=2 because both 2 and 3 are prime, π(4)=2, and so on.
I was thinking about π(x) because I recently discovered the Twitter account @_primes_. Every hour on the half hour, it tweets the next prime number. (Details on github.) A few weeks ago, for example, it tweeted this prime, not far from π10,000.
— Prime Numbers (@_primes_) February 20, 2014
Of course, the first question that popped into my head when I discovered this account was how long we had until Twitter's 140 character limit would prevent @_primes_ from tweeting the next prime. In other words, how many prime numbers are smaller than 10141? (That's a 1 followed by 141 zeroes, the first integer that doesn't fit in a tweet.*) And that's where the prime counting function comes in. I needed to know the value of π(10141). That's how many hours it is before @_primes_ has to take its ball and go home.
Off I went to look up π(10141). Done and done. Well, kind of. The only problem is that we don't actually know what π(10141) is. Big numbers are big, and their bigness is hard to comprehend. It only takes a few characters to write 10141, but it's an impossibly big number. There are only about 1080 atoms in the known universe, so 10141 is the number of atoms in 1061 universes. All that to say, I shouldn't have been surprised that we don't know what π(10141) is. In fact, the largest number x for which we know the exact value of π(x) is 1024. It's a really, really big number but a tiny, tiny fraction of 10141.
Luckily, we have the prime number theorem, which is almost as good as knowing π(10141). The prime number theorem tells us that as x gets bigger and bigger, π(x) approaches the ratio x/ln x, where ln is the natural logarithm, or logarithm base e. The estimate gets better as x gets larger, so the number 10141/ln 10141 is a pretty good estimate of how many primes we can fit on Twitter. And that number is...also impossibly huge. Specifically, it's about 3x10138, or the number of atoms in 1058 universes. Yikes!
Remember when I said that big numbers are big? I'm not very good at reasoning about big numbers. It's totally obvious to me now that 10141/ln 10141 should only be a few orders of magnitude smaller than 10141, but I was surprised when I first saw it. 10138 just seemed way too big to me! But it's true. 10138 is quite small compared to 10141.
The calculation allayed my fear that we have only a few years left of delightful tweets by @_primes_. 310138 hours is about 310134 years, or 2.510124 times the age of the universe. In an uncertain world, one thing is sure: you, Twitter, our sun, and I will be long dead before character limits keep @_primes_ from tweeting the next prime. What a relief!
*Oops, 10140, a 1 followed by 140 zeroes, is the first number that won't fit in a tweet, not 10141. I have left the numbers in the post as is. If you need more precise estimates, you can apply the same analysis to 10140 instead of 10141. Don't worry, it's still a long time before character limits hinder the @_primes_ bot!