Fibonacci numbers
This problem develops properties of the Fibonacci numbers, which are defined by the recurrence (3.22). We shall use the technique of generating functions to solve the Fibonacci recurrence. Define the generating function (or formal power series) F as
F(z)=∞∑i=0Fizi=0+z+z2+2z3+3z4+5z5+8z6+13z7+21z8+⋯,where Fi is the ith Fibonacci number.
a. Show that F(z)=z+zF(z)+z2F(z).
Note that fi=Fi−1+Fi−2∀i≥2, F0=0 and F1=1.
z+zF(z)+z2F(z)=z+z∞∑i=0Fizi+z2∞∑i=0Fizi=z+∞∑i=1Fi−1zi+∞∑i=0Fi−2zi=z+F1z+∞∑i=2(Fi−1+Fi−2)zi=z+F1z+∞∑i=2(Fi)zi=∞∑i=0Fizi=F(z)F(z)=F(z)(1−z−z21−z−z2)=F(z)−zF(z)−z2F(z)1−z−z2b. Show that
F(z)=z1−z−z2=z(1−ϕz)(1−ˆϕz)=1√5(11−ϕz−11−ˆϕz),where
ϕ=1+√52=1.61803…and
ˆϕ=1−√52=0.61803…
Let’s borrow from question a. in order to simplify this expression.
=F(z)−(z+zF(z)+z2F(z))+z1−z−z2=F(z)−F(z)+z1−z−z2=z1−z−z2So far so good. The following identities are helpful in continuing with this problem. ϕ+ˆϕ=1+√5+1−√52=1, ϕˆϕ=1−√5+√5−52=−1 and ϕ−ˆϕ=1+√5−1+√52=√5.
=z1−(ϕ+ˆϕ)z+ϕˆϕz2=z(1−ϕz)(1−ˆϕz)=√5z√5(1−ϕz)(1−ˆϕz)=(ϕ−ˆϕ)z+1−1√5(1−ϕz)(1−ˆϕz)=(1−ˆϕz)−(1−ϕz)√5(1−ϕz)(1−ˆϕz)=1√5(1−ˆϕz(1−ϕz)(1−ˆϕz)−1−ϕz(1−ϕz)(1−ˆϕz))=1√5(11−ϕz−11−ˆϕz)c. Show that
F(z)=∞∑i=01√5(ϕi−^ϕi)zi
For |x|>1 we have 11−x=∞∑k=0xk.
F(z)=1√5(11−ϕz−11−ˆϕz)=1√5(∞∑i=0(ϕz)i−∞∑i=0(ˆϕz)i)=1√5(∞∑i=0ϕizi−∞∑i=0^ϕizi)=∞∑i=01√5(ϕizi−^ϕizi)=∞∑i=01√5(ϕi−^ϕi)zid. Use part c to prove that Fi=ϕi√5 for i>0, rounded to the nearest integer. (Hint: Observe that |ˆϕ| < 1.)
By this problem’s definition and part c, Fi=1√5(ϕi−^ϕi)=ϕi√5−ˆϕi√5. For all values of i, the subtracted term ˆϕi√5 is less than 0.5 which is therefore effectively rounding the value determined by ϕi√5. Thus this problem’s popular claim (see SICP 1.13) is simply a restatement of the conclusions of part c.