Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2024.1.0 - Português


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)
[e, m] = det(A)

// Matrix of complex numbers:
// A = grand(3,3,"uin",0,10) + grand(3,3,"uin",0,10)*%i
A = [3+%i, 9+%i*3, 9+%i ; 8+%i*8, 4+%i*3, 7+%i*7 ; 4, 6+%i*2, 6+%i*9]
det(A)
[e, m] = det(A)
abs(m)  // in [1, 10)
--> 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:
n = 1000;
A = rand(n, n);
det(A)
[e, m] = det(A)

// Very small determinant (of a sparse-encoded matrix):
A = (triu(sprand(n,n,1)) + diag(rand(1,n)))/1.5;
det(A)
prod(diag(A))
[e, m] = det(A)
A = A/2;
det(A)
[e, m] = det(A)
--> // 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:

s = %s;
det([s, 1+s ; 2-s, s^2])

w = ssrand(2,2,4);
roots(det(systmat(w))),trzeros(w)   //zeros of linear system
--> 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 — determinante de uma matriz de razões de polinômios
  • determ — determinante de matrizes de polinômios
  • simp_mode — modifica o modo de simplificação racional

History

VersãoDescrição
6.1.1 [e,m]=det(X) syntax extended to sparse matrices.
Report an issue
<< cond Matrix Analysis orth >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Mon Jun 17 17:53:23 CEST 2024