### Navigation

- index
- modules |
- modules |
- next |
- previous |
- NumPy v1.5 Manual (DRAFT) »
- NumPy Reference »
- Routines »
- Linear algebra (`numpy.linalg`) »

# numpy.linalg.inv

`numpy.linalg.``inv`(a)

  Compute the (multiplicative) inverse of a matrix.

  Given a square matrix a, return the matrix ainv satisfying `dot(a, ainv) = dot(ainv, a) = eye(a.shape[0])`.

  Parameters : | a : array_like, shape (M, M) Matrix to be inverted.
  Returns : | ainv : ndarray or matrix, shape (M, M) (Multiplicative) inverse of the matrix a.
  Raises : | LinAlgError : If a is singular or not square.

  Examples

      >>> from numpy import linalg as LA
      >>> a = np.array([[1., 2.], [3., 4.]])
      >>> ainv = LA.inv(a)
      >>> np.allclose(np.dot(a, ainv), np.eye(2))
      True
      >>> np.allclose(np.dot(ainv, a), np.eye(2))
      True

  If a is a matrix object, then the return value is a matrix as well:

      >>> ainv = LA.inv(np.matrix(a))
      >>> ainv
      matrix([[-2. ,  1. ],
              [ 1.5, -0.5]])

### Navigation

- index
- modules |
- modules |
- next |
- previous |
- NumPy v1.5 Manual (DRAFT) »
- NumPy Reference »
- Routines »
- Linear algebra (`numpy.linalg`) »