Documentation |
Determinant of a matrix
This functionality does not run in MATLAB.
det(A, options)
det(A) returns the determinant of the matrix A.
If the input matrix is an array of domain type DOM_ARRAY, then numeric::det(A, Symbolic) is called to compute the result.
The determinant of hfarrays of domain type DOM_HFARRAY is internally computed via numeric::det(A).
If the argument does not evaluate to a matrix of one of the types mentioned above, a symbolic call det(A) is returned.
The MinorExpansion option is useful for small matrices (typically, matrices of dimension up to 10) containing many symbolic entries. By default, det tries to recognize matrices that can benefit from using MinorExpansion, and uses this option when computing their determinants. Nevertheless, det does not always recognize these matrices. Also, identifying that a matrix is small enough and contains many symbolic entries takes time. To improve performance, use the MinorExpansion option explicitly.
By default, det calls normal before returning results. This additional internal call ensures that the final result is normalized. This call can be computationally expensive. It also affects the result returned by det only if a matrix contains variables or exact expressions, such as sqrt(5) or sin(PI/7)).
To avoid this additional call, specify Normal = FALSE. In this case, det also can return normalized results, but does not guarantee such normalization. See Example 3 and Example 4.
We compute the determinant of a matrix given by various data types:
A := array(1..2, 1..2, [[1, 2], [3, PI]]); det(A)
B := hfarray(1..2, 1..2, [[1, 2], [3, PI]]); det(B)
C := matrix(2, 2, [[1, 2], [3, PI]]); det(C)
delete A, B, C:
If the input does not evaluate to a matrix, then symbolic calls are returned:
delete A, B: det(A + 2*B)
If you use the Normal option, det calls the normal function for final results. This call ensures that det returns results in normalized form:
det(matrix([[x, x^2], [x/(x + 2), 1/x]]))
If you specify Normal = FALSE, det does not call normal for the final result:
det(matrix([[x, x^2], [x/(x + 2), 1/x]]), Normal = FALSE)
Using Normal can significantly decrease performance of det. For example, computing the determinant of this matrix takes a long time:
n := 5: det5 := det(matrix([[(x[i*j]^(i + j) + x[i+j]^j)/(i + j) $ j = 1..n] $ i = 1..n])):
For better performance, specify Normal = FALSE:
n := 5: det5 := det(matrix([[(x[i*j]^(i + j) + x[i+j]^j)/(i + j) $ j = 1..n] $ i = 1..n]), Normal = FALSE):
A |
Square matrix: either a two-dimensional array, a two-dimensional hfarray, or an object of the category Cat::Matrix |
MinorExpansion |
Compute the determinant by a recursive minor expansion along the first column. |
Normal |
Option, specified as Normal = b Return normalized results. The value b must be TRUE or FALSE. By default, Normal = TRUE, meaning that det guarantees normalization of the returned results. Normalizing results can be computationally expensive. |