# Fibonacci-Based Arithmetic

[This is the final Wythoff’s game post. See the previous ones here: #1, #2, #3, #4, #5, #6. We’ll have a few shorter, 1- or 2-post topics starting next week.]

In our standard, base-10 number system, each position represents a specific power of 10: the number 275 in base 10 means that I have five 1s, seven 10s, and two 100s. Similarly, in the base-2 system, each position represents a different power of 2: 10011 in base 2 says I have a 1, a 2, and a 16, but no 4s or 8s.[1] Instead of using powers of 10 or 2, what happens if we use Fibonacci numbers?

We can find the Fibonacci numbers by starting[2] at $$a_1=1$$ and $$a_2=2$$ and then computing each term as the sum of the two previous ones, $$a_n=a_{n-1}+a_{n-2}$$:

1, 2, 3, 5, 8, 13, 21, 34, 55, …

Let’s use these as our position values in our so-called Fibonacci base, using just the digits 0 and 1. For example, 1010011F stands for $$a_7+a_5+a_2+a_1 = 21+8+2+1 = 32$$.

Notice that $$a_2+a_1=a_3$$, so we can write 32 instead as $$a_7+a_5+a_3$$, meaning 32=1010100F. In much the same way, any time we have a Fibonacci representation of a number, we can repeatedly use the identity $$a_n=a_{n-1}+a_{n-2}$$ to ensure that we never use consecutive Fibonacci numbers:

Theorem (Zeckendorf): Every positive integer can be expressed in base Fibonacci with no adjacent 1s. Furthermore, this representation is unique.

The “base-Fibonacci representation” of a number usually refers to its Zeckendorf representation as in this theorem. There’s a simple greedy method to find a number’s Zeckendorf representation: use the largest Fibonacci number less than (or equal to) your number, and repeat on the remainder. For example, to represent 46 in this way, check that the largest Fibonacci number below 46 is $$a_8=34$$, leaving 12 as the remainder. The largest Fibonacci number below (or equal to) 12 is $$a_5=8$$, with a remainder of 4. Now we have to use $$a_3=3$$, and finally we’re left with $$1=a_1$$. So $$46=a_8+a_5+a_3+a_1=10010101_F$$ is the Zeckendorf representation of 46.

But why discuss base Fibonacci now? What does this have to do with Wythoff’s game? Zeckendorf representations provide another simple way to characterize the losing positions in Wythoff’s game! Here’s a beautiful result:

Theorem: If $$a \le b$$ are positive integers, then $$(a,b)$$ and $$(b,a)$$ are losing position in Wythoff’s game precisely when:

• The Zeckendorf representation of a ends in an even number of 0s, and
• The Zeckendorf representation of b is the same as that of a except for one more 0 on the end.

For example, 11=10100F ends in two 0s (two is even), and 18=101000F has the same representation except for an extra 0 at the end, so (11,18) and (18,11) are Wythoff losing positions. Unlike the formula using multiples of $$\phi$$ and $$\phi^2$$ that we proved in the last few posts, this provides a method we could actually compute (without a calculator) on reasonably-sized grids when playing with friends (or enemies)! After all we’ve learned about Wythoff’s game, we finally have a way to win it!

Our Wythoff’s game saga is now ending here on Three-Cornered Things, but here are a few recommended resources if you wish to further explore this rich topic on your own:

### Notes

1. If these concepts are unfamiliar, see this previous post on number bases. []
2. Careful: these indices are shifted from the other common convention that starts the Fibonacci numbers at $$F_1=1$$ and $$F_2=1$$, which is why I’m using as instead of Fs. []

# The “Fibonacci”est String

The celebrated Fibonacci Sequence is defined by setting each term equal to the sum of the two previous terms, starting at $$F_0=0$$ and $$F_1=1$$. So it continues like this:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, …

What’s the relation to last week‘s infinite jump sequence,

a b a b b a b a b b a b b a b a b b a b a b b a b b a b a b b a b b … ?

Let’s find out!

Recall from last week that we can group our sequence into blocks of $$A=(ab)$$ and $$B=(abb)$$, and that the pattern of “short” and “long” blocks is the same as the pattern of as and bs in the original sequence:

This means we can do this grouping again! Specifically, we can group our sequence into “blocks of blocks”, or level 2 blocks, that look like $$A_2=[(ab)(abb)]$$ and $$B_2=[(ab)(abb)(abb)]$$:

Furthermore, the pattern of short and long level 2 blocks is still the same as the original jump sequence! So we can keep going, grouping our sequence into level 3 blocks $$A_3=A_2 B_2$$ and $$B_3=A_2 B_2 B_2$$, level 4 blocks $$A_4=A_3 B_3$$ and $$B_4=A_3 B_3 B_3$$, and so on, thus finding longer and longer patterns that fill up our sequence. Here’s level 3:

One natural question is: what are the lengths of these blocks? Let’s make a table:

n An Bn An Length Bn Length
0 a b 1 1
1 ab abb 2 3
2 ababb ababbabb 5 8
3 ababbababbabb ababbababbabbababbabb 13 21

The lengths are exactly the Fibonacci numbers! (Prove this!) Furthermore, how many as and bs does each block have? Here’s another table:

n An # of as # of bs Bn # of as # of bs
0 a 1 0 b 0 1
1 ab 1 1 abb 1 2
2 ababb 2 3 ababbabb 3 5
3 ababbababbabb 5 8 ababbababbabbababbabb 8 13

Again the Fibonacci numbers! This gives us another way to compute the ratio of as to bs in the jump sequence: The ratios of bs to as in blocks An and Bn are $$F_{2n}/F_{2n-1}$$ and $$F_{2n+1}/F_{2n}$$ respectively, so as n gets larger these ratios should both approach last week’s answer, the golden ratio $$\phi$$.

OK, so our jump sequence is very “Fibonacci”y: it has blocks of Fibonacci lengths with Fibonacci proportions of as and bs. How can it get any “Fibonacci”er than that? Here’s how: Define a different infinite string using the same definition as the Fibonacci numbers themselves: write $$W_0=0$$, $$W_1=1$$, and after that, each string is formed by writing the previous two next to each other: $$W_n=W_{n-1}W_{n-2}$$. The Ws continue like this:

0, 1, 10, 101, 10110, 10110101, 1011010110110, 101101011011010110101, …,

and in the limit they define some infinite string of 0s and 1s that, without a doubt, is as “Fibonacci”y as it gets. But wait; except for the first digit, this is exactly the same as our jump sequence with 0=a and 1=b!
- 1 0 1 1 0 1 0 1 1 0 1 1 0 1 0 1 1 0 1 0 1 1 0 1 1 0 1 0 1 1 0 1 1 ... a b a b b a b a b b a b b a b a b b a b a b b a b b a b a b b a b b ... This truly is the Fibonacci numbers reincarnated in a binary string.

# A Golden Observation

Last week we saw that the best strategy for Wythoff’s game is to always move to one of the blue squares in the diagram below (if you can). We found the locations of the blue squares with an iterative algorithm that builds outward from (0,0), but we haven’t yet discovered the underlying pattern in how these blue cells are arranged. Let’s go pattern hunting!

As we noticed last week, the blue cells are arranged in a symmetric “V” shape, formed from two seemingly straight lines. What are the slopes of these lines? This is the question du jour.

Looking more carefully, the upper branch of the “V” has only two types of “gaps”: consecutive blue cells are separated by either a “short” (1,2) step (a.k.a. a knight’s move) or a “long” (2,3) step. So, if we believe that this “V” branch is a perfect line, then that line’s slope should be somewhere between the slopes of these two steps, namely $$3/2=1.5$$ and $$2/1=2$$. Knowing more about how these steps are arranged will tell us more about the “V”.

Specifically, label these “short” and “long” steps as a and b respectively. What we care about is the ratio of bs to as. Why? For example, if there were an equal number of as and bs on average, then the slope of the line would be the same as the vector $$a+b=(3,5)$$, i.e., the slope would be 5/3. If there were, say, two bs for each a in the long run, then the line would fall in the direction of $$a+2b=(5,8)$$, with slope 8/5. Unfortunately, the ratio we seek is neither 1 nor 2; what is this magic number?

Let’s write down the sequence of jumps along our line. From the diagram above we see that it starts a b a b b a …, and using last week’s iterative algorithm, we can compute farther into this infinite sequence:

a b a b b a b a b b a b b a b a b b a b a b b a b b a b a b b a b b …

This sequence seems to be composed of “blocks” of (a b) and (a b b):

(a b)(a b b)(a b)(a b b)(a b b)(a b)(a b b)(a b)(a b b)(a b b)(a b)(a b b)(a b b)…

So for every a there are either one or two bs, meaning the ratio of bs to as is somewhere between 1 and 2. So the slope should be between 5/3 and 8/5. But what is it exactly? To answer this, we need to know how these “short” and “long” blocks are arranged.

Write A = (a b) and B = (a b b), so we can rewrite the sequence of blocks as

A B A B B A B A B B A B B …

Hold on; this sequence looks familiar. It’s exactly the same pattern as our original jump sequence! So it seems that the pattern of blocks is exactly the same as the pattern of the letters themselves! This is a “self-generating” sequence!

In particular, if the ratio of bs to as is some number r, then the ratio of (a b b) blocks to (a b) blocks is also r. But if we have one block of (a b) and r blocks of (a b b) then we have a total of $$1+2r$$ bs and $$1+r$$ as, so the ratio of bs to as is $$\frac{1+2r}{1+r}=r$$. This simplifies to $$1+r=r^2$$, and the solution is the shiny number $$r=\frac{1+\sqrt{5}}{2}$$, known as the golden ratio and denoted $$\phi$$ (Greek letter phi).

Now we know that our purported line should be in the direction of $$a+b\cdot\phi = (1+2\phi,2+3\phi)$$, so the slope is $$(2+3\phi)/(1+2\phi)=\phi$$. And since our “V” shape is symmetric, the other line should have slope $$1/\phi = \frac{\sqrt{5}-1}{2}$$. Done and done!

Well, yes and no. We found the slopes of the lines in the “V”, but why do they form lines at all? And what does all this have to do with the Fibonacci numbers?

There’s something unsatisfyingly arbitrary about the number 10. When we write numbers, e.g. 1729, our notation means that we have 1 thousand ($$10^3$$), 7 hundreds ($$10^2$$), 2 tens ($$10^1$$), and 9 ones ($$10^0$$), so the number 10 is ingrained in our very writing system. And it’s not just the Arabic numeral system: Roman numerals also organize themselves around powers of 10 (such as I=1, X=10, C=100, etc.). But why 10? (Other than the fact that we usually have 10 fingers and 10 toes [why not 20 instead?].)
Our “decimal” system centers around powers of 10, but there are other equally useful systems based on other numbers. For example, we could use sums of powers of 2, and instead of needing 10 digits (0,1,…,9) we can use just 2, namely 0 and 1. For example, the number 1101 in base 2 means $$1 \cdot 2^3 + 1 \cdot 2^2 + 0 \cdot 2^1 + 1 \cdot 2^0$$, also known as 13 in base 10. This may seem inefficient, since we need more digits (or, more correctly, “bits” in the binary setting) to express the same value, but it has many benefits. Each bit has only 2 choices, and can therefore be represented by a pair of opposites such as “on/off” (e.g. in circuits) or the two magnetic polarities. The latter is how hard drive disks store information (in binary!), which is one reason this system is beloved by computer scientists. It also allows for jokes like this: “There are 10 types of people in the world: those that understand binary, and those that don’t.”
Another common base is Hexadecimal, using powers of 16 with digits 0,…,9,A,B,C,D,E,F. (A hexadecimal digit is sometimes called a “nibble”.) It is common to prefix a hexadecimal number with “0x”, so 0x3B7 means $$3 \cdot 16^2 + 11 \cdot 16 + 7 = 951$$ in decimal. It also makes the phrase “I see 0xDEAD people” perfectly reasonable (how many is that?).
The possibilities are endless! We can use base $$n$$ for any positive integer $$n>1$$ in similar ways, but we can also use negative $$n$$ as well! (My favorite is base -4.) If you want to go ever further, think about what base $$(1+\sqrt{5})/2$$ (a.k.a. phinary) would look like! Or the related bases Fibonacci and NegaFibonacci!