Getting the Determinant of the Matrix in R Programming – det() Function
det() function in R Language is used to calculate the determinant of the specified matrix.
Syntax: det(x, …)
Parameters:
x: matrix
Example 1:
# R program to illustrate# det function # Initializing a matrix with# 3 rows and 3 columnsx <- matrix(c(3, 2, 6, -1, 7, 3, 2, 6, -1), 3, 3) # Getting the matrix representationx # Calling the det() functiondet(x) |
Output:
[, 1] [, 2] [, 3]
[1, ] 3 -1 2
[2, ] 2 7 6
[3, ] 6 3 -1
[1] -185
Example 2:
# R program to illustrate# det function # Initializing a matrix with# 3 rows and 3 columnsx <- matrix(c(3, 2, 6, -1, 7, 3, 2, 6, -1), 3, 3) # Getting the matrix representationx # Getting the transpose of the matrix xy <- t(x)y # Calling the det() functiondet(y) |
Output:
[, 1] [, 2] [, 3]
[1, ] 3 -1 2
[2, ] 2 7 6
[3, ] 6 3 -1
[, 1] [, 2] [, 3]
[1, ] 3 2 6
[2, ] -1 7 3
[3, ] 2 6 -1
[1] -185


