numpy.linalg.inv

numpy.linalg.inv(a)

Compute the inverse of a matrix.

Parameters:

a : array_like, shape (M, M)

Matrix to be inverted

Returns:

ainv : ndarray, shape (M, M)

Inverse of the matrix a

Raises:

LinAlgError :

If a is singular or not square.

Examples

>>> a = np.array([[1., 2.], [3., 4.]])
>>> np.linalg.inv(a)
array([[-2. ,  1. ],
       [ 1.5, -0.5]])
>>> np.dot(a, np.linalg.inv(a))
array([[ 1.,  0.],
       [ 0.,  1.]])

Previous topic

numpy.linalg.lstsq

Next topic

numpy.linalg.pinv

This Page

Quick search