Choosing a Method for the Matrix Size
The determinant definition leads to several calculation methods. Direct formulas cover small matrices. For a large dense matrix, elimination or an factorization reduces the matrix to triangular form and avoids the factorial growth of recursive cofactor expansion.
Basic Case of a First Order Matrix
For matrices of size , the determinant is very simple. If with , then:
For a matrix, the determinant is its only entry. Determinants of larger matrices are reduced to smaller cases through expansion or elimination.
Submatrix Concept
Before discussing the cofactor expansion method, we need to understand the concept of submatrix. For matrix and indices , submatrix is a matrix of size obtained by removing row and column from matrix .
Look at an example for a matrix. Suppose we have:
To get submatrix , we remove row and column :
For submatrix , we remove row and column :
This process applies to all combinations of rows and columns that are removed.
Cofactor Expansion
Cofactor expansion computes the determinant from smaller minors. We may expand along any fixed row :
Alternatively, we may expand along any fixed column :
The term is the cofactor of . The factor creates the alternating checkerboard pattern of signs. Choosing a row or column with many zeros reduces the number of minors we need to evaluate.
Cofactor Expansion for a Third Order Matrix
Look at an example of cofactor expansion for a matrix:
We choose the first row for expansion:
The expansion may use any row or column. Every zero entry makes one cofactor term zero, so a row or column with many zeros leaves fewer terms to calculate.
Triangular and Diagonal Matrices
For some special types of matrices, determinant calculation becomes very simple. The shape of the matrix removes most of the terms before you expand anything, so the work shrinks to a single product. Recognizing the shape first is what saves the effort.
For upper triangular matrix :
Its determinant is:
For lower triangular matrix :
Its determinant is:
For diagonal matrix :
Its determinant is:
For all three types of matrices, the determinant equals the product of all main diagonal elements.
Elementary Matrices
Elementary matrices are matrices obtained from the identity matrix with one elementary row operation. The determinants of elementary matrices have values that are easy to calculate:
-
Row-scaling matrix , with , that multiplies row by :
-
Row-swap matrix that swaps rows and :
-
Transvection matrix that performs :
For swaps and transvections, the indices refer to two distinct rows, so . A single row swap changes the sign of the determinant, while adding a multiple of one row to another leaves the determinant unchanged.
Gaussian Elimination for Determinant Calculation
Gaussian elimination, or equivalently an factorization, transforms a dense matrix into upper triangular form. The determinant then follows from the diagonal entries and the recorded row operations.
Suppose we use only row additions and row swaps to transform into an upper triangular matrix . If there are row swaps, then:
Since is an upper triangular matrix:
The calculation gives:
If an algorithm scales a row during elimination, that scale factor must also be recorded and removed from the final product. In numerical computation, partial pivoting is normally used to avoid a zero pivot and reduce the effect of roundoff errors.
Operation Count
For a dense matrix, the elimination or factorization requires about floating-point operations. Multiplying the resulting diagonal entries requires only additional work. A naive recursive cofactor expansion can grow like .
For a large unstructured matrix, the cubic operation count of elimination is lower than the factorial growth of recursive cofactor expansion.
Computing a Third Order Determinant by Elimination
The following example computes a determinant with Gaussian elimination:
Step 1: Swap rows and to get a nonzero pivot:
Step 2: Eliminate the first column by subtracting times row from row :
Step 3: Eliminate the second column by subtracting times row from row :
Since there is one row swap ():