Compute the determinant of a given square array using NumPy in Python Last Updated : 29 Aug, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report In Python, the determinant of a square array can be easily calculated using the NumPy package. This package is used to perform mathematical calculations on single and multi-dimensional arrays. numpy.linalg is an important module of NumPy package which is used for linear algebra. We can use det() function of numpy.linalg module to find out the determinant of a square array. Syntax: numpy.linalg.det(array) Parameters: array(…, M, M) array_like: Input array to calculate determinants for. Returns: det(…) array_like: Determinant of array. Example 1: Determinant of 2X2 matrix. Python3 # Importing libraries import numpy as np from numpy import linalg # Creating a 2X2 matrix matrix = np.array([[1, 0], [3, 6]]) print("Original 2-D matrix") print(matrix) # Output print("Determinant of the 2-D matrix:") print(np.linalg.det(matrix)) Output: Original 2-D matrix [[1 0] [3 6]] Determinant of the 2-D matrix: 6.0 Example 2: Determinant of 3X3 matrix Python3 # Importing libraries import numpy as np from numpy import linalg # Creating a 3X3 matrix matrix = np.array([[1, 0, 1], [1, 2, 0], [4, 6, 2]]) print("Original 3-D matrix") print(matrix) # Output print("Determinant of the 3-D matrix:") print(np.linalg.det(matrix)) Output: Original 3-D matrix [[1 0 1] [1 2 0] [4 6 2]] Determinant of the 3-D matrix: 2.0 Example 3: Determinant of 4X4 matrix Python3 # Importing libraries import numpy as np from numpy import linalg # Creating a 4X4 matrix matrix = np.array([[1, 0, 1, 8], [1, 2, 0, 3], [4, 6, 2, 6], [0, 3, 6, 4]]) print("Original 4-D matrix") print(matrix) # Output print("Determinant of the 4-D matrix:") print(np.linalg.det(matrix)) Output: Original 4-D matrix [[1 0 1 8] [1 2 0 3] [4 6 2 6] [0 3 6 4]] Determinant of the 4-D matrix: 188.0 Comment More infoAdvertise with us Next Article Compute the determinant of a given square array using NumPy in Python G geekmonkey Follow Improve Article Tags : Python Python-numpy Python numpy-Linear Algebra Practice Tags : python Similar Reads How to compute the eigenvalues and right eigenvectors of a given square array using NumPY? In this article, we will discuss how to compute the eigenvalues and right eigenvectors of a given square array using NumPy library. Example: Suppose we have a matrix as: [[1,2], [2,3]] Eigenvalue we get from this matrix or square array is: [-0.23606798 4.23606798] Eigenvectors of this matrix are 2 min read Compute the factor of a given array by Singular Value Decomposition using NumPy Singular Value Decomposition means when arr is a 2D array, it is factorized as u and vh, where u and vh are 2D unitary arrays and s is a 1D array of aâs singular values. numpy.linalg.svd() function is used to compute the factor of an array by Singular Value Decomposition. Syntax : numpy.linalg.svd(a 2 min read Compute the sign and natural logarithm of the determinant of an array in Python In this article, we will cover how to compute the sign and natural logarithm of the determinant of an array in Python using NumPy. numpy.linalg.slogdet() method The numpy.linalg.slogdet() method provides us to compute the sign and natural logarithm of the determinant of an array in Python. A call to 3 min read How to Calculate the determinant of a matrix using NumPy? The determinant of a square matrix is a special number that helps determine whether the matrix is invertible and how it transforms space. It is widely used in linear algebra, geometry and solving equations. NumPy provides built-in functions to easily compute the determinant of a matrix, let's explor 2 min read Compute the inner product of vectors for 1-D arrays using NumPy in Python Python has a popular package called NumPy which used to perform complex calculations on 1-D and multi-dimensional arrays. To find the inner product of two arrays, we can use the inner() function of the NumPy package. Syntax: numpy.inner(array1, array2) Parameters: array1, array2: arrays to be evalu 2 min read Like