Getting the Modulus of the Determinant of a Matrix in R Programming – determinant() Function

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to illustrate
# determinant function
  
# Initializing a matrix with
# 3 rows and 3 columns
x <- matrix(c(3, 2, 6, -1, 7, 3, 2, 6, -1), 3, 3)
  
# Getting the matrix representation
x
  
# Calling the determinant() function
determinant(x)

chevron_right


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:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to illustrate
# determinant function
  
# Initializing a matrix with
# 2 rows and 2 columns
x <- matrix(c(1, 2, 3, 4), 2, 2)
  
# Getting the matrix representation
x
  
# Calling the determinant() function
determinant(x, logarithm = FALSE)

chevron_right


Output:

     [, 1] [, 2]
[1, ]    1    3
[2, ]    2    4

$modulus
[1] 2
attr(, "logarithm")
[1] FALSE

$sign
[1] -1

attr(, "class")
[1] "det"
My Personal Notes arrow_drop_up

Recommended Posts:


Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.