Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DOC: Update documentation of np.linalg.det() #27599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions numpy/linalg/_linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2357,6 +2357,12 @@ def det(a):
The determinant is computed via LU factorization using the LAPACK
routine ``z/dgetrf``.

Due to the limitations of floating-point arithmetic, small numerical
errors may occur when calculating the determinant of a matrix. As a result,
the determinant may return very small non-zero values instead of exactly zero
for singular matrices. To check if a determinant is effectively zero, use
`np.isclose()`.

Examples
--------
The determinant of a 2-D array [[a, b], [c, d]] is ad - bc:
Expand All @@ -2374,6 +2380,13 @@ def det(a):
>>> np.linalg.det(a)
array([-2., -3., -8.])

Checking if the determinant is effectively zero for singular matrices:

>>> a = np.array([[5, 5, 6], [7, 7, 5], [4, 4, 8]])
>>> det = np.linalg.det(a)
>>> np.isclose(det, 0)
True

"""
a = asarray(a)
_assert_stacked_2d(a)
Expand Down
Loading