Sunday 23 March 2014

A Bug Strife

Young Cleo has lost her ant. The ant, whose name is Tony, didn’t have any particular complaints about life under Cleo’s care; he just decided he wanted to explore the sights and scents of the world for himself, rather than reading about them on Crickipedia*. He had written Cleo a fond pheromonal farewell on the side of his tank, so he assumed she was ok with this.

The escape was a particularly manic and haphazard affair. Cleo had been taking Tony for his daily walk down the long, straight path outside their house. She had let Tony off his leash because he was so good at walking to heel. Suddenly a huge gust of wind came blasting down the length of the path and Tony, seeing his chance for High Adventure, chose not to cling to the pavement and went careening into the distance. Bizarrely, the wind abruptly changed and came rushing back in the exact opposite direction. Cleo has no idea where on the path Tony landed, ahead of her or behind.

Cleo is naturally concerned, especially since the local insect-delicatessen (‘Insectivoracious’) is just down the road. She’s determined to find Tony, but he’s pretty small. Due to her young age, Cleo has never ventured all that far from her house, and she has no idea how far the road spans in either direction since every house is labelled with an un-orderable symbol rather than a number (a particularly valiant attempt at egalitarianism on the part of the local council) - Cleo lives at ‘Purple Blob’**. As an aspiring cosmologist, she conjectures that the road has infinite length and that Tony might be anywhere along it, moving in one direction or the other at a fixed speed (which could include zero – just staying put).

Cleo can’t see Tony without getting to the ground and examining closely, so she has to check for him one spot at a time. Conveniently, the pavement is split into fairly long, thin slabs, spanning its entire width, and she thinks she can check one of them thoroughly in about a minute. Tony is very safety-conscious and will almost certainly stick to the path. Moreover, Cleo has noticed that left to his own devices, Tony moves an exact number of slabs per minute, but she can’t for the life of her remember how many. She considers her own speed not to be an issue, since she can get her mum, who will no doubt be horrified at Tony’s impromptu departure, to drive her up and down the road at a speed that makes Tony’s negligible.

Cleo starts off where she is, first checking the slab she's standing on, then moving one step forward and checking that slab.


After a few minutes, she realises this might never work. What if Tony is behind her and moving away? Then she’s fruitlessly checking a set of slabs that he’ll never appear in. She tries a different approach, jumping back to the first unchecked slab behind her, then forward to the first unchecked slab in front of her, then back again, and so on.


This still won’t work, she realises. If he’s moving away from her (and there’s a roughly 50% chance he is) in either direction, he’ll be moving away faster than she can check, since on average she checks only half a slab in each direction every minute. But if she skips some, she could end up missing him! This is going to take some thought.

Can Cleo develop a search strategy that will certainly result in her finding Tony eventually after a finite time, so long as she never gives up until she’s successful?

Answer here! Skip the next block if you don’t want a…

HINT:
If we did know Tony’s initial position and velocity, how could we express his position after time t (measured in minutes)? This is where Cleo has to check at that time, except that she doesn’t know the initial conditions. How can she cycle through the possibilities in a way that eventually checks each one?

I first encountered this problem in a mathematically identical, but narratively distinct, form: a train starts at an unknown integer along a track described by a number line of infinite length in both positive and negative directions. There are sensors at the integer values along this line that can tell you whether or not the train is there, but only at the time you check them. The velocity of the train is known only to be an integer, positive or negative, and at every time-step you can check exactly one sensor. Arguably some extra suspension of disbelief is required for my version, since Cleo’s equivalent to ‘checking the sensor’ is actually driving to the spot that needs examining: Cleo moves at unlimited speed! On the other hand, our assumptions of an ‘infinite road’ and ‘unlimited speed’ aren’t really any crazier than an infinitely long train track with an infinite number of sensors along it, and the signal from each sensor must take some time to reach us, too. Perhaps the biggest assumption here is that Tony, being a male ant, is still alive after any appreciable length of time! It sucks to be a boy in the insect world.



*The insectese translation of Wikipedia is in the cricket dialect, a decision made by its grasshopper founders and the source of no small amount of contention in the insect world.

** You might complain that hues and shapes do still admit an ordering, and you'd be right! If this troubles you, feel free to substitute your favourite unorderable set.

Tuesday 11 March 2014

Much Ado About Muffin - THE RESULTS

My previous post told the exciting tale of how Ruby, an intrepid bakerista, saved the day (having first sabotaged it, but shh!) at Tetris HQ. While her coworker Howard may have been content simply to ferry cakes back and forth between taskmasters all day, I'm sure you were wondering (or maybe you've already deduced) what the results of her glutenous ingenuity were. To explain, here's the same illustration as previously, with the squares labelled. Since it takes eight pieces to make two tetrominoes, every puzzle involved removing a single square in such a way that the remaining eight made up the shapes required.


We may as well nerd-it-up a notch and use the proper Tetris terminology, which of course I researched using Wikipedia. Have a click if you're curious - the main point is that the pieces are denoted by the letters that roughly approximate their shape: I, L, T, S, Z, J, O. J is 'backwards L' and O is the square-shaped one. Swotted up? Good! Here we go.

Answer 1
Which square should be removed to leave a shape containing a Z and a T together? Luckily for methodical types, the answer was A. Here's how it works, and do excuse Howard's paint-job, won't you. He hasn't had to do this since 1998!

  

Answer 2
Unfortunately the dream world was much kinder to our heroes than the real thing, and Ruby found herself having to take her best stab with the information 'two of the same - possibly Ls, Js or Ts'. There was no question of which slice to remove: as Ruby noted, there is only one configuration that allows any pairs of twin pieces. If we trust her on that, it means that if we find just one pair of twins in a configuration, then it must be the one that contains all the others, too. She also said it contained only twins, so if we're checking a configuration and find a pair of different pieces, we know instantly that we're in the wrong one. These pieces of information actually made this an easier question than the first, and the answer was... B! Maybe Howard's painting will be better in the real world?


Oh dear, I guess not.

Answer 3
This is where we part company with Ruby, since the tastiest-looking piece is obviously D. However, the piece she had to remove in order to leave the highest number of combinations is I. Perhaps she was trying to make herself feel better about giving most of the cake away, but I think it's more likely that as she began discovering her inner mathematician, her idea of what is tasteful became more questionable*. There are four possible combinations: LS, LO, JZ and JO:


I'm not sure even the Mario mushrooms can explain these ones, Howard!

Unlike question 2, question 3 was much harder than the first, since it required you to find all pairs of shapes that can be made from all combinations. How to do this? I think the most efficient way is to pick a square in the configuration that looks like it can't be used to form many different shapes, form what you can using that square, then see what you have left. As an example, try 'eating' G and examine the square labelled I. With G gone, I can only be part of the L shape made with squares IHED. The only configuration possible if you eat G is the pair LJ.

Even if there are several ways to use your chosen square (e.g. eating I as above), it's not hard to make this procedure fairly methodical and be sure you haven't missed any. Notice once you've exhausted all ways of using that single square, you're done, since every configuration must use that square somehow in a way you've already tried.

Answer 4ish
What about Ruby's other comments? The worst square to eat is H, since it leaves I hanging off the end and unusable. The next-worst are C and D. If you eat C, you can make just the pair JZ, but we already saw that that's contained in the 'eat I' set. Similarly eating D leaves the pair JT, which you'll find is included in the two pairs possible when you eat A.

You might also wonder whether other pairs are unique to a particular configuration, like ZT was if you ate A. The answer is 'yes', and in some cases it's the only pair that can be made, so allowing only a small number of pairs doesn't necessarily make the configuration useless. This property of some configurations to be 'contained' in others on the basis of which pairs they allow, while others neither contain nor are contained, hints at the mathematical notion of a 'partial ordering', where you say a set X is 'larger' than Y for some choices of X and Y, but not all choices admit a comparison. (Compare the 'total ordering' on the number line, where you can always say which of two different numbers is larger.)

Epilogue
What about the fate of Ruby and Howard? Since Tetris HQ is currently enveloped by a thick smog of flour, sugar and edible glitter, it's hard to say, but we can certainly work out the probability that they gave Paul what he requested. With seven shapes - I, L, T, S, Z, J, O - available, there are 28 different ways to make a pair from two of them**, and Ruby only gave Howard four, leaving just a 1/7 (about 14%) chance of success. If she had given him all nine pieces and trusted him not to eat the extra one, they would have had access to eight more possible combinations, increasing their chances to 12/28 = 3/7 (about 43%). Not hopeful, but better. Expensive cake, Ruby!***

So I'm afraid it looks like Paul was probably not very happy with Ruby once again, and this should be a lesson to all of us: while an apple a day keeps the doctor away, a cake protégée won't get Tetris to play.



* If you doubt this phenomenon, pay a visit to Warwick Maths Department, where a decent number of professors have decided that shoes and socks are not necessary equipment for lecturing. And actually they have a point, I guess?

** There are 7*7 = 49 ways to pick two pieces in a set order, but some of these are double-counted since the order doesn't matter. There are 7 pairs of twins, and of the remaining 42, 21 are unique. So 7 + 21 = 28 combinations. This happens to be the 7th triangle number 28 = 7*8/2. To see why, draw a table with the first piece along the top and the second piece down the side and ignore the entries that get counted twice:

    ILTSZJO
I *  * *****
L
 *  * ****
T

 * ****
S


 * ***
Z



 * **
J




 * *
O





 * 

*** With a few reasonable (?) assumptions, economists could use this information to estimate how much Ruby values cake relative to her job (or hers and Howard's together!). Ruby has sacrificed a 8/28 = 2/7 increased chance of success... for a piece of cake. If the probability of her getting fired for this blunder is p, the value of cake is c and the value of her job is j, then Ruby has implicitly declared:

c > 2/7*p*j

(the value of the cake is greater than the value of her job times the increased probability of losing it), or rearranging:

j < (7/2)/p*c.

We don't really know p, but we can see what happens at various points, for instance if p = 1% then Ruby considers her job worth at most 350 pieces of cake. If p = 100% then she would happily trade her job for the certainty of four slices of cake. If that's the case, she should have just kept the whole thing and not worried!

Saturday 8 March 2014

Much Ado About Muffin - or - A Tale of Two Tetrominoes

Ruby awoke with a pounding in her head and chocolate on her breath. What had she been doing last night? As she peeled her forehead from the hard wooden surface it had been resting on, it dawned on her that she wasn’t at home at all, but seated awkwardly at her desk in the Tetris Block Management offices.

Ah yes. The office party.

She conducted a quick forensic analysis. Strewn across the floor were the scattered fragments of broken tetrominoes, empty power-up bars and experimental cheat codes. The theme music was spinning relentlessly between her ears with laboured speed and questionable tuning, and for some reason the air was thick with cake crumbs, floating like pollen grains in the morning sun. Ruby racked her brains to remember. That was it: a friend of hers had been promoted on the day of the party, and to celebrate Ruby had gone on a bit of a baking spree. Well, a baking frenzy. Cake after cake flying out of the office kitchen, all sliced into small squares to fuel the geometric obsession for which Tetris employees are renowned. She noticed she had narrowly avoided sleeping face-down in the half-finished remains of one of her creations. Smiling, she reached for one of the pieces. The chocolate coating had gone rock-solid overnight, fusing the cake into one delicious lumpy mess, but she managed to snap a piece away and chewed recuperatively as the clock struck 9am.

Suddenly her coworker, Howard, burst through the door. He seemed agitated, and not purely by the overpowering fumes of chocolate that to Ruby had become a second oxygen. Relieved to see someone in the office, he rushed over to her desk and stammered:

“There’s an emergency in the warehouse! Someone forgot to bulk-order the tetrominoes” (here Ruby almost choked on her cake) “and there’s nothing left to send the clients! Paul is clamouring for supplies – says someone was up playing all night and reached level 143. What are we going to give him?”

The guilt in Ruby’s head quickly gave way to panic. Paul was already less than pleased with her after Frances had beaten her to the highest turnover last month, and the only thing quicker than his temper was his tetromino drop rate.

“Oh god, what are we supposed to do?” she cried.

She reached down for another consolatory chunk of cake, but stopped herself with a gasp.

“Wait! Howard – what does Paul say he needs?”

“He said he needed that one that’s kind of Z-shaped to send down, and a T-thingy to stick in the ‘coming next’ box.” Howard’s grasp of Tetris terminology was never particularly good, owing to a previous career in the Ministry of Mario Mushrooms. “But why…”

“Shh!” interrupted Ruby, “I’m thinking. Do we still have the paints from that Gameboy Color merger back in the 90s?”

“I think so – why?”

“Because – look! We can pass off pieces of cake as tetrominoes so long as we paint them the right colour, and there’s nine little squares here – more than enough for two tetrominoes! The only question is which one we can do without…” Now that the crisis was partially resolved, Ruby’s mind was eager to return to her improvised breakfast.


“We need to be careful,” she realised. “Only one of the nine configurations produced by removing a chunk will leave us able to cut out a Z and a T, and there’s no hope of sticking any blocks back together once they’re cut.”

Which square can Ruby safely remove?

As Howard scampered away through the cocoa mist, Ruby breathed a sigh of relief and returned to her solitary square of cake. She hoped the client appreciated the sacrifice she had just made. As she went in for another bite, she heard a voice in her ear:

“Ruby! Ruby, wake up! RUBY!”

“Whuhhh…” groaned Ruby. “Where am I?”

It was Howard, shaking her awake with a vigour that, in her opinion, ought to be reserved for baking and baking alone.

“In the office – it’s morning! Paul is livid – he says someone forgot to bulk-order the tetrominoes and there’s nothing left to send the clients! What are we going to do?”

Ruby sat up and noticed that her dream office had almost perfectly represented her present surroundings, except that – disappointingly – the first piece she’d removed from the cake was already gone. Perhaps she had eaten it in her sleep (it wouldn't be the first time). Grumpy, disorientated and feeling like the victim of a lazy plot device, Ruby snapped:

“Well all right, what does he want?”

“Umm… I think he said something about those backwards Ls, or was it the backwards-backwards Ls? Wait – maybe it was tutus, I mean two Ts… or something. All I remember is he wanted two of the same thing!”

Ruby grimaced. Dream-Howard had been far more competent than the real thing, and that was saying something. She dragged her eyes towards the cake, which was exactly as before, except that she was a piece hungrier this time.

“Ok, well it looks like we can manage this so long as he wanted two identical pieces, and the shape was one of those three... are you at least certain about that?”

Howard looked terrified.

“Look – we’re just going to have to hope for the best. There's only one configuration that allows two duplicates to be cut from it anyway. Come to think of it, it allows nothing but pairs of duplicates! I’ll cut out this piece, you take the rest, confirm what he wants then slice it appropriately and slap on the paint, ok?”

Which square does Ruby have to remove this time?

Ruby sat back to begin her breakfast for a second time, but the cake had barely reached her mouth before Howard had returned, wheezing more than ever in the saccharine atmosphere.

“It wasn’t enough – the guy’s still going strong!” he moaned. “This time Paul needs… uh, well he needs… oh no…”

Miraculously, Ruby had opened her desk drawer to find a perfect replica of the previous cake sitting inside. She was only mildly surprised quantum entanglement was an occasional by-product of serious baking. It was no use scraping Howard’s mushroom-addled brain for more information, and there was no way she was letting a piece of cake go to waste by sending all nine down with Howard. No job was worth that. So she examined the cake closely.

“Ok, well there’s no way to give him any straight lines – the sides aren’t long enough for that – but a line never turns up when you need it anyway. If I remove this chunk you can only get one tetromino out of the resulting shape – that’s no good. There’s no point taking this one out because you’d get the same options and more if you took out this one instead I guess you could say one set of options is contained in the other. That's true for this other pair of configurations too. Still, six to choose from – I’ll just have to give you the shape that leaves the highest number of combinations. That chunk looks tastiest anyway. Now take it away and write down what he wants next time. You’re a tetromino delivery man, not a waiter at Burger Kong.”

Which was the tastiest-looking square? Which three options did Ruby dismiss? Which combinations of two tetrominoes is it possible to produce?

Ruby stumbled into the kitchen and turned on the oven. As she did so, she felt renewed life rushing through her fingertips and into every fibre of her body. She took a deep, sugary breath and grinned. Today, Tetris needed a baker... and a baker it had.

[Early post this week – I hope you enjoy reading it half as much as I enjoyed writing it! Answers are now available in the follow-up post. Many thanks to Imogen, whose half-eaten cake as pictured above was the inspiration for this post! It was as delicious as the story recollects.]

Monday 3 March 2014

Mirrors, memories and memoirs - nostalgic numbers rack their brains

Last week I introduced nostalgic numbers as two-digit numbers with the property that, when written in a certain base, each one can (loosely speaking!) look at itself in the mirror and see half of its own value reflected back at it: swapping the digits has the same effect as dividing by 2. I gave some expressions for constructing all possible nostalgic pairs, and it turned out that they are fairly prescriptive: although you can choose any number n to be the first digit of the pair's lowest member, it's then determined that the other digit will be 2n+1, the base will be 3n+2 and the value of the resulting number will be (n+1)(3n+1). Towards the end we asked the question: 'what about numbers that are effectively multiplied/divided by some other number besides 2 when you swap their digits?'

I think we're going to need some more terminology here. We already defined a 'nostalgic pair', and if we want to be clear we can say 'of base k' as well. How about saying that if the lower number doubles when you read it backwards, then it's a 'nostalgic pair of memory 2', and similarly if switching the digits causes it to become a times itself, then it has memory a. We've dealt fully with the memory 2 case - now we can start to examine numbers with better memories! What about a = 3? If I hadn't given the game away last week, you might be asking whether memory 3 pairs exist at all, and the quickest way to prove they do is just to find one:

157 = 1*7 + 5 = 1210 and
517 = 5*7 + 1 = 3610.

Done! Expressed in base 10, {12,36} is the lowest nostalgic pair of memory 3. There's nothing special about the way I found any of these initial pairs, memory 2 or 3. For memory 2, I simply took the formula we deduced last week for the digits (x,y),

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

and dived in to see what happened. You'll see exactly what I mean if you give it a try - some cases work and others don't. You spot a pattern in the ones that work and do a little more investigating to prove that intuition correct. We can't always be so lucky as to have the pattern roll out like that, but it's great when it does.

If you're not the sort to find yourself scribbling maths on any bit of paper you can grasp, hours after you were supposed to be sleeping, I may not be able to convince you of how much fun this process of exploring and discovering mathematical ideas is to us lost-cause types: the best way to experience it is to have a go yourself. If you're enjoying this story of nostalgic pairs (and I hope you are at least a little!) then I urge you to have a go at playing with these ideas on your own before reading on, since it's that process of 'maybe this will work... well ok, not quite, but what if I... ooh!' that really gives this rec-math stuff its flavour. If you do plan to experiment, avert your eyes now, because here's the corresponding table for pairs of memory 3:

kxyBase 10 representation
71512
112830
1531156
1941490
............
4n+3n3n+2(4n+2)(n+1) [any base]

Great - a whole new list of numbers, and another rule for constructing them. So we have {12,36}, {30,90}, {56,168}, {90,270} for our first few memory 3 pairs. Can you conjecture what the memory 4 pairs will look like? Hurry up - here they come!

kxyBase 10 representation
91716
1421139
1931572
24419115
............
5n+4n4n+3(5n+3)(n+1) [any base]

So we get memory 4 pairs {16,64}, {39,156}, {72, 288}, {115,460} - easy. It goes on, and the general formula for pairs of memory a is:

kxyValue
(a+1)n+anan+(a-1)((a+1)n+(a-1))(n+1)

I think that's pretty nice. So we're done, right? Well... not quite. Last week I explained why it wasn't possible to take one of the memory 2 pairs we'd found and divide or multiply both numbers by a constant to create a new pair. The issue was that the digits in memory 2 pairs have the form (x,y) = (n,2n+1), so if any number b>1 divides n exactly then it divides 2n+1 with remainder one, and that means (2n+1)/b isn't a whole number. But if we consider memory 3 pairs, their digits are (x,y) = (n,3n+2). There's a 2 on the end for that second digit now, so if n is divisible by 2, so is 3n+2. We can take any memory 3 pair whose n was even and divide the digits (in the specified base) by 2 to get a new pair. {30,90} with digits (2,8) (base 11) gives us {15,45} with digits (1,4). {90,270} with digits (4,14) (base 19) gives us {45,135} with digits (2,7).

We could do the same for pairs of memory 4, with digits (n,4n+3). Now whenever 3 divides n, we can not only divide all digits by 3 to get a new pair, but we can also multiply that result by 2 to get yet another one - the resulting digits won't be too big since we already divided by 3. So our pair {72,288} with base 19 digits (3,15) also gives us {24,96} with digits (1,5) and {48,192} with digits (2,10).

Since for any pair of memory a>2 the digits are (n,an+(a-1)), they all will admit some extra pairs for values of n that share common divisors with a-1. As it's only the case for certain generating values of n, and hence the bases (a+1)n+a, these bases and the pairs within them are something special - we'll call them 'memoir bases' and the pairs within them 'memoir sets'... because numbers in these bases have so many memories, they can write a book about them! Which are the most memoir-rich bases? They're the ones where the value of n used is equal to, or a multiple of, a-1, so they will only get larger and larger as the memory label increases. As for how many relatively memoir-rich bases we expect to see, that depends on how many factors a-1 has. Look at a detailed table for a = 7, for example:

kxyBase 10 representation
1511328
2322066

11033
31327120

21880

1940
39434190

21795
47541276
55648378

540315

432252

324189

216126

1863
63755576
............
8n+7n [highest for this base]7n+6 [highest for this base](8n+6)(n+1) [for highest (x,y)]

That's a big memoir set for base 55, generated by n = 6, but because a-1 = 6 has two factors, not just one, there are also smaller sets for the bases 23, 31 and 39 generated by n = 2, 3, 4 (and more, if we carried on past n = 7). Maybe it's interesting to consider which bases have the most memoirs if you add them all up over many different memories. For example, base 55 gets 6 memoirs for memory 7, but also 2 for memory 3 (since for memory 3, base 55 is generated by n = 18, which is divisible by 2). We'll see! We've started to re-frame part of the study of nostalgic pairs in terms of factors. I wonder whether primes/biprimes will turn up? (ha)

I have to say I'm immensely enjoying experimenting with this growing concept of nostalgic pairs. There's much more I want to say, and I will in the future, although to prevent this becoming the Nostalgic Pairs blog I may break it up a bit! Food for thought, though: is every number a member of some nostalgic pair? Or a slightly different question: is every number a base for a nostalgic pair of a certain memory? How well can we predict and summarise properties such as memoir size?

By the way, if you weren't sure whether or not to believe me about grabbing any piece of paper for maths extemporising, here's the result [click to enlarge] of my finding only blank white envelopes around the home to use as scrap:


I figure the more I find myself doing this kind of thing, the less people will want to write to me anyway!

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!