Python Numpy.linalg.inv() - Inverse Matrix
Numpy.linalg.inv() computes the inverse of the given matrix. Syntax of numpy.linalg.inv() numpy.linalg.inverse(arr) Parameters arr input array Return It returns the inverse of the given matrix. It raises the error if the given matrix is not square or inversion fails. Example Codes: numpy.linalg.inv() Method import numpy as np arr = np.array([[1, 3], [5, 7]]) arr_inv = np.linalg.inv(arr) print(arr_inv) Output: [[-0.875 0.375] [ 0.625 -0.125]] Example Codes: numpy.linalg.inv() Method With matrix Input If the given input is a numpy matrix, then inv() also returns a matrix.