library(matlib)
A <- matrix(c(2,1,-1,-1,3,4,3,5),4,2,byrow = TRUE)
b <- c(6,-2,4,2)
showEqn(A, b)
## 2*x1 + 1*x2 = 6
## -1*x1 - 1*x2 = -2
## 3*x1 + 4*x2 = 4
## 3*x1 + 5*x2 = 2
c( R(A), R(cbind(A,b)) ) # show ranks
## [1] 2 2
all.equal( R(A), R(cbind(A,b)) ) # consistent?
## [1] TRUE
# Plot the equations:
plotEqn(A,b)
## 2*x1 + x2 = 6
## -x1 - 1*x2 = -2
## 3*x1 + 4*x2 = 4
## 3*x1 + 5*x2 = 2
Solve(A, b, fractions = TRUE)
## x1 = 4
## x2 = -2
## 0 = 0
## 0 = 0
The solution is 4,-2,0,0