Compute the determinant of a given square array using NumPy in Python Last Updated : 29 Aug, 2020 Comments Improve Suggest changes 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 Numpy 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 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 How to rearrange columns of a 2D NumPy array using given index positions? In this article, we will learn how to rearrange columns of a given numpy array using given index positions. Here the columns are rearranged with the given indexes. For this, we can simply store the columns values in lists and arrange these according to the given index list but this approach is very 2 min read How to get the indices of the sorted array using NumPy in Python? We can get the indices of the sorted elements of a given array with the help of argsort() method. This function is used to perform an indirect sort along the given axis using the algorithm specified by the kind keyword. It returns an array of indices of the same shape as arr that would sort the arra 2 min read Compute the condition number of a given matrix using NumPy In this article, we will use the cond() function of the NumPy package to calculate the condition number of a given matrix. cond() is a function of linear algebra module in NumPy package. Syntax: numpy.linalg.cond(x, p=None) Example 1: Condition Number of 2X2 matrix Python3 # Importing library impor 2 min read Raise a square matrix to the power n in Linear Algebra using NumPy in Python In this article, we will discuss how to raise a square matrix to the power n in the Linear Algebra in Python. The numpy.linalg.matrix_power() method is used to raise a square matrix to the power n. It will take two parameters, The 1st parameter is an input matrix that is created using a NumPy array 3 min read Like