The determinant is the most essential concept of linear algebra. It is a scalar value that is calculated from a square matrix. The determinant is a fundamental operation that helps us in the inverse matrix and in solving linear equations. Determinants are only calculated for square matrices. A square matrix has an equal number of rows and columns. The numpy.linalg subpackage provides the det() function for calculating the determinant of a given input matrix. Let's compute the determinant in the following code block:
# Import numpy
import numpy as np
# Create matrix using NumPy
mat=np.mat([[2,4],[5,7]])
print("Matrix:\n",mat)
# Calculate determinant
print("Determinant:",np.linalg.det(mat))
This results in the following output:
Matrix:
[[2 4]
[5 7]]
Determinant: -5.999999999999998
In the preceding code block, we have calculated the determinant of a given matrix using the np.linalg.det() method. Let's understand one more concept of linear algebra, which is...