fractions(x, cycles = 10, max.denominator = 2000)
max.denominator the continued fraction
stops at that point.
"fractions". A
structure with
.Data component the same
as the input numeric
x, but with the
rational approximations held as a character vector attribute,
"fracs"
. Arithmetic operations on
"fractions"
objects are possible.
Each component is first expanded in a continued fraction of the form
x = floor(x) + 1/(p1 + 1/(p2 + ...)))
where
p1,
p2
, ... are positive integers,
terminating either at
cycles terms or
when a
pj > max.denominator. The
continued fraction is then re-arranged to retrieve the numerator and
denominator as integers. The numerators and denominators are then
combined into a character vector that becomes the
"fracs"
attribute and used in printed
representations. Arithmetic operations on
"fractions"
objects have full floating
point accuracy, but the character representation printed out may not.
X <- matrix(runif(25), 5, 5) solve(X, X/5) fractions(solve(X, X/5)) fractions(solve(X, X/5)) + 1