convergents: Partial convergents of continued fractions

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

Partial convergents of continued fractions or generalized continued fractions

Usage

1
2
convergents(a)
gconvergents(a,b, b0 = 0)

Arguments

a,b

In function convergents(), the elements of a are the partial denominators (the first element of a is the integer part of the continued fraction). In gconvergents() the elements of a are the partial numerators and the elements of b the partial denominators

b0

The floor of the fraction

Details

Function convergents() returns partial convergents of the continued fraction

ommitted: see PDF

where a = a_0,a_1,a_2,... (note the off-by-one issue).

Function gconvergents() returns partial convergents of the continued fraction

ommitted: see PDF

where a = a_1,a_2,...

Value

Returns a list of two elements, A for the numerators and B for the denominators

Note

This classical algorithm generates very large partial numerators and denominators. To evaluate limits, use functions CF() or GCF().

Author(s)

Robin K. S. Hankin

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”

See Also

CF

Examples

1
2
3
4
5
6
7
# Successive approximations to pi:

jj <- convergents(c(3,7,15,1,292))
jj$A/jj$B - pi     # should get smaller


convergents(rep(1,10))

contfrac documentation built on May 1, 2019, 8:07 p.m.