linalg.inv
Description
Compute the (multiplicative) inverse of a matrix.
Given a square matrix a, it returns the matrix ainv satisfying dot(a, ainv) = dot(ainv, a) = eye(a.shape[0]).
Mandatory Input Parameters
Parameter |
Type |
Description |
|---|---|---|
a |
array_like |
Matrix to be inverted |
Optional Input Parameters
None
Return Value
Type |
Description |
|---|---|
ndarray/matrix |
The inverse of the matrix is returned. |
Examples
>>> import numpy as np
>>> a = np.array([[1.,2.], [3.,4.]])
>>> a
array([[1., 2.],
[3., 4.]])
>>> ainv = np.linalg.inv(a)
>>> ainv
array([[-2. , 1. ],
[ 1.5, -0.5]])
>>>
>>> t = np.dot(a, ainv)
>>> t
array([[1.0000000e+00, 0.0000000e+00],
[8.8817842e-16, 1.0000000e+00]])
>>> np.allclose(t, np.eye(2))
True
>>>
Parent topic: Linear Algebra Functions