Saturday, October 5, 2024
Google search engine
HomeLanguagesnumpy.linalg.det() Method in Python

numpy.linalg.det() Method in Python

In NumPy, we can compute the determinant of the given square array with the help of numpy.linalg.det(). It will take the given square array as a parameter and return the determinant of that.

Syntax: numpy.linalg.det() 
Parameter: An square array. 
Return: The determinant of that square array.

Example 1:

Python




import numpy as np
from numpy import linalg as LA
 
 
array1 = np.array([[1, 2], [3, 4]])
 
# Original 2-d array
print(array1)
 
# Determinant of the said 2-D array
print(np.linalg.det(array1))


Output:

[[1 2]
 [3 4]]
-2.0000000000000004

Example 2:

Python




import numpy as np
from numpy import linalg as LA
 
 
array1 = np.array([[1, 2, 3], [3, 4, 1], [3, 2, 1]])
 
# Original 2-d array
print(array1)
 
# Determinant of the said 2-D array
print(np.linalg.det(array1))


Output:

[[1 2 3]
 [3 4 1]
 [3 2 1]]
-15.999999999999998
RELATED ARTICLES

Most Popular

Recent Comments