Finding Inverse of Binet Formula – Method

fibonacci-numbersgolden ratio

I'm already aware of the Binet formula $\displaystyle F_n = \frac{\varphi^n + \frac{1}{\varphi^n}}{\sqrt{5}}$. I'm attempting to find the inverse of that formula so I can find the position in the sequence of Fibonacci numbers. In fact, at first glance it's relatively easy:

$$
F_n\sqrt{5} = \varphi^n + \frac{1}{\varphi^n}\\
\varphi^nF_n\sqrt{5} = \varphi^{2n} + 1\\
\varphi^{2n} – \varphi^nF_n\sqrt{5}+ 1 = 0\\
\varphi^n = \frac{F_n\sqrt{5}+ \sqrt{5F_n^2 – 4}}{2}\\
n = \log_\varphi\left(\frac{F_n\sqrt{5}+ \sqrt{5F_n^2 – 4}}{2}\right)
$$

But this isn't quite correct. The problem is that we must subtract or add 4 depending on whether the Fibonacci number has odd or even position in the sequence (or rather, whether $5F_n^2 – 4$ is a perfect square; admittedly, we could just go by this indicator, but I want to avoid that if at all possible). So the formula is actually:

$$
n = \log_\varphi\left(\frac{F_n\sqrt{5}+ \sqrt{5F_n^2 + 4(-1)^n}}{2}\right)
$$

But that doesn't work for me, because n appears in multiple places in the formula, and you'd need to know if it's odd or even to be able to derive it. So if you do the work, you'll see that I'm trying to isolate n in the expression:

$$
\varphi^{2n} – \varphi^nF_n\sqrt{5} = (-1)^n
$$

Or alternatively, find an operation that when applied to the numbers 3, 8, 21, 55, 144, etc. gives an even number, and when applied to the numbers 2, 5, 13, 34, 89 gives an odd number.

As a side note, I find it highly unnerving that the almighty quadratic formula fails in this particular case.

Update: I am only interested in solving either of the two problems posed above, not in other ways to find Fibonacci numbers' positions in the sequence.

Best Answer

The second term vanishes quite quickly. We have $F_n=\lfloor \frac{\phi^n}{\sqrt{5}}+\frac{1}{2}\rfloor$, where $\lfloor \cdot \rfloor$ denotes the floor function. If the floor weren't there, you could solve for $n$, and if you rounded you would be wrong only for possibly very small $n$.

Update: A quick calculation shows that $n=\left[ \log_\phi \sqrt{5}(F_n-\frac{1}{2}) \right]$ holds for all $n\ge 3$, and fails for $n=1,2$. In this case $[\cdot]$ denotes the rounding function, or $[x]=\lfloor x+\frac{1}{2}\rfloor$.

Related Question