np.linalg.det()
The determinant is a single number that tells you whether a square matrix can be inverted and how it scales area.
In this page:
Syntax
det = np.linalg.det(matrix)
np.linalg.det()
np.linalg.det computes the determinant of a square matrix. A determinant of zero means the matrix is singular and has no inverse. Floating-point results may show tiny rounding errors, so round when printing.
Note:
For a 2x2 matrix [[a, b], [c, d]] the determinant is a*d - b*c.
Example: np.linalg.det()
import numpy as np
A = np.array([[4, 3], [6, 3]])
print(np.linalg.det(A).round(2))
S = np.array([[1, 2], [2, 4]])
print(np.linalg.det(S).round(2))
# Output:
# -6.0
# 0.0
Related Topics
Common Mistakes
- Calling det on a non-square matrix
- Comparing det == 0 exactly with floats
- Confusing determinant with trace
Chapter Summary
- det works on square matrices
- Zero determinant means singular
- Round float results
- 2x2 formula is ad - bc
🔒
Chapter Quiz — Complete all 6 topics to unlock
0/6 topics done
Complete these topics first: