Det {matlib}R Documentation

Determinant of a Square Matrix

Description

Returns the determinant of a square matrix X, computed either by Gaussian elimination, expansion by cofactors, or as the product of the eigenvalues of the matrix. If the latter, X must be symmetric.

Usage

Det(
  X,
  method = c("elimination", "eigenvalues", "cofactors"),
  verbose = FALSE,
  fractions = FALSE,
  ...
)

Arguments

X

a square matrix

method

one of '"elimination"' (the default), '"eigenvalues"', or '"cofactors"' (for computation by minors and cofactors)

verbose

logical; if TRUE, print intermediate steps

fractions

logical; if TRUE, try to express non-integers as rational numbers, using the fractions function; if you require greater accuracy, you can set the cycles (default 10) and/or max.denominator (default 2000) arguments to fractions as a global option, e.g., options(fractions=list(cycles=100, max.denominator=10^4)).

...

arguments passed to gaussianElimination or Eigen

Value

the determinant of X

Author(s)

John Fox

See Also

det for the base R function

gaussianElimination, Eigen

Other determinants: adjoint(), cofactor(), minor(), rowCofactors(), rowMinors()

Examples

A <- matrix(c(1,2,3,2,5,6,3,6,10), 3, 3) # nonsingular, symmetric
A
Det(A)
Det(A, verbose=TRUE, fractions=TRUE)
B <- matrix(1:9, 3, 3) # a singular matrix
B
Det(B)
C <- matrix(c(1, .5, .5, 1), 2, 2) # square, symmetric, nonsingular
Det(C)
Det(C, method="eigenvalues")
Det(C, method="cofactors")

[Package matlib version 0.9.8 Index]