Reverse engineering your prime birthday

If you follow the great big geeks on twitter - @jamesgrime and @standupmaths, I'm looking at you - you'll have seen bits and pieces of discussion about prime birthdays.

How to find your next prime birthday

It's your prime birthday if you've been alive for a number of days that happens to be a prime number - one that you can only divide by 1 and itself. 29 is a prime number - the only times tables it's in are 1 (times 29) and 29 (times 1).

And - I don't remember where I saw this, but I definitely didn't discover it - you can find your next prime birthday using Wolfram Alpha. It's a two-step process:

1) Type in "Days since (your birthdate). For me, that's "days since 15/11/1977" - and today I get 11978. Not a prime, of course; it's even. No cake for me.
2) If you then type "primes > (your number)", it spits out a list. When I say "primes > 11978", the first one is 11981 - three days time. I'd better start baking for Saturday!

ETA - hat tip to @gelada: You can also visit Prime Birthday if you don't want to mess around with Wolfram Alpha.

So that's straightforward. Right? Of course it is. What got me thinking was a tweet from @Caro_lann saying it was her prime birthday... but not which one.

Let's get geekier

Now, I'm a mathematician. My mind works in weird ways, and I'm conscious that what happened next was neither normal nor obvious to most people. I make no apology for that.

I wondered: could you use the density of someone's prime birthdays to figure out how old they are? That is, if you know how many prime birthdays they have in, say, a two-year window around today, can you figure out their age?

It's an investigation!

Carl Friedrich Gauss, bless his heart, found an expression for the density of prime numbers around a number x: $p(x) \approx \frac{1}{\ln(x)}$ , where $\ln$ is the natural logarithm.

Notice that that's a squiggly equals sign - it's roughly right, rather than precisely.

Let's test it with me: my calculator says $\frac{1}{\ln(11978)} = 0.1065$ or so. Over a two-year window, 730 days, Dr Gauss would expect 77.74 primes.

I asked Wolfram Alpha:  list of primes > (11978 - 365) and < (11978 + 365) and, handily, it tells me there are 77 primes in that two-year window. Let me stick my bottom lip out and nod impressedly; that's not a bad estimate at all((I know the correct thing to do is to integrate between limits. Unfortunately, $\frac{1}{\ln(x)}$ is not an easy integral, and far beyond the scope of this.))

How about backwards?

Now, does it work the other way? Can I take the 77 and turn it into my age?

I can certainly try - it's just algebra and finding the inverse of a function. We have $p = \frac{1}{ \ln(x)}$ , which we can juggle around to get $\ln(x) = \frac{1}{p}$, or $x = e^{\frac{1}{p}}$.

And does it work? Let's throw in the observed density ( $\frac{77}{730} = 0.1055$ ) and get out... 13102. Gauss thinks I'm about three years older than I am! So what's gone wrong?

Well, the obvious defence is that the formula is only approximate. But really, three years? That's nearly a 10% error - when the number of prime birthdays it predicted was pretty much bang on.

The real difficulty is due to the exponential. It's very sensitive to small changes. Our observed $\frac{1}{p}$ is 9.4805; the 'true' value should be 9.3908. That tiny error - around 1% - gets exaggerated when you put it into the exponential function. Our answer is off by a factor of $e^{0.09}$ or so - a little short of 10%.

Morals of the story

The moral of the story here... well, three morals.

  1. @Caro_lann can tell us the density of her prime birthdays and we won't be able to guess her age accurately;
  2. Tiny differences in what you put into your calculator can make big differences in your answers. You have an ANS button. Use it well.
  3. I'll be 12,000 days old in about three weeks. You can buy me a present here.

Edited 2014-09-21 to fix some LaTeX.

Colin

Colin is a Weymouth maths tutor, author of several Maths For Dummies books and A-level maths guides. He started Flying Colours Maths in 2008. He lives with an espresso pot and nothing to prove.

Share

4 comments on “Reverse engineering your prime birthday

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Sign up for the Sum Comfort newsletter and get a free e-book of mathematical quotations.

No spam ever, obviously.

Where do you teach?

I teach in my home in Abbotsbury Road, Weymouth.

It's a 15-minute walk from Weymouth station, and it's on bus routes 3, 8 and X53. On-road parking is available nearby.

On twitter