Ramanujan's Lost Notebook Part I, Ch. 7: ch07Continuants
DefinitionRamanujanLostNotebook_PartI_ch07_ch07Continuantsnumber-theoryramanujan-lost-notebook
Numerator and denominator of the depth-N convergent of 1/(1+a₁/(b₁+a₂/(b₂+…))). The pair recurrence avoids intermediate divisions. At N=0 the convergent is 1; a₀ and b₀ are unused. Source conventions: (7.1.1), (7.1.2), (7.1.4), (7.4.12).
Definition code
import Mathlib
noncomputable section
namespace RamanujanLostNotebook.PartI
/-- Numerator and denominator of the depth-N convergent of 1/(1+a₁/(b₁+a₂/(b₂+…))). The pair recurrence avoids intermediate divisions. At N=0 the convergent is 1; a₀ and b₀ are unused. Source conventions: (7.1.1), (7.1.2), (7.1.4), (7.4.12). -/
noncomputable def ch07Continuants (a b : ℕ → ℂ) : ℕ → ℂ × ℂ
| 0 => (1, 1)
| 1 => (b 1, b 1 + a 1)
| n + 2 =>
let u := ch07Continuants a b (n + 1)
let v := ch07Continuants a b n
(b (n + 2) * u.1 + a (n + 2) * v.1,
b (n + 2) * u.2 + a (n + 2) * v.2)
end RamanujanLostNotebook.PartI
end
Source
G. E. Andrews and B. C. Berndt, Ramanujan's Lost Notebook, Part I, Springer 2005, Chapter 7.