Fibonacci Numbers
...linear algebra perspectives
\(F_0 = 0, F_1 = 1\)
\(F_{n+2} = F_{n+1} + F_n\) for \(n = 0,1,2,\ldots\)
\(F_0, F_1, F_2, \ldots \)
#1. Fibonacci Numbers, Quickly
The Fibonacci numbers were first described in Indian mathematics, as early as 200 BC in work by Pingala on enumerating possible patterns of Sanskrit poetry formed from syllables of two lengths.
Hemachandra (c. 1150) is credited with knowledge of the sequence as well, writing that "the sum of the last and the one before the last is the number ... of the next mātrā-vṛtta."
\(\underbrace{\left(\begin{array}{cc}\star & \star \\\star & \star\end{array}\right)}_{M}\left(\begin{array}{c}F_{n+1} \\F_n\end{array}\right) = \left(\begin{array}{c}F_{n+2} \\F_{n+1}\end{array}\right)\)
#1. Fibonacci Numbers, Quickly
\(\underbrace{\left(\begin{array}{cc}{\color{IndianRed}\star} & {\color{IndianRed}\star} \\\star & \star\end{array}\right)}_{M}\left(\begin{array}{c}F_{n+1} \\F_n\end{array}\right) = \left(\begin{array}{c}F_{n+2} \\F_{n+1}\end{array}\right)\)
#1. Fibonacci Numbers, Quickly
\(\underbrace{\left(\begin{array}{cc}{\color{IndianRed}1} & {\color{IndianRed}1} \\\star & \star\end{array}\right)}_{M}\left(\begin{array}{c}F_{n+1} \\F_n\end{array}\right) = \left(\begin{array}{c}F_{n+2} \\F_{n+1}\end{array}\right)\)
#1. Fibonacci Numbers, Quickly
\(\underbrace{\left(\begin{array}{cc}{\color{IndianRed}1} & {\color{IndianRed}1} \\{\color{DodgerBlue}\star} & {\color{DodgerBlue}\star}\end{array}\right)}_{M}\left(\begin{array}{c}F_{n+1} \\F_n\end{array}\right) = \left(\begin{array}{c}F_{n+2} \\F_{n+1}\end{array}\right)\)
#1. Fibonacci Numbers, Quickly
\(\underbrace{\left(\begin{array}{cc}{\color{IndianRed}1} & {\color{IndianRed}1} \\{\color{DodgerBlue}1} & {\color{DodgerBlue}0}\end{array}\right)}_{M}\left(\begin{array}{c}F_{n+1} \\F_n\end{array}\right) = \left(\begin{array}{c}F_{n+2} \\F_{n+1}\end{array}\right)\)
#1. Fibonacci Numbers, Quickly
\(\underbrace{\left(\begin{array}{cc}{\color{IndianRed}1} & {\color{IndianRed}1} \\{\color{DodgerBlue}1} & {\color{DodgerBlue}0}\end{array}\right)}_{M}\left(\begin{array}{c}F_{n+1} \\F_n\end{array}\right) = \left(\begin{array}{c}F_{n+2} \\F_{n+1}\end{array}\right)\)
\(M\left(\begin{array}{c}F_{n+1} \\F_n\end{array}\right)=\left(\begin{array}{c}F_{n+2} \\F_{n+1}\end{array}\right)\)
#1. Fibonacci Numbers, Quickly
\(\underbrace{\left(\begin{array}{cc}{\color{IndianRed}1} & {\color{IndianRed}1} \\{\color{DodgerBlue}1} & {\color{DodgerBlue}0}\end{array}\right)}_{M}\left(\begin{array}{c}F_{n+1} \\F_n\end{array}\right) = \left(\begin{array}{c}F_{n+2} \\F_{n+1}\end{array}\right)\)
\(M\left(\begin{array}{c}1 \\0\end{array}\right)=\left(\begin{array}{c}F_{2} \\F_{1}\end{array}\right)\)
\(M\left(\begin{array}{c}F_{n+1} \\F_n\end{array}\right)=\left(\begin{array}{c}F_{n+2} \\F_{n+1}\end{array}\right)\)
#1. Fibonacci Numbers, Quickly
\(\underbrace{\left(\begin{array}{cc}{\color{IndianRed}1} & {\color{IndianRed}1} \\{\color{DodgerBlue}1} & {\color{DodgerBlue}0}\end{array}\right)}_{M}\left(\begin{array}{c}F_{n+1} \\F_n\end{array}\right) = \left(\begin{array}{c}F_{n+2} \\F_{n+1}\end{array}\right)\)
\(M\left(\begin{array}{c}1 \\0\end{array}\right)=\left(\begin{array}{c}F_{2} \\F_{1}\end{array}\right)\)
#1. Fibonacci Numbers, Quickly
\(\underbrace{\left(\begin{array}{cc}{\color{IndianRed}1} & {\color{IndianRed}1} \\{\color{DodgerBlue}1} & {\color{DodgerBlue}0}\end{array}\right)}_{M}\left(\begin{array}{c}F_{n+1} \\F_n\end{array}\right) = \left(\begin{array}{c}F_{n+2} \\F_{n+1}\end{array}\right)\)
\(M\left(\begin{array}{c}1 \\0\end{array}\right)=\left(\begin{array}{c}F_{2} \\F_{1}\end{array}\right)\)
\(M\left(\begin{array}{c}F_2 \\F_1\end{array}\right)=\left(\begin{array}{c}F_{3} \\F_{2}\end{array}\right)\)
#1. Fibonacci Numbers, Quickly
\(\underbrace{\left(\begin{array}{cc}{\color{IndianRed}1} & {\color{IndianRed}1} \\{\color{DodgerBlue}1} & {\color{DodgerBlue}0}\end{array}\right)}_{M}\left(\begin{array}{c}F_{n+1} \\F_n\end{array}\right) = \left(\begin{array}{c}F_{n+2} \\F_{n+1}\end{array}\right)\)
\(M\left(\begin{array}{c}1 \\0\end{array}\right)=\left(\begin{array}{c}F_{2} \\F_{1}\end{array}\right)\)
\(M{\color{Orange}\left(\begin{array}{c}F_2 \\F_1\end{array}\right)}=\left(\begin{array}{c}F_{3} \\F_{2}\end{array}\right)\)
#1. Fibonacci Numbers, Quickly
\(\underbrace{\left(\begin{array}{cc}{\color{IndianRed}1} & {\color{IndianRed}1} \\{\color{DodgerBlue}1} & {\color{DodgerBlue}0}\end{array}\right)}_{M}\left(\begin{array}{c}F_{n+1} \\F_n\end{array}\right) = \left(\begin{array}{c}F_{n+2} \\F_{n+1}\end{array}\right)\)
\(M\left(\begin{array}{c}1 \\0\end{array}\right)=\left(\begin{array}{c}F_{2} \\F_{1}\end{array}\right)\)
\(M \cdot {\color{Orange}M \left(\begin{array}{c}1 \\0\end{array}\right)}=\left(\begin{array}{c}F_{3} \\F_{2}\end{array}\right)\)
#1. Fibonacci Numbers, Quickly
\(\underbrace{\left(\begin{array}{cc}{\color{IndianRed}1} & {\color{IndianRed}1} \\{\color{DodgerBlue}1} & {\color{DodgerBlue}0}\end{array}\right)}_{M}\left(\begin{array}{c}F_{n+1} \\F_n\end{array}\right) = \left(\begin{array}{c}F_{n+2} \\F_{n+1}\end{array}\right)\)
\(M\left(\begin{array}{c}1 \\0\end{array}\right)=\left(\begin{array}{c}F_{2} \\F_{1}\end{array}\right)\)
\(M^2\left(\begin{array}{c}1 \\0\end{array}\right)=\left(\begin{array}{c}F_{3} \\F_{2}\end{array}\right)\)
#1. Fibonacci Numbers, Quickly
\(\underbrace{\left(\begin{array}{cc}{\color{IndianRed}1} & {\color{IndianRed}1} \\{\color{DodgerBlue}1} & {\color{DodgerBlue}0}\end{array}\right)}_{M}\left(\begin{array}{c}F_{n+1} \\F_n\end{array}\right) = \left(\begin{array}{c}F_{n+2} \\F_{n+1}\end{array}\right)\)
\(M\left(\begin{array}{c}1 \\0\end{array}\right)=\left(\begin{array}{c}F_{2} \\F_{1}\end{array}\right)\)
\(M^n\left(\begin{array}{c}1 \\0\end{array}\right)=\left(\begin{array}{c}F_{n+1} \\F_{n}\end{array}\right)\)
#1. Fibonacci Numbers, Quickly
\(M^n\left(\begin{array}{c}1 \\0\end{array}\right)=\left(\begin{array}{c}F_{n+1} \\F_{n}\end{array}\right)\)
#1. Fibonacci Numbers, Quickly
\(\underbrace{M \longrightarrow M^{2} \longrightarrow M^{4} \longrightarrow M^{8} \longrightarrow M^{16} \longrightarrow M^{32} \longrightarrow \cdots}_{}\)
repeated squaring
\(\mathcal{O}(\log_2 n)\) multiplications of \(2 \times 2\) matrices.
#1. Fibonacci Numbers, Quickly
\(\underbrace{M \longrightarrow M^{2} \longrightarrow M^{4} \longrightarrow M^{8} \longrightarrow M^{16} \longrightarrow M^{32} \longrightarrow \cdots}_{}\)
repeated squaring
\(\mathcal{O}(\log_2 n)\) multiplications of \(2 \times 2\) matrices.
\(M^n = M^{(2^{k_1} + 2^{k_2} + \cdots + 2^{k_\ell})} = M^{2^{k_1}} M^{2^{k_2}} \cdots M^{2^{k_\ell}} \)
\(\mathcal{O}(\log_2 n)\) multiplications of \(2 \times 2\) matrices.
#1. Fibonacci Numbers, Quickly
If we want to compute the Fibonacci numbers by this method, we have to be careful, since the \(F_n\) grow very fast.
#1. Fibonacci Numbers, Quickly
As we will see later, the number of decimal digits of \(F_n\) is of order \(n\).
Thus we must use multiple precision arithmetic, and so the arithmetic operations will be relatively slow.
#1. Fibonacci Numbers, Quickly
#2. Fibonacci Numbers, The Formula
Consider the vector space of all infinite sequences:
\((u_0, u_1, u_2, \ldots )\)
...with coordinate-wise addition and multiplication by real numbers.
In this space we define a subspace \(\mathcal{W}\) of all sequences satisfying the equation:
\(u_{n+2} = u_{n+1}+u_n\) for all \(n = 0, 1, ...\)
Easy to verify: \(\mathcal{W}\) is a subspace.
Claim: \(dim(\mathcal{W}) = 2\).
Observe that \((0,1,1,2,3,\ldots)\) and \((1,0,1,1,2,\ldots)\) is a basis.
Goal. Find a closed-form formula for \(F_n\).
\(= (0,1,1,2,3,5,8,13,21,\ldots)\)
\(= (\ldots,\alpha^n,\ldots)\)
\(= (\ldots,\beta^n,\ldots)\)
=
+
\(\mathcal{W}\)
#2. Fibonacci Numbers, The Formula
\((\tau^0,\tau^1,\tau^2,\tau^3,\cdots) \in \mathcal{W} \)
\(\tau^k = \tau^{k-1}+\tau^{k-2}\)
\(\tau^2 = \tau+1\)
\(\tau_{1,2}=(1 \pm \sqrt{5}) / 2\)
\(\alpha=(1 + \sqrt{5}) / 2\)
\(\beta=(1 - \sqrt{5}) / 2\)
#2. Fibonacci Numbers, The Formula
=
+
\(F = c \cdot (\alpha^0,\alpha^1,\alpha^2,\alpha^3,\cdots) + d \cdot (\beta^0,\beta^1,\beta^2,\beta^3,\cdots)\)
\(0 = c + d\)
\(1 = c\alpha + d\beta\)
\(d = 1/(\beta -\alpha)\)
\(c = 1/(\alpha -\beta)\)
#2. Fibonacci Numbers, The Formula
#2. Fibonacci Numbers, The Formula
\(F_n = c \cdot \alpha^n + d \cdot \beta^n\)
\(d = 1/(\beta -\alpha)\)
\(c = 1/(\alpha -\beta)\)
\(\alpha=(1 + \sqrt{5}) / 2\)
\(\beta=(1 - \sqrt{5}) / 2\)
\(F_n = \frac{1}{\sqrt{5}} \cdot \left[ \left( \frac{1+\sqrt{5}}{2} \right)^n - \left( \frac{1-\sqrt{5}}{2} \right)^n \right] \)
#2. Fibonacci Numbers, The Formula
\(F_n = \left\lfloor \frac{1}{\sqrt{5}} \cdot \left( \frac{1+\sqrt{5}}{2} \right)^n \right\rfloor \)
Exercise 1. Show that:
Exercise 2. Use this method to work out a closed form for:
\(y_{n+2}=2 y_{n+1}-y_n\)
(Source: generatingfunctionology, Wilf;
h/t Matthew Drescher and John Azariah for a fun Twitter discussion on this.)
Fibonacci Computation and Recurrence
By Neeldhara Misra
Fibonacci Computation and Recurrence
- 187