To upload the package, just type:

library(matlib)

EXAMPLE 1: Recall we have the following system of linear equations such that x1 + x2 = 4 2x1 + x2 = 5. Its augmented matrix is  1 1 4 2 1 5 . In R you type:

A <- matrix(c(1,2,1,1), nrow = 2, ncol = 2)

If you type A, then R will return

A
##      [,1] [,2]
## [1,]    1    1
## [2,]    2    1

Now we create a vector for the right-hand side of the system of linear equations:

b <- c(4, 5)
b
## [1] 4 5

Then, in order to solve the system of linear equations with the matlib package, just type:

Solve(A, b)
## x1    =  1 
##   x2  =  3

Without this package, if you failed to install matlib, just type

solve(A, b)
## [1] 1 3

EXAMPLE 2:

A <- matrix(c(1,-2,-1,2,3,2,3,-2,1), nrow = 3, ncol = 3)
A
##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]   -2    3   -2
## [3,]   -1    2    1
b <- c(6, -1, 2)
b
## [1]  6 -1  2
Solve(A, b)
## x1      =  1 
##   x2    =  1 
##     x3  =  1

Again, this package can plot not only the dimensional geometry but also it can plot the three-dimensional geometry of the system of linear equations. If you type as follows:

plotEqn3d(A,b, xlim=c(0,4), ylim=c(0,4))

EXAMPLE 3: In R, first you create the coefficient matrix A by the following:

A <- matrix(c(1,0,1,0,1,0,0,1,0,1,1,0,0,1,0,1),nrow=4,ncol=4)
A
##      [,1] [,2] [,3] [,4]
## [1,]    1    1    0    0
## [2,]    0    0    1    1
## [3,]    1    0    1    0
## [4,]    0    1    0    1

Now we create a vector for the right-hand side of the system of linear equations such that

b <- c(475, 489, 542,422)
b
## [1] 475 489 542 422
Solve(A, b)
## x1     - 1*x4  =   53 
##   x2     + x4  =  422 
##     x3   + x4  =  489 
##             0  =    0