### Diary for 01:090:101:21, Experimental Math, fall 2008

#### The fourth meeting, 9/22/2008

Maybe a couple of presentations
I hope that representatives of a few more of the solution teams will discuss their solutions of questions. I thank Mr. Hard for his solution of Question #3 near the end of the last meeting.
Indeed, I thank Ms. Bae (Question #7) and Mr. Firminich (Question #5) for their expositions of solutions.

Another random(?) sequence
This is really a rehearsal for rabbit counting, but let me look at a (really!) rather random sequence before getting on with something very famous. So what if I start a sequence with, say, 1, and then go on by multiplying the number by 5 and subtracting 3. I have no reason to expect that this will produce anything interesting, but I just want to practice.

```
> frog:=proc(n) if n=1 then 1 else 5*frog(n-1)-3 end if end proc;
frog := proc(n) if n = 1 then 1 else 5*frog(n - 1) - 3 end if end proc

> seq(frog(n),n=1..10);
1, 2, 7, 32, 157, 782, 3907, 19532, 97657, 488282
```
So the frog function above uses the recursive idea to define the sequence. The next command actually computes the first 10 values. Maybe we could check that 7 times 5 is 35 and then minus 3 gives 32: as in the term after 7. By the way, this sequence is in Sloane's Encyclopedia. It is sequence number A047850 but let me pretend that it is not. Oh well.
```
> v:=n->A*5^n+B;
n
v := n -> A 5  + B
```
I am going to guess that a formula for the terms is a constant multiplying powers of 5 plus another constant -- well, something like that worked for the sequence we considered last time, so let's try it here.
```
> coefficients:=solve({v(1)=frog(1),v(2)=frog(2)});
coefficients := {A = 1/20, B = 3/4}
```
There are two constants, and I use the two first terms in the sequence to get values for the constants.
```
> v1:=n->subs(coefficients,v(n));
v1 := n -> subs(coefficients, v(n))
> v1(n);
n
5
---- + 3/4
20
```
Now I substitute the values I got and get a specific formula, which is displayed above.
```
> v1(n)-(5*v1(n-1)-3);
n     (n - 1)
5     5
---- - --------
20       4
> simplify(%);
0
```
I know that the formula works for n=1 and n=2, because that's where I got the values for A and B. But the instructions above tell me that the formula obeys the recursion relation. Why would one want such formulas? Well, one reason is that they usually compute terms in the sequence much faster than the recurrence way. For example, on my home computer, I found the terms corresponding to 1, 10, 100, 1,000, 10,000, and 100,000 both ways. Actually, I tried to. The formula worked fine, and took less than .01 seconds. The recurrence method got an error message: Error, (in frog) too many levels of recursion after .2 seconds (20 times as much computing time). So there was not enough memory space available! Ah well.

Introduction to the Fibonacci numbers
More than 800 years ago, an Italian "mathematician" whose nickname was Fibonacci was born and died in Pisa and published numerous influential books on computation. He introduced so-called Arabic numbers (digits 0 through 9, decimal numbers) and the computational methods associated with them (following Arabic and Indian traditions). A Wikipedia article states that the methods were used in "commercial bookkeeping, conversion of weights and measures, the calculation of interest, money-changing, and other applications". This wasn't theoretical math, but exciting rather applied cutting-edge commercial ideas at that time.

The same book which introduced these new computational ideas also showed a sequence of integers to the European audience. The sequence came to be called the Fibonacci numbers.
Here's a translation of the book's introduction to the sequence.
It turns out that the sequence was studied almost a thousand years earlier in connection with chanting patterns in Sanskrit poetry. Here's a reference.

The Fibonacci numbers arise in numerous real-world situations. Their patterns have been observed repeatedly in biology. I'll distribute a black and white copy of this poster. Many people have studied (perhaps more accurately, obsessively studied) the Fibonacci numbers. There is a Fibonacci Association which publishes the Fibonacci Quarterly and there's a huge marble statue of Fibonacci in a main square of Pisa (yes, the town with the Leaning Tower). This is neat if you visit and are a math geek.

A Maple approach to the sequence
It turns out that the entries in the sequence can be computed by an expression called Binet's Formula, which with standard historical inaccuracy was known way before Binet was associated with it. Let's get this formula using Maple.

```
> fibon:=proc(n) if n=1 then 1 else if n=2 then 1 else fibon(n-1)+fibon(n-2) end if end if end proc;
fibon :=

proc(n) if n = 1 then 1 else if n = 2 then 1 else fibon(n - 1) + fibon(n - 2) end if end if end proc
```
This command defines a procedure (a short Maple program) to compute the Fibonacci numbers.
```
> seq(fibon(n),n=1..10);
1, 1, 2, 3, 5, 8, 13, 21, 34, 55
```
These are the first 10 terms of the sequence. You can check that each term is the sum of the two immediately preceding it.
```
> growth:=solve(L^(n+2)=L^(n+1)+L^(n),L);
1/2         1/2
5           5
growth := 1/2 + ----, 1/2 - ----, 0
2           2
```
Here I'm trying to get the correct growth constants for this sequence. I am guessing (more pedantically, "conjecturing") that the sequence will behave like powers of a number. This is similar to what we saw in some earlier examples, but the power is not so obvious. Maple takes the equation Ln+2=Ln+1+Ln and tries to solve it for L. It divides by the common factor Ln and gets a quadratic equation, L2=L+1, or L2-L-1=0 and gets the roots using the quadratic formula. The 0 at the end of the list is also a root of the equation, but I will not use it -- it doesn't give me any information.
```
> Lp:=growth;Lm:=growth;
1/2
5
Lp := 1/2 + ----
2

1/2
5
Lm := 1/2 - ----
2
```
So I will call Lp (p for plus) and Lm (m for minus) the two roots.
```
> v:=n->A*Lp^n+B*Lm^n;
n       n
v := n -> A Lp  + B Lm
```
Here is my guess for the formula giving the Fibonacci numbers. I need to find out what A and B are, and then I need to check if the formula really will obey the Fibonacci equation.
```
> seq(fibon(n)=v(n),n=1..2);
/       1/2\     /       1/2\        /       1/2\2     /       1/2\2
|      5   |     |      5   |        |      5   |      |      5   |
1 = A |1/2 + ----| + B |1/2 - ----|, 1 = A |1/2 + ----|  + B |1/2 - ----|
\       2  /     \       2  /        \       2  /      \       2  /

> coefficients:=solve({%});
1/2       1/2
5         5
coefficients := {B = - ----, A = ----}
5         5
```
I have two constants, so I hope that the two equations will be enough. And solve does indeed get me values for the coefficients.
```
> v1:=n->subs(coefficients,v(n));
v1 := n -> subs(coefficients, v(n))

> v1(n);
/       1/2\n        /       1/2\n
1/2 |      5   |     1/2 |      5   |
5    |1/2 + ----|    5    |1/2 - ----|
\       2  /         \       2  /
------------------ - ------------------
5                    5
```
I substituted in with the coefficients and got a really weird looking formula. Notice that there are two n's up in the exponents, but there are square roots of 5's all over the place!
```
> v1(n+2)-v1(n+1)-v1(n);
/       1/2\(n + 2)        /       1/2\(n + 2)        /       1/2\(n + 1)        /       1/2\(n + 1) 1/2 |      5   |           1/2 |      5   |           1/2 |      5   |           1/2 |      5   |
5    |1/2 + ----|          5    |1/2 - ----|          5    |1/2 + ----|          5    |1/2 - ----|
\       2  /               \       2  /               \       2  /               \       2  /
------------------------ - ------------------------ - ------------------------ + ------------------------           5                          5                          5                          5

/       1/2\n        /       1/2\n
1/2 |      5   |     1/2 |      5   |
5    |1/2 + ----|    5    |1/2 - ----|
\       2  /         \       2  /
- ------------------ + ------------------
5                    5

> simplify(%);
/       1/2\n   /       1/2\n        /       1/2\n   /       1/2\n        /       1/2\(n + 1)
1/2 |      5   |    |      5   |     1/2 |      5   |    |      5   |     1/2 |      5   |
5    |1/2 + ----|    |1/2 + ----|    5    |1/2 - ----|    |1/2 - ----|    5    |1/2 + ----|
\       2  /    \       2  /         \       2  /    \       2  /         \       2  /
------------------ + ------------- - ------------------ + ------------- - ------------------------
10                 2                 10                 2                    5

/       1/2\(n + 1)
1/2 |      5   |
5    |1/2 - ----|
\       2  /
+ ------------------------
5

> expand(%);
0
```
The simplify command doesn't help much, but expand gets me 0, so I know that this ridiculous formula does indeed produce the Fibonacci numbers, forever! Here are a few more "uses":
```
> v1(4);
/       1/2\4        /       1/2\4
1/2 |      5   |     1/2 |      5   |
5    |1/2 + ----|    5    |1/2 - ----|
\       2  /         \       2  /
------------------ - ------------------
5                    5
> expand(%);
3

> v1(100);
/       1/2\100        /       1/2\100
1/2 |      5   |       1/2 |      5   |
5    |1/2 + ----|      5    |1/2 - ----|
\       2  /           \       2  /
-------------------- - --------------------
5                      5

> expand(%);
354224848179261915075
```
You can check, if you want to, that what's above is the 100th Fibonacci number (just go through the recursive definition for a little while ...).

A little while ...
Today is the day after our fourth meeting. So at home, on my little PC, I timed the computation of the 100th Fibonacci number using Binet's formula. The time needed on a not very fast computer was about .08 seconds. Then I tried the recursive definition. Let's see: computing the 30th Fibonacci number took about 3.3 seconds of computational time and more than 10 times the storage space than the formula evaluation. Here is what I learned by small-scale experimentation:

Approximate computational time
(in seconds) for fibon(n)
n 30313233
Time 3.35.99.815.4

And, considering how the time required is growing, I don't think there is enough time before the computer rusts to find fibon(100).
With more honesty, I will tell you that there are ways to speed up the recursive evaluation, but it will never be even close to the formula. This may be one reason people like formulas.

And other things ...
If you get completely obsessed with the Fibonacci numbers, you can start seeing amazing patterns in them. Here is one such pattern. Look at the beginning of the sequence:
1, 1, 2, 3, 5, 8, 13, 21, 34, 55
Take an entry, say 13, and look at the numbers on either side, 8 and 21. Well, 8·21=168 and 132=169, so these are off by 1. Let's try another, say 34 with border numbers 21 and 55. Not so easily now (I am checking with Maple in another window!) I see that 342=1,156 and 21·55=1,155. Again, off by 1. What's going on? This is called the Cassini identity (discovered by a relative of the person who found gaps in the rings of Saturn hundreds of years ago). Here is it, along with a PROOF:

```
> v1(n+1)*v1(n-1)-v1(n)^2;
/     /       1/2\(n + 1)        /       1/2\(n + 1)\
| 1/2 |      5   |           1/2 |      5   |       |
|5    |1/2 + ----|          5    |1/2 - ----|       |
|     \       2  /               \       2  /       |
|------------------------ - ------------------------|
\           5                          5            /

/     /       1/2\(n - 1)        /       1/2\(n - 1)\   /     /       1/2\n        /       1/2\n\2
| 1/2 |      5   |           1/2 |      5   |       |   | 1/2 |      5   |     1/2 |      5   | |
|5    |1/2 + ----|          5    |1/2 - ----|       |   |5    |1/2 + ----|    5    |1/2 - ----| |
|     \       2  /               \       2  /       |   |     \       2  /         \       2  / |
|------------------------ - ------------------------| - |------------------ - ------------------|
\           5                          5            /   \        5                    5         /

> expand(%);
//       1/2\n\2   /       1/2\n /       1/2\n        //       1/2\n\2
||      5   | |    |      5   |  |      5   |     1/2 ||      5   | |
||1/2 + ----| |    |1/2 + ----|  |1/2 - ----|    5    ||1/2 + ----| |
\\       2  / /    \       2  /  \       2  /         \\       2  / /
---------------- - --------------------------- + ---------------------
/       1/2\             /       1/2\               /       1/2\
|      5   |             |      5   |               |      5   |
10 |1/2 + ----|          10 |1/2 - ----|            10 |1/2 + ----|
\       2  /             \       2  /               \       2  /

/       1/2\n      /       1/2\n   /       1/2\n /       1/2\n   //       1/2\n\2
|      5   |   1/2 |      5   |    |      5   |  |      5   |    ||      5   | |
|1/2 + ----|  5    |1/2 - ----|    |1/2 - ----|  |1/2 + ----|    ||1/2 - ----| |
\       2  /       \       2  /    \       2  /  \       2  /    \\       2  / /
- -------------------------------- - --------------------------- + ----------------
/       1/2\                     /       1/2\            /       1/2\
|      5   |                     |      5   |            |      5   |
10 |1/2 - ----|                  10 |1/2 + ----|         10 |1/2 - ----|
\       2  /                     \       2  /            \       2  /

/       1/2\n      /       1/2\n        //       1/2\n\2   //       1/2\n\2
|      5   |   1/2 |      5   |     1/2 ||      5   | |    ||      5   | |
|1/2 - ----|  5    |1/2 + ----|    5    ||1/2 - ----| |    ||1/2 + ----| |
\       2  /       \       2  /         \\       2  / /    \\       2  / /
+ -------------------------------- - --------------------- - ----------------
/       1/2\                  /       1/2\             5
|      5   |                  |      5   |
10 |1/2 + ----|               10 |1/2 - ----|
\       2  /                  \       2  /

/       1/2\n /       1/2\n   //       1/2\n\2
|      5   |  |      5   |    ||      5   | |
2 |1/2 + ----|  |1/2 - ----|    ||1/2 - ----| |
\       2  /  \       2  /    \\       2  / /
+ ----------------------------- - ----------------
5                        5

> simplify(%);
n
(-1)
```
So the square of a Fibonacci number is alternately one more and then one less than the product of the Fibonacci numbers which border it!

Next time I will provide you with some recurrences, and I hope that you will be able to get formulas for them.