I am trying to solve a bigger problem, and I think that an important part of the program is spent on inefficient computations.
I need to compute for a given number N, th
Using the last form here for the inverse you can find the two indexes for the Fib numbers around the current number. http://en.wikipedia.org/wiki/Fibonacci_number#Computation_by_rounding
log(N * sqrt(5)) / log((1+sqrt(5))/2)
should give you a number which is between the two integer indexes for P
and Q
. You can then used the closed-form (as shown in the other answers) to give the actual numbers P
and Q
.
Note that you may be off by one depending on your initial Fib conditions.