Middle and Ripple, fast simple O(lg n) algorithms for Lucas Numbers

Middle and Ripple, fast simple O(lg n) algorithms for Lucas Numbers
Notice: This research summary and analysis were automatically generated using AI technology. For absolute accuracy, please refer to the [Original Paper Viewer] below or the Original ArXiv Source.

A fast simple O(\log n) iteration algorithm for individual Lucas numbers is given. This is faster than using Fibonacci based methods because of the structure of Lucas numbers. Using a sqrt 5 conversion factor on Lucus numbers gives a faster Fibonacci algorithm. In addition, a fast simple recursive algorithm for individual Lucas numbers is given that is O(log n).


💡 Research Summary

The paper introduces two novel O(log n) algorithms for computing individual Lucas numbers, named “Middle” (iterative) and “Ripple” (recursive). Lucas numbers Lₙ satisfy the same recurrence as Fibonacci numbers but with different initial conditions (L₀ = 2, L₁ = 1, L₂ = 3). Traditional approaches either compute Lₙ by invoking Fibonacci algorithms twice (using Lₙ = Fₙ₋₁ + Fₙ₊₁) or rely on O(n) iterative addition, both of which are suboptimal for isolated queries.

The core insight of the authors is to apply the well‑known doubling identities directly to the Lucas sequence. The fundamental identity they derive is
 L₂k = L₂k − (−1)ᵏ·2,
which can be rewritten as
 L₂k+2 = L₂k+1 + (−1)ᵏ·2.
Using this, they construct a compact set of update formulas that require only two squarings, two sign adjustments, and three additions per binary digit of the exponent.

Middle (Iterative) Algorithm

  1. Convert n to binary and store the bits in an array “markOdd”.
  2. Initialise three variables: LL = L₂k, LM = L₂k+1, LH = L₂k+2.
  3. For each bit from most‑significant to least‑significant, set p = ±1 depending on the bit, then execute:
     LL ← LL·LL − p·2
     LH ← LM·LM + p·2
     LM ← LH − LL
    If the current bit is 1, a further swap (LL ← LM, p ← −1) is performed before the next iteration. After processing all bits, LL holds Lₙ. The loop runs ⌊log₂ n⌋ + 1 times, giving O(log n) time with a very small constant factor (two multiplications per iteration, both squarings, which are cheaper than general multiplications).

Ripple (Recursive) Algorithm
The recursive version mirrors the same doubling principle:

  • If n is even, p = 1 and Lₙ = L_{n/2}² − p·2.
  • If n is odd, p = −1 and Lₙ = L_{⌈n/2⌉}² − L_{⌊n/2⌋}² + p·4.
    Base cases are defined for n = 2, 3, 4 (values 3, 4, 7). Each recursive call reduces the problem size roughly by half, leading to a recursion depth of O(log n). Each call performs at most one squaring and one signed addition, making the average number of multiplications per level less than two.

Complexity and Comparison
Both algorithms achieve O(log n) arithmetic operations. The authors argue that because only squaring is required, the constant factor is lower than in prior fast Fibonacci algorithms (e.g., Takahashi’s method


Comments & Academic Discussion

Loading comments...

Leave a Comment