Monday 24 February 2014

Nostalgic numbers - fun with numerical anagrams

As I battled to dry the tears running down my wrinkled face with facts about my latest age, there was a fleeting moment when I thought 'hey, when you double 26 you reverse its digits, don't you?'. Answer: uhh.... no (exercise: prove this). But I started to wonder whether any two-digit numbers did have this property, that switching the digits results in a number that's twice the original. Have a go if you like and see what you find.

The answer this time? Well, it's also 'uhh... no', but a slightly more impressive one. To prove it, notice that if our number is written with two digits, xy, then it has value 10x + y. We'll write (x,y) rather than xy to avoid confusion with multiplication. We want (y,x) to be twice (x,y), which means the following property must hold:

10y + x = 2(10x + y) , so
10y + x = 20x + 2y,
8y = 19x,
y = 19/8 x.

We can see that x needs to be divisible by 8, or y won't be a whole number. So x must be at least 8, but then y needs to be at least 19. What does it mean for a digit to be greater than 9? Not much! There can't be any pairs of digits (x,y) that satisfy this equation. Bam.

[I initially wrote a different proof of the above, which I'll post as a comment below.]

On first glance, that's a shame, but on second - not really. There's something much more interesting going on behind the scenes, namely that if we choose to work in a different base, it is possible to find solutions. Quick base primer: usually when we write a number, it's code for adding powers of ten together to represent a quantity, for example

217 = 2*100 + 1*10 + 7*1.

But we don't have to use ten as the base: for instance, since

217 = 4*49 + 3*7 + 0*1,

we could write the same quantity as 4307, which we call the 'base 7' representation of the number. 'Binary' refers to the base 2 representation; 21710 in binary would be 110110012. Mathematicians don't like numerical statements that are dependent on an arbitrary label such as the number's base representation, unless that notion can be generalised to all bases. If we had found solutions, but only in base 10, we would still be missing infinitely many others!

Let's get ourselves into a more general mood here. In base k, the number with digits (x,y) has value kx + y, and we're looking for numbers with the property that

ky + x = 2(kx + y).

Expand this out, rearrange (as before) and we're left needing

y = (2k - 1)/(k - 2) x.

The problem is now just a matter of finding the values of k, x and y that solve this equation. To get the ball rolling, one solution is (k,x,y) = (5,1,3), i.e. in base 5, the number written '31' is twice the number written '13'. Indeed, we find that

135 = 1*5 + 3 = 810 and
315 = 3*5 + 1 = 1610 = 2*810.

Since I initially had decrepitude in mind when thinking about these, I've decided they should be called 'nostalgic pairs', which to me evokes images of the larger number gazing into the mirror (calibrated to a certain base!) and seeing its old self, half its current age, reflected back. The table shows the lower halves of a few more nostalgic pairs and a general rule for constructing the rest. The rule is fairly easy to deduce once you notice a pattern, and you can check it's correct by plugging it into the above formula.

kxyBase 10 representation
5138
82521
113740
144965
............
3n+2n2n+1(3n+1)(n+1) [any base]

So the first few nostalgic pairs, expressed in base 10, are {8,16}, {21,42}, {40,80} and {65,130}. Although 130 is three digits in base 10, in base 14 it's only two: 9414. You can see that the list goes on: there are infinitely-many two-digit nostalgic numbers and the second digit and base are entirely determined by the first digit. Note that we can't construct, say, the digits (2x,2y) from (x,y) in this table and have a solution for the same base, since 2y would be (4n + 2), larger than the base it's supposed to be written in. Similarly we can never divide (x,y) by some constant to find a smaller pair of digits, because if a number were to divide x = n, it would always leave a remainder of 1 when dividing y = 2n + 1. There's a little more work involved in proving the above ratios between x and y are the only solutions and it's more fiddly than interesting, so I'll omit it and leave it for you to do if you're really keen.

It gets better! Why stop at doubling numbers to reverse their digits? What about numbers that flip when you triple them, quadruple them, and so on? They also exist, also in infinite quantities, and although the situation is similar there's a few extra things to say about them (as well as more cute names to give them, of course), which I'll leave for another week. I'm also pleased to report the first three-digit nostalgic pair, which took me a little while, but starts with the base 5 quantity:

1435 = 4810, which is double 3415 = 9610.

Awesome.

Tuesday 18 February 2014

26, biprimes and dimensional gates - how interesting is your age?

Whenever my - or a friend's - birthday is approaching, I try to find something mathematically interesting about the age the person is about to become. It takes the edge off growing old and I discover everyone is secretly nerdier than they let on. Easy choices are primes, numbers with lots of factors, squares and so on, and I recently made my way through each of those as I turned 23, 24 and 25. Sometimes there are more exciting options. 3, 7, 31 are Mersenne primes. 4 is 22, 27 is 33, and you're unlikely to make it to 4(sorry). 6 is a perfect number, which explains why A.A. Milne wanted to be 6 for ever and ever, but he may have lacked the clever-as-cleverness to realise 7 is happy. Apparently perfection doesn't equate to happiness... until you turn 28, that is.

But what can you say about 26, my latest age?

Well, it has just two prime factors, 2 and 13, which makes it a 'biprime' (or 'semiprime'). In some sense, that's the closest you can get to primality without hitting it. That's kind of interesting, but is it as special as being prime? If you know n primes then you can get n(n+1)/2 biprimes right off the bat by multiplying together every pair of primes and removing the ones you counted twice, so there are more known biprimes. But perhaps that's unfair: we're letting ourselves count biprimes over a much larger range, which might include unknown primes (and biprimes) as well. If, on the other hand, we consider the ratio of primes/biprimes up to and including a certain number k, the primes put up a better fight. In fact, for the first couple of dozen values of k the primes are more common, with a few points where the frequencies match. And the first value of k at which biprimes outnumber the primes? 26! 26 is the hero (or villain) that starts the revolution. Nice one, 26.


We see two more flips at 31 and 34, where the balance of power changes again. I think it would be fun to have an infinite chain of these numerical nemeses. Sadly the k = 41 to 120 rows are all green, suggesting that perhaps the biprimes do eventually overpower the primes forever (at k = 120 there are 31 primes to 38 biprimes). Not that that's a given: processes like random walks are capable of arbitrarily large excursions away from their starting points, yet still return to the beginning infinitely often. At any rate there might still be a limiting ratio that would give a notion of relative scarcity (hence 'specialness'!).

I only discovered the above mini-accolade for 26 as I sat down to write this entry, so I wasn't aware of it previously. Biprimality in itself not seeming too special, I figured I was in for a boring year until I happened across something in the book Fermat's Last Theorem by Simon Singh. There is only one instance of a square number being exactly two fewer than a cube, i.e.

m2 = n3 - 2,

for some integers m and n. The square and cube in question are 25 = 52 and 27 = 33, which means that 26 is uniquely sandwiched exactly above a square and below a cube. Half the fun of recreational mathematics is sexing up the names of everything you encounter, so let's call 26 the 'dimension gate', since it bridges the gap between the second and third dimensions. What about numbers

d = m2 = n3

at which the dimensions truly meet, such as 64 = 82 = 43, 729 = 272 = 93, 1,000,000 = 1,0002 = 1003? I think these have a more natural dimension-crossing quality than 26, so maybe they're more like wormholes. Imagine the topology caused by squares and cubes (and more) stretching and squishing into each other all over the number line; there's something very sci-fi about it all!

Finally, for the algebra-lovers out there (and in here), 26 is the number of sporadic groups.

So the next time you're dreading the prospect of becoming another year older, see if you can work out something exciting and unique about your new age. It won't make you any younger (who are we kidding - it'll probably do the opposite), but at least all those times you're forced to confront that number, your reaction might be 'ooh' rather than 'argh'.

Happy mathsing!