 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Compute the determinant of an array in linear algebra in Python
To Compute the determinant of an array in linear algebra, use the np.linalg.det() in Python Numpy. The 1st parameter, a is the input array to compute determinants for. The method returns the determinant.
Steps
At first, import the required libraries -
import numpy as np
Create an array −
arr = np.array([[ 5, 10], [12, 18]])
Display the array −
print("Our Array...\n",arr) Check the Dimensions −
print("\nDimensions of our Array...\n",arr.ndim) Get the Datatype −
print("\nDatatype of our Array object...\n",arr.dtype) Get the Shape −
print("\nShape of our Array object...\n",arr.shape) To Compute the determinant of an array in linear algebra, use the np.linalg.det() in Python Numpy −
print("\nResult (determinant)...\n",np.linalg.det(arr))  Example
import numpy as np # Create an array arr = np.array([[ 5, 10], [12, 18]]) # Display the array print("Our Array...\n",arr) # Check the Dimensions print("\nDimensions of our Array...\n",arr.ndim) # Get the Datatype print("\nDatatype of our Array object...\n",arr.dtype) # Get the Shape print("\nShape of our Array object...\n",arr.shape) # To Compute the determinant of an array in linear algebra, use the np.linalg.det() in Python Numpy. print("\nResult (determinant)...\n",np.linalg.det(arr)) Output
Our Array... [[ 5 10] [12 18]] Dimensions of our Array... 2 Datatype of our Array object... int64 Shape of our Array object... (2, 2) Result (determinant)... -30.000000000000014
Advertisements
 