The determinant of an n by n matrix will be written as follows
det(A) = |A| = | ![]() |
|
![]() |
The solution is given by the so called "determinant expansion by minors". A minor Mij of the matrix A is the n-1 by n-1 matrix made by the rows and columns of A except the i'th row and the j'th column is not included. So for example M12 for the matrix A above is given below
M12 = | ![]() |
|
![]() |
The determinant is the given by the following where the sum is taken over a single row or column.
|A| = | ![]() |
(-1)i+j | aij | Mij |
Any row or column can be chosen across which to take the sum, when computing manually the row or column with the most zeros is chosen to minimise the amount of work. If the first row is chosen for the sum then the determinant in terms of the minors would be
|A| = a11 | ![]() |
|
![]() |
- a12 | ![]() |
|
![]() |
+ a13 | ![]() |
|
![]() |
. . . . . + a1n | ![]() |
|
![]() |
The process is repreated for each of the determinants above, on each expansion the dimension of the determinant in each term decreases by 1. When the terms are 2 by 2 matrices the determinant is given as
![]() |
|
![]() |
= | a11 a22 | - | a12 a21 |
If the determinant is 0 the matrix said to be "singular". A singular matrix either has izero elements in an entire row or column, or else a row (or column) is a linear combination of other rows (or columns).
C source code example/* Recursive definition of determinate using expansion by minors. */ double Determinant(double **a,int n) { int i,j,j1,j2; double det = 0; double **m = NULL; if (n < 1) { /* Error */ } else if (n == 1) { /* Shouldn't get used */ det = a[0][0]; } else if (n == 2) { det = a[0][0] * a[1][1] - a[1][0] * a[0][1]; } else { det = 0; for (j1=0;j1<n;j1++) { m = malloc((n-1)*sizeof(double *)); for (i=0;i<n-1;i++) m[i] = malloc((n-1)*sizeof(double)); for (i=1;i<n;i++) { j2 = 0; for (j=0;j<n;j++) { if (j == j1) continue; m[i-1][j2] = a[i][j]; j2++; } } det += pow(-1.0,1.0+j1+1.0) * a[0][j1] * Determinant(m,n-1); for (i=0;i<n-1;i++) free(m[i]); free(m); } } return(det); }