Code Explanation:
1. Import the det function:
from scipy.linalg import det
The det function computes the determinant of a square matrix.
It is part of the scipy.linalg module, which provides linear algebra routines.
2. Define the matrix:
matrix = [[1, 2], [3, 4]]
matrix is a 2x2 list of lists representing the matrix:
3. Compute the determinant:
result = det(matrix)
The determinant of a 2x2 matrix is calculated using the formula:
det=(1⋅4)−(2⋅3)=4−6=−2
4. Print the result:
print(result)
This outputs the determinant of the matrix.
Final Output:
-2.0
0 Comments:
Post a Comment