MxDet
- calculate determinant of the matrix

Matrix functions
(AFL 4.10)


SYNTAX MxDet( mx, method = 0 )
RETURNS NUMBER
FUNCTION The function calculates determinant of the matrix
  • method = 0 - auto (use slow method for matrices of upto and including 5x5, fast for larger matrices)
  • method = 1 - slow (Laplace expansion method, more accurate)
  • method = 2 - fast (LU decomposition, less accurate)
"Slow" method for small matrices (1x1, 2x2, 3x3, 4x4) is actually faster than "fast", equally fast for matrix 5x5 and slower than "fast" method for matrices larger than 5x5. For this reason "auto" method uses "fast" LU method only for matrices larger than 5x5

LU decomposition is fast but subject to higher numerical errors. "Slow" method is slower yet produces much more reliable results.

For example Octave/MatLab that use LU decomposition would say that determinant of singular matrix like this

{ {16, 2, 3, 13}, { 5, 11, 10, 8}, {9, 7, 6, 12}, {4, 14, 15, 1 } }

is -1.4495e-012 due to roundoff errors of LU method.

If you want to calculate determinant using fast (LU decomposition) method, call MxDet with fast parameter set to 2.

CAVEAT: Laplace method has complexity of O(N!) and for this reason, even if you use method = 1, the maximum dimension for this method is limited to 10x10. Matrices larger than that are always calculated using LU method

EXAMPLE
SEE ALSO Matrix() function , MxSolve() function

References:

The MxDet function is used in the following formulas in AFL on-line library:

More information:

Updated on-line reference