Find rational approximations to the components of a real numeric object using a standard continued fraction method.
rational(x, cycles = 10, max.denominator = 2000, ...)
- Any object of mode numeric. Missing values are now allowed.
- The maximum number of steps to be used in the continued fraction approximation process.
- An early termination criterion. If any partial denominator exceeds
max.denominatorthe continued fraction stops at that point.
- arguments passed to or from other methods.
Each component is first expanded in a continued fraction of the form
x = floor(x) + 1/(p1 + 1/(p2 + ...)))
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 and the ratio returned as the value.
A numeric object with the same attributes as
x but with entries rational approximations to the values. This effectively rounds relative to the size of the object and replaces very small entries by zero.
Documentation reproduced from package MASS, version 7.3-45. License: GPL-2 | GPL-3