On last week’s “Welcome to the math olympics”, I closed with a problem from the International Math Olympiad of 1981 (a bad year for wine – I would know, I was an avid drinker back then). I would like to take some time to present a solution to this problem, because this is where all the magic happens. What magic? You will see. Here is the problem again:

Problem 6 (IMO 1981, modified): If $latex f(0,y) = y+1, , f(x+1,0) = f(x,1)$ and $latex f(x+1,y+1) = f(x, f(x+1,y))$, for all non-negative integers $latex x,y$, find $latex f(4,2009)$.

The solution that follows uses solely elementary mathematics. What does that mean? It means that a 15 year-old can figure out the solution, given enough time and an IQ of 300. And, indeed, there are some who can solve this problem in 15 minutes. But, as you will see, it takes clarity of mind that is only attained through relentless effort. Effort to the outside world – to you, it will feel like you are going down the rabbit-hole and you don’t want the journey to end. But you must enter this world with wonder, because it is the world of the imagination – a world where your greatest weapon is your curiosity, prodding your mind to see how far the rabbit-hole goes.

Enter the rabbit-hole: The first thing you observe is that the function $latex f(x,y)$ has two arguments (inputs) and that you are given three equations that work as an algorithm for computing the value of this function on non-negative integers (0,1, 2, …, etc.) So, where do you start? Usually, you start with almost nothing, near the bottom and then work your way up. But why should you start near 0? Because you soon find that if you try to evaluate $latex f(4,2009)$, or even $latex f(4,2)$, you get stuck. And getting stuck is the single greatest motivating force to make you think (wouldn’t that be nice). So we must think. “Can I evaluate $latex f(1,0)$?”, for example. Let me stop to say something that is probably obvious to those with math and science backgrounds: evaluate means calculate an answer that will return a number, like 2, or 5, but not $latex f(2,13)$. The latter is a function with two inputs and unless you are given a prescription for how that function works (i.e. what number comes out for each pair of inputs), then you might as well think of it as a string of symbols and numbers – in other words, useless. OK, back to computing $latex f(1,0)$. You have three equations you can use: $latex f(0,y) = y+1, , f(x+1,0) = f(x,1)$ and the complicated-looking $latex f(x+1,y+1) = f(x,f(x+1,y))$. Which one to use… You try the first one: $latex f(0,y) = y+1$. Can it help you to compute $latex f(1,0)$? Nope. The first input is always 0 in that equation and you are asking for the value of the function when the first input is 1. So, you try the second equation: $latex f(x+1,0) = f(x,1)$. Bingo. Choose $latex x=0$ and substitute on both sides of the equation to get: $latex f(1,0) = f(0,1)$. And you are in business! Why? Because now you can use the first equation to get $latex f(1,0) = f(0,1) = 1+1=2$ (the last equality follows from deep mathematics).

For very large values of 1.

So far, you have seen how to use two of the equations to evaluate $latex f(1,0)$. Can you evaluate $latex f(1,1)$? The first two equations are useless, since either the first or second input is always 0. You must use the third one by setting $latex x=0, y=0$: $latex f(1,1) = f(0,f(1,0)) = f(0,2) = 2+1=3$, where you used $latex f(1,0)=2$ for the second equality and applied the first equation to get the last equality. Sweet stuff. Now you can try to evaluate either $latex f(2,1)$, or $latex f(1,2)$. You try $latex f(2,1)$ using the third equation with $latex x=1,y=0$: $latex f(2,1)=f(1,f(2,0))$. You don’t know what $latex f(2,0)$ is, so you try to figure it out using the second equation with $latex x=1,y=0$: $latex f(2,0) = f(1,1) = 3$ (you evaluated $latex f(1,1)$ a few lines back). Going back to $latex f(2,1) = f(1,f(2,0)) = f(1,3)$, you see that you need to figure out what $latex f(1,3)$ is, which seems more complicated than $latex f(1,2)$ (you chose to evaluate $latex f(2,1)$ instead and look where it got you… oh well). At this point you have two choices: Be stubborn and try to figure out $latex f(1,3)$ (you really want to know what $latex f(2,1)$ is and I can’t blame you), or switch gears and do the wise thing: Evaluate the simpler $latex f(1,2)$. Wisdom be damned. You are forging ahead with $latex f(1,3)$ using the third equation with $latex x=0, y=2$: $latex f(1,3) = f(0,f(1,2))=f(1,2)+1$. Did you see what you just did there? You used the first equation in the last equality with $latex y=f(1,2)$ even though you don’t know what $latex f(1,2)$ is yet (which is totally your fault). Now, a super-genius would notice that there is a pattern here whenever $latex x=1$ as an input: $latex f(1,y+1) = f(0,f(1,y)) = f(1,y)+1$, where you used the third equation and then the first equation. Time to go wild, you think:
$latex f(1,y+1) = f(1,y) +1 = (f(1,y-1)+1)+1 = f(1,y-1)+2 = ldots = f(1,1)+y=3+y.$
For any non-negative integer y! I bet you are wondering how you went from $latex f(1,y+1) = f(1,y-1)+2$ all the way to $latex f(1,y+1) = f(1,1)+y = 3+y$. I will tell you if you give this post 5 stars. Go ahead, it’s free and it will mean so much to my parents (who don’t even know about this blog…) OK, here is the answer: Pattern recognition. Again. Let’s make it explicit: $latex f(1,y+1) = f(1,y)+1=f(1,y-1)+2 = f(1,y-2) + 3 =ldots = f(1,1) + ?$. What should we put instead of the question mark? If you stare enough at the series of equalities, you will notice that the sum of the second argument and the number at the end is always $latex y+1$ (think about why this is the case). So $latex ?=y$ and $latex f(1,y+1)=f(1,1)+y = y+3$.

Yes, I have cleared all levels of Angry Birds with 3 stars! Me and 10 million others.

You didn’t see the pattern right away, but after you evaluated $latex f(1,y)$ for $latex y$ up to 5, you noticed that the answer was always $latex y+2$ and then proved it using the reasoning from the previous paragraph. You have cleared the first level!

Level 2 Mission: Figure out $latex f(2,y)$ for arbitrary non-negative integers $latex y$.

You have built enough intuition by now to see what you need to do next: figure out a general formula for $latex f(2,y)$, just like you did for $latex f(1,y)$. But how? Well, using the third equation again: $latex f(2,y) = f(1,f(2,y-1)) = f(2,y-1)+2$, where you used your knowledge of the general formula for $latex f(1,z)$ and put $latex z=f(2,y-1)$ to get the last equality. And it is time to go wild once more:

$latex f(2,y)=f(2,y-1)+2=f(2,y-2)+2cdot 2=ldots = f(2,0)+2y = 2y+3.$

BAM! Level 2 cleared. Let’s get through Level 3 using your experience points from Level 2: $latex f(3,y) = f(2,f(3,y-1)) = 2f(3,y-1)+3$. This looks a bit more complicated than before… But you are even more curious than you are stubborn and you want to know; you must know. So you go even wilder this time:

$latex f(3,y)=2f(3,y-1)+3 = 2(2f(3,y-2)+3)+3 = 2(2(2f(3,y-3)+3)+3)+3 =ldots = 2^z f(3,y-z) + 3cdot(1+2+2^2+2^3+ldots+2^{z-1}) = 2^y f(3,0)+3(1+2+2^2+ldots+2^{y-1}).$

If you only knew how to evaluate $latex f(3,0)$… You do! Use the second equation given to you: $latex f(3,0)=f(2,1)=2cdot1+3=5$, where you used $latex f(2,y)=2y+3$ from Level 2. Recalling that $latex 1+2+2^2+ldots+2^{y-1} =2^y-1$ (see Deal or no deal?), you get:

$latex f(3,y) = 2^ycdot 5+ 3(2^y-1) = 2^ycdot (5+3) -3 = 2^{y+3}-3.$

And Level 3 is cleared and you are ready for the final boss. But you have the Eye of Thundera (the scary-looking equation $latex f(x+1,y+1)=f(x,f(x+1,y))$ turned out to be your most powerful weapon), so you forge ahead:

$latex f(4,y) = f(3,f(4,y-1)) = 2^{f(4,y-1)+3}-3.$

At this point, you are strong enough to fight the last boss. You must find a formula for $latex f(4,y)$. It looks like $latex 2^{2^{2^{ldots^2}}}-3$, with $latex y+3$ twos in the tower of power. Can you do it? Show me how in the comments. If you need help with writing math in WordPress, search for “latex wordpress” and the internet will teach you how.

In all seriousness (and you will never hear this from me again), you have just completed a journey that few have ever undertaken. As I explained in my previous post, less than 0.001% of the world ever has the privilege of facing a problem like this and coming out on top. Now that you have been inside the belly of the beast, I will let you ponder on this: How far does the rabbit-hole really go?