Python – scipy.linalg.det

ScipyScientific ComputingProgramming

The scipy.linalg package contains a set of different functionalities that are used for Linear Algebra. One of them is the det() function. This function is used to find the determinant of a two-dimensional matrix.

Syntax

scipy.linalg.det(x)

Where x is a square matrix.

Example 1

Let us consider the following example −

# Importing the required libraries
from scipy import linalg
import numpy as np

# Initialize the matrix A
A = np.array([[8, 5], [3, 4]])
print("Input Matrix :\n", A)

# Find the determinant of matrix X
x = linalg.det(A)
print("Determinant Value of A:", x)

Output

It will generate the following output −

Input Matrix :
[[8 5]
[3 4]]
Determinant Value of A: 17.0

Example 2

Let us consider the following example −

# Importing the required libraries
from scipy import linalg
import numpy as np

# Initializing the matrix M
M = np.arange(6, 10).reshape(2, 2)
print("Input Matrix :\n", M)

# Finding the determinant of matrix X
x = linalg.det(M)
print("Determinant Value of M:", x)

Output

The above program will generate the following output −

Input Matrix :
[[6 7]
[8 9]]
Determinant Value of M: -2.0000000000000053
raja
Updated on 22-Dec-2021 09:59:56

Advertisements