# Solve a system of linear equations # Define A matrix and b vector from Section 2.10 in the notes A <- matrix(c(2, 3, 3, -6), 2, 2) b <- matrix(c(5, -3), 2, 1) # check the determinant det(A) # obtain the inverse Ainv=solve(A) # get the solution Ainv %*% b # or do it in one step solve(A) %*% b # or do it "the long way" A2 <- matrix(c(-6, -3, -3, 2), 2, 2) 1/(det(A))*A2 %*% b