Wolfram ResearchProductsPurchasingServices & ResourcesAbout UsOur Sites
Mathematica Technical FAQs Services & Resources / Mathematica / Kernels & Programming
-----
 /
Symbols
*Mathematica
*Network Mathematica
*webMathematica
*gridMathematica
*Personal Grid Edition
*Wolfram Workbench
*Wolfram Education Group
*Application Packages
*Mathematica for Students
*Mathematica CalcCenter
*Publicon
*A New Kind of Science Explorer
*Mathematical Explorer
*Mathematica Teacher's Edition
*Calculus WIZ
*Mathematica Player
*Ask about this page
*Print this page
*Email this page
*Give us feedback
*
Sign up for our newsletter:

Det


Usage Message:

Det[m] gives the determinant of the square matrix m.

Attributes[Det] = {Protected}

Options:

Modulus -> 0

Notes:

For small matrices (smaller than about 11 by 11), Det[m] is computed using simple cofactor expansion. For larger matrices, cofactor expansion can be prohibitively time-consuming. Instead, for larger matrices, the Det function uses Gaussian elimination or partial row reduction to reduce the complexity of the calculation before computing the determinant. This optimization provides for much faster computation of determinants.

The form of the results from Det[m] for large symbolic matrices will not always be identical to the form that would be given by cofactor expansion. The most commonly encountered example of this difference is in computation of the characteristic polynomial for a large matrix (larger than about 11 by 11). The result will sometimes be given as a rational function, reflecting the initial transformations that were used to speed up the calculation, rather than as a polynomial.


In[1]:= m = N[Table[Sin[x y], {x, 14}, {y, 14}]] ;

In[2]:= d = Det[m - x IdentityMatrix[14]]

                    119            -198            -198
Out[2]= (-1.21726 10    (1.32519 10     + 1.6948 10     x - 
 
                  -198  2           -198  3             -197  4
>        5.7317 10     x  - 7.636 10     x  + 1.00354 10     x  + 
 
                   -197  5             -197  6             -197  7
>        1.35802 10     x  - 1.02941 10     x  - 1.32725 10     x  + 
 
                   -198  8             -198  9             -198  10
>        7.18524 10     x  + 8.03595 10     x  - 3.61125 10     x   - 
 
                   -198  11             -198  12             -199  13
>        3.16315 10     x   + 1.30586 10     x   + 8.21605 10     x   - 
 
                   -199  14             -199  15             -200  16
>        3.30445 10     x   - 1.40429 10     x   + 5.66687 10     x   + 
 
                   -200  17           -201  18             -201  19
>        1.55058 10     x   - 6.362 10     x   - 1.05921 10     x   + 
 
                   -202  20             -203  21             -203  22
>        4.44238 10     x   + 4.05856 10     x   - 1.74284 10     x   - 
 
                  -205  23           -205  24
>        6.6597 10     x   + 2.928 10     x  )) / 
 
                -17             -18               -18  2 5
>    (1.54539 10    + 5.71835 10    x - 8.13562 10    x )
From this result you can in principle get the characteristic polynomial (and a remainder polynomial with numerically negligible coefficients) using PolynomialDivision . For reasons of numerical stability, this method is often appropriate only for high-precision matrices.

In[3]:= {num, den} = {Numerator[d], Denominator[d]} ;

In[4]:= {cp, rem} = PolynomialDivision[num, den, x]

                                         2            3            4
Out[4]= {-183008. + 104539. x + 366989. x  - 112690. x  - 230950. x  + 
 
               5           6            7            8            9
>     46597.1 x  + 69568. x  - 9566.38 x  - 11424.3 x  + 1037.15 x  + 
 
               10            11            12           13       14
>     1048.91 x   - 56.8254 x   - 50.6084 x   + 1.2399 x   + 1. x  , 
 
                -92             -92              -92  2             -92  3
>    -1.61499 10    - 3.09815 10    x + 2.0075 10    x  + 6.05247 10    x  - 
 
                -93  4             -92  5             -93  6
>     6.39704 10    x  - 4.80003 10    x  - 1.07117 10    x  + 
 
                -92  7             -94  8             -93  9
>     1.87267 10    x  + 7.11615 10    x  - 3.03747 10    x }
In examples such as this, where the symbolic part of the matrix occurs in a particularly simple form, there are often better ways to do the calculation rather than direct computation of a symbolic determinant. For example, you can construct the characteristic polynomial using the eigenvalues of the matrix (which are the same as the roots of the characteristic polynomial computed above).

In[5]:= ev = Eigenvalues[m] //Sort

Out[5]= {-3.34798, -3.29011, -3.26555, -3.2125, -2.35978, -2.06242, -1.09661, 
 
>    0.739625, 1.97485, 2.28356, 2.4223, 3.22977, 3.32804, 3.41689}

In[6]:= NRoots[cp == 0, x]

Out[6]= x == -3.34798 || x == -3.29011 || x == -3.26555 || x == -3.2125 || 
 
>    x == -2.35978 || x == -2.06242 || x == -1.09661 || x == 0.739625 || 
 
>    x == 1.97485 || x == 2.28356 || x == 2.4223 || x == 3.22977 || 
 
>    x == 3.32804 || x == 3.41689
Another approach is to compute values for the characteristic polynomial using interpolation. Here is an example of the use of interpolation to compute the eigenvalue near x == 0.739625. This approach has the advantage of never requiring a potentially time-consuming evaluation of a symbolic determinant. The example here, which involves the computation of 51 numerical determinants, will normally be faster than a single evaluation of the corresponding symbolic determinant.

In[7]:= cpi[x_] = Interpolation[
            Table[{t, Det[m - t IdentityMatrix[14]]}, {t, 0, 1, .02}]][x]

Out[7]= InterpolatingFunction[{{0, 1.}}, <>][x]

In[8]:= FindRoot[cpi[x], {x, 0, 1}]

Out[8]= {x -> 0.739625}

Known Bugs

The Det function in Version 3.0 of Mathematica can return a result with an incorrect sign for certain large exact matrices. This error is currently being investigated. Although a complete characterization of this error is not yet available, all of the known examples are exact matrices with dimension 12 or larger and with a matrix element -1 as the only non-zero element in some column or row.

Here is an example of a result with an incorrect sign.


In[1]:= Det[DiagonalMatrix[{-1,2,3,4,5,6,7,8,9,a,b,c}]]

Out[1]= 362880 a b c
You can get a correct result in this example by computing the product of the eigenevalues.

In[2]:= Times @@ Eigenvalues[DiagonalMatrix[{-1,2,3,4,5,6,7,8,9,a,b,c}]]

Out[2]= -362880 a b c
Here is a more complicated example, which also gives an incorrect sign. The correct result can be computed using the product of the eigenvalues.

In[3]:= m = {{-1,0,0,0,0,0,0,0,0,0,0,0},
              {0,2,0,1,0,0,0,1,0,0,0,0},
              {0,0,3,0,0,0,0,0,0,0,0,0},
              {0,0,0,4,0,0,0,0,1,0,0,0},
              {0,1,0,0,5,0,0,0,1,0,0,0},
              {0,0,0,0,0,6,0,0,0,0,1,1},
              {0,0,1,0,0,0,7,0,0,1,0,0},
              {0,0,0,0,0,0,0,8,0,0,0,0},
              {0,0,0,1,0,0,0,0,9,0,0,0},
              {0,0,0,1,0,0,1,0,0,x,0,0},
              {0,1,0,0,0,0,1,0,0,0,y,0},
              {0,0,0,0,0,0,0,0,0,0,0,z}};

In[4]:= Det[m]

Out[4]= 50400 (-y + 7 x y) z

In[5]:= Times @@ Eigenvalues[m] //Expand

Out[5]= 50400 y z - 352800 x y z

When additional information about this error becomes available, it will be included here, or can be obtained by contacting Technical Support .

We apologize for any difficulties caused by this error.


Additional Online Documentation:

Mathematica 3.0
http://documents.wolfram.com/v3/RefGuide/Det.html

Mathematica 4.0
http://documents.wolfram.com/v4/RefGuide/Det.html




 © 2008 Wolfram Research, Inc.  Terms of Use  Privacy Policy