Continued fractions
Description
Various utilities for manipulating continued fractions
Details
Package:  contfrac 
Type:  Package 
Version:  1.0 
Date:  20080404 
License:  GPL 
Author(s)
Robin K. S. Hankin
Maintainer: <hankin.robin@gmail.com>
References

W. H. Press, B. P. Flannery, S. A. Teukolsky, and W. T. Vetterling 1992. Numerical recipes 3rd edition: the art of scientific computing. Cambridge University Press; section 5.2 “Evaluation of continued fractions”
W. J. Lenz 1976. Generating Bessel functions in Mie scattering calculations using continued fractions. Applied Optics, 15(3):668671
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  # approximate real numbers with continued fraction:
as_cf(pi)
as_cf(exp(1),25) # OK up to element 21 (which should be 14)
# Some convergents of pi:
jj < convergents(c(3,7,15,1,292))
jj$A / jj$B  pi
# An identity of Euler's:
jj < GCF(a=seq(from=2,by=2,len=30), b=seq(from=3,by=2,len=30), b0=1)
jj  1/(exp(0.5)1) # should be small
# Now a continued fraction representation of tan(z):
tan_cf < function(z,n=14){ GCF(c(z,rep(z^2,n1)), seq(from=1,by=2,len=n)) }
tan_cf(1+1i)  tan(1+1i) # should be small

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker. Vote for new features on Trello.