rational                package:MASS                R Documentation

_R_a_t_i_o_n_a_l _A_p_p_r_o_x_i_m_a_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     Find rational approximations to the components of a real numeric
     object using a standard continued fraction method.

_U_s_a_g_e:

     rational(x, cycles = 10, max.denominator = 2000, ...)

_A_r_g_u_m_e_n_t_s:

       x: Any object of mode numeric. Missing values are now allowed. 

  cycles: The maximum number of steps to be used in the continued
          fraction approximation process. 

max.denominator: An early termination criterion.  If any partial
          denominator exceeds 'max.denominator' the continued fraction
          stops at that point. 

     ...: arguments passed to or from other methods. 

_D_e_t_a_i_l_s:

     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 and the ratio returned as the value.

_V_a_l_u_e:

     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.

_S_e_e _A_l_s_o:

     'fractions'

_E_x_a_m_p_l_e_s:

     X <- matrix(runif(25), 5, 5)
     zapsmall(solve(X, X/5)) # print near-zeroes as zero
     rational(solve(X, X/5))

