Skip to content

ContinuedFractionK ​

The continued fraction f1/(g1+f2/(g2+⋯ ))f_1/(g_1 + f_2/(g_2 + \cdots)) over an index range, finite or infinite.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageContinuedFractionK✓
ContinuedFractionK(f, g, (i, imin, imax))the finite continued fraction, exact, for imin ≤ i ≤ imax
ContinuedFractionK(f, g, (i, imin, PositiveInfinity))the infinite fraction, when ff and gg do not depend on ii
Typed signatures
TypePackageApplies
(any, any, tuple<symbol, integer, any>) -> numbermodularalways

Domain: The modular group

Details
  • The iterator is written the same way Sum and Product write theirs: Tuple(i, imin, imax)
  • The finite fraction is built right to left: fimax/gimaxf_{imax}/g_{imax} first, then each fi/(gi+that)f_i/(g_i + \text{that}) down to i=imini = imin
  • The infinite case is solved algebraically, not truncated: constant f,gf, g make x=f/(g+x)x = f/(g+x), whose positive root x=(−g+g2+4f)/2x = (-g + \sqrt{g^2+4f})/2 is the fraction's value — an ff or gg that depends on ii has no such closed form here, and the call stays unevaluated

Examples

Basic #

11+12+13+14+15\cfrac{1}{1 + \cfrac{1}{2 + \cfrac{1}{3 + \cfrac{1}{4 + \cfrac15}}}}

live ↗
InContinuedFractionK(1,k,(k,1,5))\mathrm{ContinuedFractionK}(1, k, (k,1,5))Out157225\frac{157}{225}
Scope #

the infinite all-ones fraction is 1/φ1/\varphi — (5−1)/2(\sqrt5 - 1)/2

live ↗
InContinuedFractionK(1,1,(k,1,∞))\mathrm{ContinuedFractionK}(1, 1, (k,1,∞))Out5−12\frac{\sqrt{5}-1}{2}
About
Examples2
Checked againstWolfram Language 2 agree
CrosswalkWolfram Language

See also: Convergents, ContinuedFraction