If x is a scalar, it will return a list with components cf
the continued fraction as a vector, rat the rational approximation,
and prec the difference between the value and this approximation.
If x is a vector, the continued fraction, then it will return a list
with components f the numerical value, p and q the
convergents, and prec an estimated precision.
Arguments
x
a numeric scalar or vector.
tol
tolerance; default 1e-12.
Details
If x is a scalar its continued fraction will be generated up to
the accuracy prescribed in tol. If it is of length greater 1, the
function assumes this to be a continued fraction and computes its value
and convergents.
The continued fraction \([b_0; b_1, \ldots, b_{n-1}]\) is assumed to be
finite and neither periodic nor infinite. For implementation uses the
representation of continued fractions through 2-by-2 matrices
(i.e. Wallis' recursion formula from 1644).
References
Hardy, G. H., and E. M. Wright (1979). An Introduction to the Theory of
Numbers. Fifth Edition, Oxford University Press, New York.