Overview:
-
The NumPy function det() from the linalg module finds the determinant of a given matrix using the LU decomposition or the LU factorization method.
-
Using LU decomposition the determinant of a matrix can be found by factoring the matrix A into a lower triangular matrix and upper triangular matrix and taking the product of the diagonal elements of both the matrices.
- The determinant is only defined for square matrices which are singular. i.e.,square matrices that have an inverse.
Example:
# Example Python program that finds the determinant # Create a square matrix of order 3x3 # Make the matrix non-singular determinant = numpy.linalg.det(matrix) print("Matrix:") print("Determinant of the matrix:") |
Output:
Matrix: [[-4 -3 -2] [-1 1 1] [ 2 3 4]] Determinant of the matrix: -12.0 |