Learn R Programming

contFracR (version 1.2.1)

root2cfrac: Function To Generate Continued Fraction For Arbitrary Roots

Description

This function generates the generalized continued fraction for any input value x^(m/n).

Usage

root2cfrac(x, n, m = 1, nterms = 10, ...)

Value

A list, containing: The continued fraction numerators and denominators in bigz form num , denom . The continued fraction numerators and denominators in numeric form numericnum, numericdenom . In the extreme case that a value exceeds the machine size of a numeric, NA is returned. The inputs x, n, m are echoed back.

Arguments

x

The number itself. Integers, doubles, bigz, and bigq classes are allowed.

n

The integer denominator of the power to which x is raised. That is, when m is 1, the n-th root of x is generated.

m

The integer numerator of the power to which x is raised. The default is 1.

nterms

How many terms (denominators) to calculate.

...

Reserved for future use

Author

Carl Witthoft, carl@witthoft.com

Details

The generalized continued fraction for arbitrary roots will not be periodic, and may not even show a pattern in the denominator values. By comparison, sqrt2periodicCfrac generates a simple continued fraction with a periodic sequence for square roots only. That periodic sequence tends to converge more slowly than the aperiodic sequence produced here.

References

https://en.wikipedia.org/wiki/Generalized_continued_fraction

See Also

sqrt2periodicCfrac, cfrac2num

Examples

Run this code
root2cfrac(x = 2, n = 3)
root2cfrac(x=17, n= 5, m= 2)
root2cfrac(x = 2, n = 2, nterms = 20)
#compare with 
sqrt2periodicCfrac(num = 2, nterms = 20)


Run the code above in your browser using DataLab