Computing Fibonacci numbers with generating function

99 Views Asked by At

I am trying to compute specific Fibonacci numbers e.g. $f_n$ using the generating function of Fibonacci numbers. Closed form of generating function for Fibonacci numbers is as follows: $$G(x) = \frac{x}{1-x-x^2} $$ We evaluate this polynomial at the roots of unity $w^0, w^1, w^2, ..., w^{n-1}$ to get the values $v_0, v_1, v_2, ..., v_{n-1}$. We can then do inverse Fourier transformation to find coefficients which represent Fibonacci numbers but I am not doing that because I am interested just in the specific Fibonacci number $f_n$. To calculate this specific Fibonacci number we generate $(n-1)$ row of Fourier matrix and use the following formula to compute n-th Fibonacci number $f_n$: $$f_n = \sum_{i=0}^{n-1}F_{n-1,i} \cdot v_i$$ I have written a program and tried to compute specific Fibonacci numbers using this procedure, but the results were incorrect. Results should be approximations of Fibonacci numbers, but mine were not even approximations as they were not even real numbers since they still had a certain imaginary part. I think I didn't evaluate the polynomial correctly. For roots of unity I used $w^n = e^{\frac{2\pi i}{n}}$, but the first problem is that the procedure lists using root $w^0$ which shouldn't exist. I evaluated polynomial at the specific root of unity e.g. $w^i$ by plugging in that said root in place of $x$ in the function $G(x)$ but I am not sure if this is the right way to evaluate the given polynomial. My question is what is the correct way to evaluate polynomial $G(x)$ at the roots of unity $w^0, w^1, w^2, ..., w^{n-1}$ and what to use for the root $w^0$. If there are any other errors in the described procedure that could lead to incorrect results please point them out.