we can solve simultaneous equation using matrix algebra in R

Suppose we have 3 set equations, that we want to solve

x+2y-4z=40

2x+3y+5z=50

x+3y+6z=100

A<-matrix(data=c(1,2,-4,2,3,5,1,3,6), nrow=3, byrow = T)
a<-matrix(data=c(40,50,100), nrow=3, byrow = T)
A
##      [,1] [,2] [,3]
## [1,]    1    2   -4
## [2,]    2    3    5
## [3,]    1    3    6
a
##      [,1]
## [1,]   40
## [2,]   50
## [3,]  100

Solution for the samultaneous equation

round(solve(A,a),1)
##       [,1]
## [1,] -48.7
## [2,]  47.0
## [3,]   1.3
#transpose of A
t(A)
##      [,1] [,2] [,3]
## [1,]    1    2    1
## [2,]    2    3    3
## [3,]   -4    5    6
#inverse of A
round(solve(A),2)
##       [,1]  [,2]  [,3]
## [1,] -0.13  1.04 -0.96
## [2,]  0.30 -0.43  0.57
## [3,] -0.13  0.04  0.04
#diagnal matrix of A
diag(A)
## [1] 1 3 6
#eigen values of A
eigen(A)
## eigen() decomposition
## $values
## [1]  8.192582  2.807418 -1.000000
## 
## $vectors
##            [,1]        [,2]       [,3]
## [1,] -0.2402309  0.92361157  0.8156925
## [2,]  0.6237095  0.08893567 -0.5647102
## [3,]  0.7438250 -0.37287012  0.1254912
#cofactor of A eliment(1,1)
#for this 'matlib' package is best
#install.packages("matlib")
library(matlib)
## Warning: package 'matlib' was built under R version 3.6.3
cofactor(A, 1, 1)
## [1] 3