Golden and Alternating, fast simple O(lg n) algorithms for Fibonacci
Two very fast and simple O(lg n) algorithms for individual Fibonacci numbers are given and compared to competing algorithms. A simple O(lg n) recursion is derived that can also be applied to Lucas. A formula is given to estimate the largest n, where F_n does not overflow the implementation’s data type. The danger of timing runs on input that is too large for the computer representation leads to false research results.
💡 Research Summary
The paper presents two novel algorithms for computing individual Fibonacci numbers in O(log n) time, emphasizing simplicity, speed, and robustness against overflow. After a concise review of traditional methods—naïve recursion, dynamic programming, and matrix exponentiation—the author points out that while matrix exponentiation theoretically achieves logarithmic complexity, its practical performance suffers from heavy constant factors, floating‑point approximations, and memory overhead. To address these issues, the paper introduces the “Golden” algorithm and the “Alternating” algorithm.
The Golden algorithm derives directly from Binet’s closed‑form expression Fₙ = (φⁿ − ψⁿ)/√5, where φ = (1+√5)/2 and ψ = (1−√5)/2. By representing φ and ψ through the 2×2 matrix A =
Comments & Academic Discussion
Loading comments...
Leave a Comment