Written by Colin+ in algebra, geek pride, prime numbers.

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.

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:

ETA - hat tip to @gelada: You can also visit Prime Birthday if you don't want to mess around with Wolfram Alpha.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!

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.

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?

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.))

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%.

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

- @Caro_lann can tell us the density of her prime birthdays and we won't be able to guess her age accurately;
- Tiny differences in what you put into your calculator can make big differences in your answers. You have an ANS button. Use it well.
- 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.

Pingback: Tweets that mention Reverse engineering your prime birthday -- Topsy.com

## Melissa

Nice ploy to receive more birthday presents! 🙂

## Colin

I prefer to think of it as a strategy 😀

## icecolbeveridge

Looking through old posts, found this one on prime birthdays: http://t.co/FSJ46GIP — quite proud of it!