- Compute the determinant of the given matrix.
# 3. Compute the determinant of the matrix
# 3 9 -2 4 2
# 0 1 4 -2 7
# 0 0 -2 5 2
# 0 0 0 -1 6
# 0 0 0 0 4
m <- matrix(data = c(3, 9, -2, 4, 2,
0, 1, 4, -2, 7,
0, 0, -2, 5, 2,
0, 0, 0, -1, 6,
0, 0, 0, 0, 4), nrow = 5, ncol = 5, byrow = T)
print(m)
## [,1] [,2] [,3] [,4] [,5]
## [1,] 3 9 -2 4 2
## [2,] 0 1 4 -2 7
## [3,] 0 0 -2 5 2
## [4,] 0 0 0 -1 6
## [5,] 0 0 0 0 4
# Compute determinant by hand:
d <- 3*(1*(-2*(-4)))
print(d)
## [1] 24
# Also check with R's computed result:
print(det(m))
## [1] 24