Compute the inverse of the matrix using numpy. ** Just add I (Inverse acronym) to the matrix object. ** **
Example: Find the inverse of matrix A.
import numpy as np
"""
Inverse matrix of A A^-Ask for 1
calculate the inverse matrix of A
"""
#Generation of matrix A make A
a1_lis = [1, 0, 0]
a2_lis = [0, 2, 0]
a3_lis = [0, 0, 4]
A_matrix=np.matrix([a1_lis, a2_lis, a3_lis])
##
A_inv_matrix=A_matrix.I #Inverse matrix calculation
print(C_matrix)
[[ 3 0 0] [ 2 4 0] [ 4 0 16]]
Also apply as follows.
A_inv_matrix = np.linalg.inv(A_matrix)