Getting the Modulus of the Determinant of a Matrix in R Programming – determinant() Function
Last Updated :
03 Jun, 2020
determinant()
function in R Language is a generic function that returns separately the modulus of the determinant, optionally on the logarithm scale, and the sign of the determinant.
Syntax: determinant(x, logarithm = TRUE, …)
Parameters:
x: matrix
logarithm: if TRUE (default) return the logarithm of the modulus of the determinant
Example 1:
x < - matrix(c( 3 , 2 , 6 , - 1 , 7 , 3 , 2 , 6 , - 1 ), 3 , 3 )
x
determinant(x)
|
Output:
[, 1] [, 2] [, 3]
[1, ] 3 -1 2
[2, ] 2 7 6
[3, ] 6 3 -1
$modulus
[1] 5.220356
attr(, "logarithm")
[1] TRUE
$sign
[1] -1
attr(, "class")
[1] "det"
Example 2:
x < - matrix(c( 1 , 2 , 3 , 4 ), 2 , 2 )
x
determinant(x, logarithm = FALSE)
|
Output:
[, 1] [, 2]
[1, ] 1 3
[2, ] 2 4
$modulus
[1] 2
attr(, "logarithm")
[1] FALSE
$sign
[1] -1
attr(, "class")
[1] "det"
Share your thoughts in the comments
Please Login to comment...