x + 2y - 3z = 5
2x + y - 3z = 13
-x + y + 2z= -8
A=matrix(c(1,2,-1,2,1,1,-3,-3,2),3,3)
print(A)
## [,1] [,2] [,3]
## [1,] 1 2 -3
## [2,] 2 1 -3
## [3,] -1 1 2
Inverse.matrix = solve(A)
print(Inverse.matrix)
## [,1] [,2] [,3]
## [1,] -0.8333333 1.1666667 0.5
## [2,] 0.1666667 0.1666667 0.5
## [3,] -0.5000000 0.5000000 0.5
A=matrix(c(1,2,-1,2,1,1,-3,-3,2),3,3)
B= c(5,13,-8)
x <- solve(A)%*%B
print(x)
## [,1]
## [1,] 7
## [2,] -1
## [3,] 0
v_A <- c(1,2,1,2,1,1,5,13,-8)
A <- matrix(v_A, 3,3)
v_B <- c(5,13,-8)
B <- matrix(v_B, 3,1)
A1 <- solve(A)
X <- round(A1 %*% B,0)
X
## [,1]
## [1,] 0
## [2,] 0
## [3,] 1
q<-matrix(c(3,1,4,4,3,3,2,3,2), nrow=3)
print(q)
## [,1] [,2] [,3]
## [1,] 3 4 2
## [2,] 1 3 3
## [3,] 4 3 2
detrm.q<-det(q)
print(paste("Dtrm q = ", detrm.q))
## [1] "Dtrm q = 13"
qx<-matrix(c(1,4,5,4,3,3,2,3,2), nrow=3)
detrm.x<-det(qx)
print(paste("Dtrm x = ", detrm.x))
## [1] "Dtrm x = 19"
qy<-matrix(c(3,1,4,1,4,5,2,3,2), nrow=3)
detrm.y<-det(qy)
print(paste("Dtrm y = ", detrm.y))
## [1] "Dtrm y = -33"
qz<-matrix(c(3,1,4,4,3,3,1,4,5), nrow=3)
detrm.z<-det(qz)
print(paste("Dtrm z = ", detrm.z))
## [1] "Dtrm z = 44"
print(paste("The determinants are ", detrm.q, ", " , detrm.x,",", detrm.y, ", and ",detrm.z))
## [1] "The determinants are 13 , 19 , -33 , and 44"
Solution using r
q=matrix(c(3,1,4,4,3,3,2,3,2),nrow=3)
b=c(1,4,5)
x <- solve(q)%*%b
print(x)
## [,1]
## [1,] 1.461538
## [2,] -2.538462
## [3,] 3.384615