Waste less time on Facebook — follow Brilliant.
×

Fast Fibonacci Transform Results

This note has been used to help create the Fast Fibonacci Transform wiki

In How Many Transformations, Daniel came to the realization that linear recurrence of the form

\[\left\{\begin{array}{l}x_{n+1}=a_1x_n+b_1y_n,\\ y_{n+1}=a_2x_n+b_2y_n,\end{array}\right.\]

could easily be solved by setting up the matrix interpretation, and then diagonalize the matrix (assuming that's possible) which would allow us quick exponentiation, and hence obtain the Nth term directly.

We've seen this in the context of the Fast Fibonacci Transform. Specifically, set \( x_n = f_{n+1} \) and \( y_n = f_n\), and you get the system of equations

\[ \begin{cases} x_{n+1} = 1x_n + 1y_n \\ y_{n+1} = 1x_n + 0 y_n \\ \end{cases}\]

Hence, \[ \begin{pmatrix} x_n \\ y_n \\ \end{pmatrix} = \begin{pmatrix} 1 & 1 \\ 1 & 0 \\ \end{pmatrix}^n \begin{pmatrix} 1 \\ 1 \\ \end{pmatrix} \]

Using this, show the following:
1. Performing the eigenvalue decomposition, prove Binet's formula.
2. Using only matrix properties, conclude that
\[ f_{2n+1} = f_{n+1} ^2 + f_n ^2. \]
Hint: \( A^{2n} = A^n \times A^n \).
3. Find a similar formula for \( f_{2n} \).
4. Express \( f_{3n} \) in terms of \( f_{n}, f_{n+1}\).

Note by Calvin Lin
2 years, 10 months ago

No vote yet
1 vote

Comments

Sort by:

Top Newest

This kinda gave away the method one uses to solve my problem (if you don't use eigenvalue decomposition). However, I would still like to see how eigenvalue decomposition works, so it would be nice if a brilliant user could post a solution to the problems suggested in this note. Thanks. Daniel Liu · 2 years, 10 months ago

Log in to reply

@Daniel Liu Added a solution. It's pretty basic matrix manipulation, and would have been the approach that I thought you used. Calvin Lin Staff · 2 years, 10 months ago

Log in to reply

For Fast Fibonacci Transform, here's a python code for calculating fibonacci numbers:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# (Public) Returns F(n).
def fibonacci(n):
    if n < 0:
        raise ValueError("Negative arguments not implemented")
    return _fib(n)[0]


# (Private) Returns the tuple (F(n), F(n+1)).
def _fib(n):
    if n == 0:
        return (0, 1)
    else:
        a, b = _fib(n // 2)
        c = a * (b * 2 - a)
        d = a * a + b * b
        if n % 2 == 0:
            return (c, d)
        else:
            return (d, c + d)
Pranjal Jain · 1 year, 11 months ago

Log in to reply

I wish I saw this earlier Agnishom Chattopadhyay · 1 year, 11 months ago

Log in to reply

Log in to reply

@Calvin Lin Okay! Will go through this Agnishom Chattopadhyay · 1 year, 11 months ago

Log in to reply

Let \( \rho =\frac{1+\sqrt{5}}2 \) and \( {\overline \rho} = \frac{1-\sqrt{5}}2 \). Let \( D = \begin{pmatrix} \rho&0 \\ 0&{\overline \rho} \end{pmatrix} \). Let \( A = \begin{pmatrix} \rho&{\overline \rho} \\ 1&1 \end{pmatrix} \). Then \( \begin{pmatrix} 1&1\\1&0 \end{pmatrix} = ADA^{-1} \). Patrick Corn · 2 years, 10 months ago

Log in to reply

@Patrick Corn (1) So \( \begin{pmatrix} f_{n+1} \\ f_n \end{pmatrix} = (ADA^{-1})^n \begin{pmatrix} 1\\0 \end{pmatrix} = AD^nA^{-1} \begin{pmatrix} 1\\0 \end{pmatrix} \). Some painful computations yield \( \begin{pmatrix} f_{n+1}\\f_n \end{pmatrix} = \frac1{\sqrt{5}} \begin{pmatrix} \rho^{n+1}-{\overline \rho}^{n+1} \\ \rho^n - {\overline \rho}^n \end{pmatrix} \); Binet's formula falls out of this. Patrick Corn · 2 years, 10 months ago

Log in to reply

@Patrick Corn (2) and (3): let \( M = \begin{pmatrix} 1 & 1 \\ 1 & 0 \end{pmatrix} = ADA^{-1} \). Then \( M^n \begin{pmatrix} 1 \\ 0 \end{pmatrix} = \begin{pmatrix} f_{n+1} \\ f_n \end{pmatrix} \), and \( M^n \begin{pmatrix} 0 \\ 1 \end{pmatrix} = M^{n-1} \begin{pmatrix} 1 \\ 0 \end{pmatrix} = \begin{pmatrix} f_n \\ f_{n-1} \end{pmatrix} \). So \( M^n = \begin{pmatrix} f_{n+1} & f_n \\ f_n & f_{n-1} \end{pmatrix} \).

Now then, \( \begin{pmatrix} f_{2n+1} \\ f_{2n} \end{pmatrix} = M^{2n} \begin{pmatrix} 1 \\ 0 \end{pmatrix} = M^n \begin{pmatrix} f_{n+1} \\ f_n \end{pmatrix} = \begin{pmatrix} f_{n+1} & f_n \\ f_n & f_{n-1} \end{pmatrix} \begin{pmatrix} f_{n+1} \\ f_n \end{pmatrix} \).

So we get \( \begin{pmatrix} f_{2n+1} \\ f_{2n} \end{pmatrix} = \begin{pmatrix} f_{n+1}^2 + f_n^2 \\ f_{n+1}f_n + f_n f_{n-1} \end{pmatrix} \), and the formulas we want can be read off from there. Patrick Corn · 2 years, 10 months ago

Log in to reply

@Patrick Corn (4) Similar computations give \( f_{3n} = f_n(3f_{n+1}^2-3f_nf_{n+1}+2f_n^2) \). (Basically the same process as the previous, but I had to substitute \( f_{n-1} = f_{n+1}-f_n \) in some places.) Patrick Corn · 2 years, 10 months ago

Log in to reply

×

Problem Loading...

Note Loading...

Set Loading...