

rational(rational)                           R Documentation

_R_a_t_i_o_n_a_l _A_p_p_r_o_x_i_m_a_t_i_o_n _t_o _R_e_a_l _N_u_m_b_e_r_s

_U_s_a_g_e_:

     rational(x, ...)

_A_r_g_u_m_e_n_t_s_:

       x: Numeric array to be approximated.

     ...: Optional additional parameters to be passed to
          rat(x, ...)

_V_a_l_u_e_:

     Numeric array of the same shape as `x' of rational
     approximations.

     If `x' contains the results of a calculation for which
     the correct answers rational with ``small'' denomina-
     tors, this may remove roundoff error.

     Similar to `round(..)', except that full accuracy is
     maintained for many exactly rational quantities.

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

     `fractions' and the primitive function `rat'.

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

     # solve() accuracy check using a small Hilbert Matrix
         x <- matrix(0,5,5); x <- 1/(row(x) + col(x) - 1); rat(x)

         x1 <- solve(solve(x))
     #compare:
         x-x1
     #with:
         x-rational(x1)

