

solve {base}                                 R Documentation

_S_o_l_v_e _a _S_y_s_t_e_m _o_f _E_q_u_a_t_i_o_n_s

_D_e_s_c_r_i_p_t_i_o_n_:

     This generic function solves the equation `a %*% x = b'
     for `x', where `b' can be either a vector or a matrix.

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

     solve(a, b, tol = 1e-7)

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

       a: a numeric matrix containing the coefficients of
          the linear system.

       b: a numeric vector or matrix giving the right-hand
          side(s) of the linear system.  If omitted, `b' is
          taken to be an identity matrix and `solve' will
          return the inverse of `a'.

     tol: the tolerance for detecting linear dependencies in
          the columns of `a'.

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

     `backsolve', `qr.solve'.

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

     hilbert <- function(n) { i <- 1:n; 1 / outer(i - 1, i, "+") }
     h8 <- hilbert(8); h8
     solve(h8) # gives error: `singular'
     sh8 <- solve(h8, tol = 1e-10)
     round(sh8 %*% h8, 3)

