To write a small piece of code for finding determinant and Inverse matrix using python scipy library.
2 dimensional array.
Define a sample array.
Import linear algebra attributes from scipy.
Pass to the det() constructor.
Finds the determinant of an two dimensional array.
from scipy import linalg
import numpy as np
#define a 2-dimensional array
sample_array = np.array([[1,2],[3,4]])
#pass values to det() function
print(“Determinant of array”)
d = linalg.det(sample_array)
print(d,”\n”)
#Inverse matrix of array
print(“Inverse matrix of array”)
I = linalg.inv(sample_array)
print(I)