num2bigq {Rmpfr} | R Documentation |
BigQ / BigRational Approximation of Numbers
Description
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.
Usage
num2bigq(x, cycles = 50L, max.denominator = 2^25, verbose = FALSE)
Arguments
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. |
Value
a big rational, i.e., bigq
(from gmp)
vector of the same length as x
.
Author(s)
Bill Venables and Brian Ripley, for the algorithm in fractions()
;
Martin Maechler, for the port to use Rmpfr and gmp
arithmetic.
See Also
.mpfr2bigq()
seems similar but typically uses much larger
denominators in order to get full accuracy.
Examples
num2bigq(0.33333)
num2bigq(pi, max.denominator = 200) # 355/113
num2bigq(pi) # much larger
num2bigq(pi, cycles=10) # much larger