rat(x, leng=6, maxm=100, name="rational.so")
x
| numeric data object for which the rational approximation is needed. |
leng
| maximum length of the continued fraction used. |
maxm
|
maximum partial denominator. If any partial denominator
exceeds maxm the continued fraction terminates at that point.
|
name
| name of object file containing the dynamically loaded C function. |
rat()
can be viewed as providing a speculative way of removing
roundoff error if the correct answer should be rational numbers with
"small" denominators.
rational()
and fractions()
which use rat()
# solve() accuracy check using a small Hilbert Matrix x <- matrix(0,5,5); x <- 1/(row(x) + col(x) -1) # confirm: rat(x) x1 <- solve(solve(x)); x2 <- rat(x1) # compare: x-x1 # with: x-x2$num/x2$den