root2cfrac | R Documentation |
This function generates the generalized continued fraction for any input value x^(m/n)
.
root2cfrac(x, n, m = 1, nterms = 10, ...)
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 |
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.
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.
Carl Witthoft, carl@witthoft.com
https://en.wikipedia.org/wiki/Generalized_continued_fraction
sqrt2periodicCfrac
, cfrac2num
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.