Calculating the Inverse of a Matrix

The scipy.linalg.inv is used to find the inverse of a matrix.

Syntax: scipy.linalg.inv(a , overwrite_a , check_finite)

Parameters:

  • a: It is a square matrix.
  • overwrite_a (Optional): Discard data in the square matrix.
  • check_finite (Optional): It checks whether the input matrix contains only finite numbers.

Returns:

  • scipy.linalg.inv returns the inverse of the square matrix.

Consider an example where an input x is taken by the function scipy.linalg.inv. This input is the square matrix. It returns y, which is the inverse of the matrix x. Let the matrix be –

Python




# Import the required libraries
from scipy import linalg
import numpy as np
  
# Initializing the matrix
x = np.array([[7, 2], [4, 5]])
  
# Finding the inverse of
# matrix x
y = linalg.inv(x)
print(y)


Output:

[[ 0.18518519 -0.07407407]
 [-0.14814815  0.25925926]]

SciPy Linear Algebra – SciPy Linalg

The SciPy package includes the features of the NumPy package in Python. It uses NumPy arrays as the fundamental data structure. It has all the features included in the linear algebra of the NumPy module and some extended functionality. It consists of a linalg submodule, and there is an overlap in the functionality provided by the SciPy and NumPy submodules.

Let’s discuss some methods provided by the module and its functionality with some examples.

Similar Reads

Solving the linear equations

The linalg.solve function is used to solve the given linear equations. It is used to evaluate the equations automatically and find the values of the unknown variables....

Calculating the Inverse of a Matrix

...

Calculating the Pseudo Inverse of a Matrix

The scipy.linalg.inv is used to find the inverse of a matrix....

Finding the Determinant of a Matrix

...

Singular Value Decomposition

To evaluate the (Moore-Penrose) pseudo-inverse of a matrix, scipy.linalg.pinv is used....

Eigenvalues and EigenVectors

...

Calculating the norm

The determinant of a square matrix is a value derived arithmetically from the coefficients of the matrix. In the linalg module, we use the linalg.det() function to find the determinant of a matrix....

More Matrix Functions

...