Ex C25 Pg 353

Calculating determinant of a 3 X 3 matrix

Doing the computations by hand, find the determinant of the matrix below:

mat = matrix(c (3,-1,4,2,5,1,2,0,6), ncol=3 , nrow=3, byrow=TRUE)
mat
##      [,1] [,2] [,3]
## [1,]    3   -1    4
## [2,]    2    5    1
## [3,]    2    0    6

Steps to calculate the determinant of the 3 X 3 matrix

determinant<-3*(5*6-0*1)-(-1)*(2*6-1*2)+4*(2*0-2*5)
determinant
## [1] 60

Verify using the R function det

print(det(mat))
## [1] 60

Ex C26 pg 353

Calculating the determinant of a 4 X 4 matrix

mat1 = matrix(c (2,0,3,2,5,1,2,4,3,0,1,2,5,3,2,1), ncol=4 , nrow=4, byrow=TRUE)
mat1
##      [,1] [,2] [,3] [,4]
## [1,]    2    0    3    2
## [2,]    5    1    2    4
## [3,]    3    0    1    2
## [4,]    5    3    2    1

Steps to calculate the detereminant

#Break up the matrix to calculate determinants
#With reference to mat[1,1]
mat1_1<-matrix(c (1,2,4,0,1,2,3,2,1), ncol=3 , byrow=TRUE)
#With reference to mat[1,2]
mat1_2<-matrix(c (5,2,4,3,1,2,5,2,1), ncol=3 , byrow=TRUE)
#Similarly
mat1_3<-matrix(c (5,1,4,3,0,2,5,3,1), ncol=3 , byrow=TRUE)
mat1_4<-matrix(c (5,1,2,3,0,1,5,3,2), ncol=3 , byrow=TRUE)
determinant_mat1<-2*det(mat1_1)-0*(det(mat1_2))+3*(det(mat1_3))-2*(det(mat1_4))
determinant_mat1
## [1] 29

Verify using R

print(det(mat1))
## [1] 29