Skip to contents

\(a_0 + 1/(a_1 + 1/(a_2 + \cdots))\). The walk stops as soon as the remainder falls below the rounding floor of the value it came from: continuing past that emits a partial quotient made entirely of floating point residue.

Usage

ContFr(x, n)

Arguments

x

Number to expand.

n

Maximum number of partial quotients, at most 20.

Value

Named list with estimate, terms, convergents, reliable_terms, residual, n, method.

References

Classical number theory; no single owning source.

Examples

ContFr(pi, 5)
#> $estimate
#> [1] 3.141593
#> 
#> $terms
#> [1]   3   7  15   1 292
#> 
#> $convergents
#>          hs    ks
#> [1,]      3     1
#> [2,]     22     7
#> [3,]    333   106
#> [4,]    355   113
#> [5,] 103993 33102
#> 
#> $reliable_terms
#> [1] 5
#> 
#> $residual
#> [1] 5.778906e-10
#> 
#> $n
#> [1] 5
#> 
#> $method
#> [1] "simple continued fraction expansion"
#>