backsolve                package:base                R Documentation

_S_o_l_v_e _a_n _U_p_p_e_r _o_r _L_o_w_e_r _T_r_i_a_n_g_u_l_a_r _S_y_s_t_e_m

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

     Solves a system of linear equations where the coefficient matrix
     is upper or lower triangular.

_U_s_a_g_e:

        backsolve(r, x, k= ncol(r), upper.tri = TRUE, transpose = FALSE)
     forwardsolve(l, x, k= ncol(l), upper.tri = FALSE, transpose = FALSE)

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

     The solution of the triangular system.  The result will be a
     vector if `x' is a vector and a matrix if `x' is a matrix.

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

     Dongarra, J. J., Bunch,J. R.,  Moler, C. B. and  Stewart, G. W.
     (1978) LINPACK Users Guide.  Philadelphia: SIAM Publications.

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

     `chol', `qr', `solve'.

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

     ## upper triangular matrix `r':
     r <- rbind(c(1,2,3),
                c(0,1,1),
                c(0,0,2))
     ( y <- backsolve(r, x <- c(8,4,2)) ) # -1 3 1
     r %*% y # == x = (8,4,2)
     ( y2 <- backsolve(r, x, transpose = TRUE)) # 8 -12 -5
     all(t(r) %*% y2 == x)# exactly on Linux (Pentium)
     all(y  == backsolve(t(r), x, upper = FALSE, transpose = TRUE))
     all(y2 == backsolve(t(r), x, upper = FALSE, transpose = FALSE))

