The Matrix Inverse
The inverse undoes a matrix's action, but it exists only for square, full-rank matrices and is rarely computed explicitly.
Definition
The inverse of a square matrix A is the matrix A^{-1} satisfying A A^{-1} = A^{-1} A = I. When it exists, A is called invertible or nonsingular, and the inverse is unique. A square matrix fails to be invertible exactly when its determinant is zero, equivalently when its columns are linearly dependent or its rank is less than its dimension.
Properties
- (A^{-1})^{-1} = A
- (AB)^{-1} = B^{-1} A^{-1}, order reversed
- (A^T)^{-1} = (A^{-1})^T
- (cA)^{-1} = (1/c) A^{-1} for nonzero scalar c
The 2-by-2 formula
For a 2-by-2 matrix with entries a, b, c, d, the inverse is 1/(ad - bc) times the matrix [[d, -b], [-c, a]]. The quantity ad - bc is the determinant; when it is zero, no inverse exists. Larger matrices have no such simple closed form, and the general adjugate formula is far too slow for computation.
Do not invert to solve
To solve Ax = b, computing A^{-1} and then multiplying is both slower and less accurate than solving the system directly with LU factorization. Explicit inversion is needed only when the inverse itself is the object of interest, for example a covariance matrix. As the saying in numerical computing goes, never form an inverse when a solve will do.
import numpy as np
A = np.array([[2.0, 1.0], [1.0, 3.0]])
b = np.array([1.0, 2.0])
x = np.linalg.solve(A, b) # preferred
# x_slow = np.linalg.inv(A) @ b # avoid
print(x)
In simulations, operator matrices from discretized physics are large and sparse; their inverses are dense and impractical to store, so engineers rely on factorizations and iterative solvers instead.