fractions                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:

     fractions(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.

     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.

_V_a_l_u_e:

     An object of class '"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.

_R_e_f_e_r_e_n_c_e_s:

     Venables, W. N. and Ripley, B. D. (2002) _Modern Applied
     Statistics with S._ Fourth Edition. Springer.

_S_e_e _A_l_s_o:

     'rational'

_E_x_a_m_p_l_e_s:

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

