| num2bigq | R Documentation |
num2bigq(x) searches for “small” denominator
bigq aka ‘bigRational’ approximations to numeric or
"mpfr" x.
It uses the same continued fraction approximation as package
MASS' fractions(), but using big integer,
rational and mpfr-arithmetic from packages Rmpfr and gmp.
num2bigq(x, cycles = 50L, max.denominator = 2^25, verbose = FALSE)
x |
numeric or mpfr-number like |
cycles |
a positive integer, the maximal number of approximation cycles, or equivalently, continued fraction terms to be used. |
max.denominator |
an approximate bound on the maximal
denominator used in the approximation.
If small, the algorithm may use less than |
verbose |
a logical indicating if some intermediate results should be printed during the iterative approximation. |
a big rational, i.e., bigq (from gmp)
vector of the same length as x.
Bill Venables and Brian Ripley, for the algorithm in fractions();
Martin Maechler, for the port to use Rmpfr and gmp arithmetic.
.mpfr2bigq() seems similar but typically uses much larger
denominators in order to get full accuracy.
num2bigq(0.33333)
num2bigq(pi, max.denominator = 200) # 355/113
num2bigq(pi) # much larger
num2bigq(pi, cycles=10) # much larger
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.