Fibonacci Word
Coding in processing
You are probably familiar with the Fibonacci sequence where each subsequent number is a sum of previous two numbers.
A simple mathematical representation of Fibonacci sequence would be written as: F(n)=F(n-1)+F(n-2) for n>1.
This would result in a sequence:
0,1,1,2,3,5,8,13,21,34,55,89,…
Fibonacci sequence is also closely related to the Golden Ratio. Here is a simple representation of squares whose sides are Fibonacci numbers:
Fibonacci Word
Fibonacci Word is a special sequence of binary digits, but also has some great fractal qualities. When I learned about it, I was really interested to visualize it myself and experience the magic of this sequence.
Fibonacci word is formed by repeating and concatenating the binary digits in the same way as in Fibonacci sequence. You can take any two digits or characters to create this sequence. For the sake of this article, we will go with “0” and “1”. As you can see below, we will start the sequence with the first two digits and then move on to form the third, fourth, etc.
The logic for the sequence is:
Let S(0) be “0” and S(1) be “01”. Now S(n)=S(n-1)S(n-2)
Applying this logic, we get:
1st = 0
2nd = 01
3rd = 010 (concatenating 2nd and 1st)
4th = 01001 (concatenating 3rd and 2nd)
5th = 01001010 (concatenating 4th and 3rd)
6th = 0100101001001
7th = 010010100100101001010
and so on…
As you can see, very quickly this sequence grows exponentially.
A very interesting thing happens if we add some rules to this sequence.
- Go through each digit in the nth iteration of the sequence.
- If the current digit is “0” — Turn left if “n” is even / Turn right if “n” is odd.
Taking the 6th iteration from above, lets look at this logic visually: