Determinants

Author : Thomas Shores

      University of Nebraska

      Send comments to : tshores@math . unl . edu

Definition and Basic Properties

The main reason that determinants are useful is the following:  for a given matrix A they provide us with a single number (called the determinant of A),  which is  nonzero precisely when A is an invertible matrix.

Here is a summary of all the laws of determinants that we need.  An example of each law will be given below.  Let's start with the definition of determinant in terms of expansion down the first column.  

DEFINITION.  The determinant of a 1×1 matrix is the single entry of the matrix.  For n > 1,      
         the determinant of the n×n matrix A = [ai,j] is the Sum[ai,1 Ai,1], where Ai,j means the 
         (i,j)th cofactor, i.e., (-1)i+j Mi,j, where Mi,j is the (i,j)th minor of A, i.e.,  the 
         determinant of the matrix obtained from A by deleting the ith row and jth column of A
         and collapsing the remaining elements together.  We use the notations  |A|   or det(A)
         for the determinant of  the matrix  A.  

NB:  There are two important things to remember about determinants:
	(1)  Spelling:  it is spelled determinANT.
	(2)  What it is:  a determinant is a NUMBER, not a matrix or vector.  Also, one calculates the determinant of a  SQUARE matrix to get the resulting number.

We'll need these definitions for D12-D14:

DEFINITION.   The minors matrix of the matrix A = [ai,j] is the matrix M(A) = [Mi,j(A)] of
        minors of A.
DEFINITION.  The cofactors matrix of a matrix A = [ai,j] is the matrix  Acof = [Ai,j] of 
        cofactors of the matrix A.

Here are the basic laws of determinants, all of which can be deduced from the definition:

D1:  The determinant of a  matrix with a zero row is 0.
D2:  Exchanging two rows of a determinant changes its sign.
D3:  Multiplying a single row of a matrix by a constant gives a determinant whose value is the constant times the determinant of the original matrix.
D4:  A determinant with repeated rows has  value 0.
D5:  The determinant is linear in each row.
D6:  Adding a multiple of one row to another does not change a determinant.
D7:  The determinant of an (upper) triangular matrix is the product of the diagonal elements.
D8:  The determinant of a matrix is nonzero if and only if the matrix is nonsingular.
D9:  The determinant of a product of matrices is the product of the determinants.
D10:  The determinant of a matrix is the same as the determinant of its transpose.
D11:  The determinant of a matrix can be computed by expanding cofactors along any row or column of the matrix.
D12:  For any (square) matrix A, |A| adj(A) = adj(A) |A| = |A| I
D13:  If |A| is not 0, then the inverse of A is given by  Inv(A) = (1/|A|) adj(A).
D14:  (Cramer's Rule)  If |A| is not 0, then the unique solution to A . x  = b is given by xj = |Aj| / |A|, where  |Aj|  is the determinant of the matrix obtained from A by replacing the jth column of A by b.

Here are some examples to verify some of the laws D1-D11...

a = {{ 1, 2},{-3 ,4 }}

b = {{1 ,2 },{2 ,3 }}

Det[a]

Det[b]

Det[a+b]

Det[{{1,2,3},{0,4,5},{0,0,6}}]

Adjoints, Inverses, and Solution of Linear Systems

Now for some illustrations of D12-D13:

A = {{1,3,2},{2,1,1},{1,0,1}}

Just in case you prefer a more “matrix-like”  appearance in the output, activate this cell:

MatrixForm[A]

O.K., now let's get down to business.  Eyeball the last output and fill in the matrix of cofactors of A (yes, there is a way to do it in Mathematica, but  I want you to figure it out).

MinA = {{  ,  ,  }, {  ,  ,  }, {  ,  ,  }}

All you have to do to convert the matrix of minors into the matrix of cofactors  is to overlay the entries of M(A) with a “checkerboard” of +/- 's.  So do the following:

plusminus = {{1,-1,1},{-1,1,-1},{1,-1,1}}

Now  to do the overlaying, multiply corresponding entries of the matrix plusminus and A by doing the following (which, by the way, is why * won't give real matrix multiplication):

Acof = plusminus * MinA

Do the following cell:

adjA = Transpose[Acof]

Now for the magic... Activate the following:

A . adjA

adjA . A

detA = Det[A]

This can't be a coincidence.  It isn't  !!!
Test this out::

Inverse[A]

(1/Det[A]) adjA

We have already seen a special case of D13, namely the 2×2 case.  For consider the matrix below and its inverse:

m = {{a,b},{c,d}}

MatrixForm[m]

Invm = Inverse[m]

MatrixForm[Invm]

One final fact::  we now have an explicit formula for the unique solution x of A x = b, namely, from the formula x = Inv(A) b  and D14, we get (in the case |A| is  not 0) that
 
                                     x  =  (1 / |A| ) adj(A) b.
                                     
  If we were to pick this expression apart for each coordinate of x we would arrive at the famous  Cramer's Rule (D14).

Determinant Solutions  v s. Gaussian eliminations

The truth of the matter is that Cramer's Rule and adjoints are only good for small matrices and theoretical arguments.  For if you evaluate determinants in a straightforward way from the definition, the work in doing so is about  n! flops for an n×n system.  This is vast compared to the number n3  flops  required for Gaussian elimination.  (If you haven't seen the term before, a “flop” in numerical linear algebra is a single addition or subtraction, together with a single multiplication or division, and a bit of index fiddling.  One rounds up if only one operation is present.  For example, it is not hard to show that the operation of adding a multiple of one row vector of length n to another requires  n flops.)
 
    On the other hand, there is a sneaky way to evaluate determinants that is much less work than the definition:  use elementary row operations together with D2 , D6 and the elementary operations that correspond to these rules to reduce the determinant to that of a triangular matrix.  This will only require about  n3 /3 flops.   As a matter of fact, it is tantamount to Gaussian elimination.  But to use Cramer's Rule, you will have to calculate (n + 1) determinants.   So why bother with Cramer's Rule on larger problems  when it still will take about n times as much work as Gaussian elimination?  A similar remark applies to computing adjoints instead of using Gauss -Jordan elimination on the super-augmented matrix of A.
 In case you're not convinced, try the following:  let's make Mathematica do a reasonable problem.  First we will simulate Cramer's Rule on a 10×10 by doing 11 determinants.  Then we compare to a direct LinearSolve.  Incidentally, Mathematica really uses elementary row operations to compute a determinant.  One could make a definition that does determinants from definition by recursion. It would take much longer than the built-in function Det of Mathematica.   In each of the timing cells  below, be sure to click on each cell twice.  You will get different numbers.  This has to do with having or not having data and programs in memory.

a = Table[i+j,{i,10},{j,10}]

b = Table[1,{i,10}]

11 * Timing[Det[a]]

Timing[LinearSolve[a,b]]

Exercises

For the following exercises, use the matrices :

1   3    0    5    4               2     2    0     -5   7
         0   8    3    -5   2               1     9    6     -3   8
A =   5   -5   2    -1   0      B =    8    -7   0     2    1 
         2   1    -4   7    9               4     -6   -2    1   7 
         6   -8   0    1    0               5     0    -9    9    0

Evaluate :
    Det A
    Det B
    Det (A + B)
    Det (2 A)       Write this in terms of Det (A) and verify using Mathematica.
    Det (A3)        Write this in terms of Det (A) and verify using Mathematica.
    Det (A B)