In order to save some computational time, there are important theoretical properties of matrix operations. We begin with some properties of matrix operations in this section
library(matlib)
A <- matrix(c(1,-2,-1,2,3,2,3,-2,1), nrow = 3, ncol = 3)
inv(A)
## [,1] [,2] [,3]
## [1,] 0.58333333 0.3333333 -1.0833333
## [2,] 0.33333333 0.3333333 -0.3333333
## [3,] -0.08333333 -0.3333333 0.5833333
Then, R returns
library(MASS)
fractions(inv(A))
## [,1] [,2] [,3]
## [1,] 7/12 1/3 -13/12
## [2,] 1/3 1/3 -1/3
## [3,] -1/12 -1/3 7/12
we can use the solve() function to find the inverse of a matrix instead of the inv() function.
library(matlib)
A <- matrix(c(1,-2,-1,2,3,2,3,-2,1), nrow = 3, ncol = 3)
solve(A)
## [,1] [,2] [,3]
## [1,] 0.58333333 0.3333333 -1.0833333
## [2,] 0.33333333 0.3333333 -0.3333333
## [3,] -0.08333333 -0.3333333 0.5833333