4x4 Matrix A
## [,1] [,2]
## [1,] 2 1
## [2,] 8 7
Get the lower triangular Matrix L
matLower <- lu(matA)$L
matLower
## [,1] [,2]
## [1,] 1 0
## [2,] 4 1
Get the upper triangular Matrix U
matUpper <- lu(matA)$U
matUpper
## [,1] [,2]
## [1,] 2 1
## [2,] 0 3
A=LU
matA
## [,1] [,2]
## [1,] 2 1
## [2,] 8 7
matLower%*%matUpper
## [,1] [,2]
## [1,] 2 1
## [2,] 8 7