Ramanujan's Notebooks, shared: cfDen
DefinitionRamanujanNotebooks_shared_cfDennumber-theoryramanujan-notebooks
Denominator B_n of the n-th convergent of the continued fraction
b 0 + a 0 / (b 1 + a 1 / (b 2 + a 2 / (b 3 + ⋯))) with partial numerators a 0, a 1, … and
partial denominators b 0, b 1, … (complex sequences), by the usual three-term recurrence
B_0 = 1, B_1 = b 1, B_{n+2} = b (n+2) * B_{n+1} + a (n+1) * B_n.
Used for the continued fractions of Part III, Chapter 16, Entries 10–13 (pp. 19–28).
No division occurs: the function is total, with no junk value; b 0 is not used.
Whether B_n ≠ 0 is a matter for each statement.
Reference: for a k = k + 1, b k = 2k + 1 the values at n = 0, 1, 2, 3 are
1, 3, 17, 128 (so the third convergent of 1 + 1/(3 + 2/(5 + 3/7)) is 166/128).
Definition code
import Mathlib
namespace RamanujanNotebooks
/-- Denominator `B_n` of the `n`-th convergent of the continued fraction
`b 0 + a 0 / (b 1 + a 1 / (b 2 + a 2 / (b 3 + ⋯)))` with partial numerators `a 0, a 1, …` and
partial denominators `b 0, b 1, …` (complex sequences), by the usual three-term recurrence
`B_0 = 1`, `B_1 = b 1`, `B_{n+2} = b (n+2) * B_{n+1} + a (n+1) * B_n`.
Used for the continued fractions of Part III, Chapter 16, Entries 10–13 (pp. 19–28).
No division occurs: the function is total, with no junk value; `b 0` is not used.
Whether `B_n ≠ 0` is a matter for each statement.
Reference: for `a k = k + 1`, `b k = 2k + 1` the values at `n = 0, 1, 2, 3` are
`1, 3, 17, 128` (so the third convergent of `1 + 1/(3 + 2/(5 + 3/7))` is `166/128`). -/
noncomputable def cfDen (a b : ℕ → ℂ) : ℕ → ℂ
| 0 => 1
| 1 => b 1
| (n + 2) => b (n + 2) * cfDen a b (n + 1) + a (n + 1) * cfDen a b n
end RamanujanNotebooks
Source
Bruce C. Berndt, Ramanujan's Notebooks.