Given a Fibonacci number, find what number in the sequence it is

146 Views Asked by At

I came across the formula for the $n$th Fibonacci number:

$$\frac{\Phi^n-(-\Phi)^n}{\sqrt5} = x,$$

where $x$ is the $n$th Fibonacci number.

This formula works one way around, but I cannot seem to get it to flip around. How would I go about isolating $n$?

1

There are 1 best solutions below

0
On BEST ANSWER

A "practical" solution could be the following:

For large enough $n$, you can write the $n^{th}$ Fibonacci number as $$y_n = \frac{1}{\sqrt{5}} \left( \frac{1+\sqrt{5}}{2} \right)^{n+1}$$ where index $n$ starts from 0.

Now you can solve for $n$ from $y_n = x$ as:

$$ n = \frac{\log(x \sqrt{5})}{\log( (1+\sqrt{5})/2)} - 1 = \frac{\log(x) + 0.8047}{0.4812}-1 = 2.0781\log(x)+0.6723$$.

The $\log$ is the natural logarithm. You can round the above expression to the nearest integer.

For example, with $x=233$, I get $n=12.0001$, which I can round off to 12. Indeed, with the 0 based indexing, $y_{n+1} = y_{13} = 233$.