Matrix Determinant ๐
Contents
Matrix Determinant ๐ #
Write functions that return the determinant of square matrix of orders (\(2\times2\)), (\(3\times3\)), and (\(n\times n\)).
Rules#
Function returns a integer.
You must not use any external function to calculate the determinant.
Useful Links#
Determinant overview#
Order (\(2\times2\))#
In the case of a (\(2\times2\)) matrix the determinant can be defined as
Larger Orders#
Minor of Matrix#
Minor of matrix for a particular element in the matrix is defined as the matrix obtained after deleting the row and column of the matrix in which that particular element lies.
- cuemath
Note
See the Minor of Matrix challenge for more details.
Cofactor of Matrix#
The \((i,j)\) cofactor \(C_{ij}\) is defined in terms of the minor \(M_{i,j}\) by
Determinant using cofactor expansion along the \(i^{\text{th}}\) row#
For a Matrix \(A\) like:
You can use one arbitrary row and the cofactor expansion to get the determinant of \(A\):
For example, if you chose the first row, the determinant is:
Note
You can use any row you want.
Recursive formula#
A recursive formula must have a starting point. For cofactor expansions, the starting point is the case of \(1 \times 1\) matrices.
Consider a \(1 \times 1\) matrix \(A\) like:
Then, the determinant of \(A\) is:
Therefore, to determine the determinant of any square matrix, you can
recursively apply the cofactor expansion
up to the point that all matrix
have a \(1 \times 1\) dimension.