root2cfrac {contFracR} | R Documentation |
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, ...)
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 |
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 |
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.
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.
Author(s)
Carl Witthoft, carl@witthoft.com
References
https://en.wikipedia.org/wiki/Generalized_continued_fraction
See Also
Examples
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)