as_cf {contfrac} | R Documentation |
Approximates a real number in continued fraction form
Description
Approximates a real number in continued fraction form using a standard simple algorithm
Usage
as_cf(x, n = 10)
Arguments
x |
real number to be approximated in continued fraction form |
n |
Number of partial denominators to evaluate; see Notes |
Note
Has difficulties with rational values as expected
Author(s)
Robin K. S. Hankin
See Also
Examples
phi <- (sqrt(5)+1)/2
as_cf(phi,50) # loses it after about 38 iterations ... not bad ...
as_cf(pi) # looks about right
as_cf(exp(1),20)
f <- function(x){CF(as_cf(x,30),TRUE) - x}
x <- runif(40)
plot(sapply(x,f))
[Package contfrac version 1.1-12 Index]