library(matlib)
## Warning: package 'matlib' was built under R version 3.5.1
Create the equation:
eq1 <- matrix(c(1, 1, -1,
1, -1,-1,
0,0,1), 3, 3, byrow=TRUE)
colnames(eq1) <- paste0('x', 1:3)
eq2 <- c(-1, -1, 2)
showEqn(eq1, eq2)
## 1*x1 + 1*x2 - 1*x3 = -1
## 1*x1 - 1*x2 - 1*x3 = -1
## 0*x1 + 0*x2 + 1*x3 = 2
Solve the equation:
solve(eq1, eq2)
## x1 x2 x3
## 1 0 2