det determinant of a square matrix Syntax d = det(X) [e,m] = det(X) Arguments X square matrix of real or complex numbers, polynomials, or rationals. Sparse-encoded matrices accepted. d Scalar of the X's type: the determinant of X. If X is sparse-encoded, d is dense. m real or complex number: the determinant base 10 mantissa, with abs(m) ∈ [1,10). Not supported for X polynomial or rational. e integer: the determinant base 10 exponent, such that d = m * 10e. Not supported for X polynomial or rational. Description d = det(X) yields the determinant of the matrix X. For a polynomial or rational matrix, d=det(X) uses determ(..) whose algorithm is based on the FFT. d=detr(X) can be alternatively used, based on the Leverrier algorithm. Both methods yield equivalent results. For rational matrices, turning off `simp_mode(%f)` might be required to get identical results. [e, m] = det(X) can be used only for a matrix of numbers. This syntax allows to overcome computation's underflow or overflow, when abs(d) is smaller than number_properties("tiny") ≈ 2.23 10-308 or bigger than number_properties("huge") ≈ 1.80 10308. For denses matrices, det(..) is based on the Lapack routines DGETRF for real matrices and ZGETRF for the complex case. For sparse matrices, the determinant is obtained from LU factorization thanks to the umfpack library. Examples A = rand(3,3)*5; --> det(A) ans = -10.805163 --> [e, m] = det(A) e = 1. m = -1.0805163 --> // Matrix of complex numbers: --> A = [3+%i, 9+%i*3, 9+%i ; 8+%i*8, 4+%i*3, 7+%i*7 ; 4, 6+%i*2, 6+%i*9] A = 3. + i 9. + 3.i 9. + i 8. + 8.i 4. + 3.i 7. + 7.i 4. + 0.i 6. + 2.i 6. + 9.i --> det(A) ans = 745. - 225.i --> [e, m] = det(A) e = 2. m = 7.45 - 2.25i --> abs(m) // in [1, 10) ans = 7.7823518 ]]> Very big or small determinants: underflow and overflow handling: // Very big determinant: --> A = rand(n, n); --> det(A) ans = -Inf --> [e, m] = det(A) // -3.1199e743 e = 743. m = -3.1198687 --> // Very small determinant (of a sparse-encoded matrix): --> n = 1000; --> A = (triu(sprand(n,n,1)) + diag(rand(1,n)))/1.5; --> det(A) ans = 5.21D-236 --> prod(diag(A)) ans = 5.21D-236 --> [e, m] = det(A) e = -236. m = 5.2119757 --> A = A/2; --> det(A) ans = 0. --> [e, m] = det(A) e = -537. m = 4.8641473 ]]> Determinant of a polynomial matrix: det([s, 1+s ; 2-s, s^2]) ans = -2 -s +s² +s³ --> w = ssrand(2,2,4); --> roots(det(systmat(w))),trzeros(w) ans = -3.1907522 + 0.i 2.3596502 + 0.i ans = 2.3596502 + 0.i -3.1907522 + 0.i ]]> See also detr determ simp_mode History 6.1.1 [e,m]=det(X) syntax extended to sparse matrices.