TL;DR
A matrix is a rule that moves vectors around. Its inverse, written , is the rule that moves them back. Multiplying by and then by (in either order) leaves every vector unchanged, and that identity action is written . A square matrix has an inverse exactly when its determinant is not zero.
The inverse is the matrix version of dividing by a number. It is the cleanest way to write the solution of a linear system: if , then . Where you'll see it: in solving equations for fitted models, in changing coordinates in graphics and robotics, and in the covariance formulas of multivariate statistics.
Intuition
Think of a matrix as a machine that takes a point and returns a new point. Rotating every point by 30 degrees is a machine. To undo it, rotate by minus 30 degrees. That second machine is the inverse. Stretching the horizontal direction by 2 is undone by shrinking it by one half. Shearing a shape sideways is undone by shearing it back.
Some machines cannot be undone. If a matrix squashes the plane onto a line, then every line of points running along the squashed direction lands on a single spot. Once two different inputs give the same output, no rule can recover the input from the output. The determinant is the test for this: a zero determinant means area has been squashed to zero, so the map has lost information.
Why care? Equations of the form ask: which input does the machine turn into ? If the machine can be undone, the answer is , one step, for any . The inverse turns "solve this equation" into "apply that machine".
- original square corners
- after the stretch by 2
The math
Definition
Let be an matrix and let be the identity matrix, which has ones on the diagonal and zeros elsewhere. The matrix is invertible (or nonsingular) if there is a matrix such that
If no such matrix exists, is singular.
Both products must equal . For square matrices, one of them implies the other, but the definition states both. The inverse is unique: if two matrices both undo , they are equal.
When the inverse exists
A square matrix is invertible if and only if its determinant is nonzero:
Equivalently, the columns of are linearly independent: none of them is a combination of the others. A zero determinant means some direction has been collapsed.
The 2 by 2 formula
For a matrix with ,
Swap the diagonal entries, negate the off-diagonal ones, and divide by the determinant. You can check it by multiplying out: the product is .
Rules that follow from the definition
- . The order reverses, just as when you undo a sequence of steps: undo the last one first.
- .
- .
- .
Gauss-Jordan elimination
For larger matrices, write the augmented block and apply row operations (swap rows, scale a row, add a multiple of one row to another) until the left block becomes . The right block is then . If you reach a row of zeros on the left, is singular.
Solving linear systems
If is invertible, the system has exactly one solution:
Multiply both sides by on the left. The left side becomes because .
Worked examples
Let .
- Determinant: . It is nonzero, so the inverse exists.
- Apply the formula: .
- Check the top-left entry of : .
- Check the top-right entry: .
- Check the bottom row: and .
So . Interpretation: is the exact undo of the machine , and it can be used on any input.
Solve and . In matrix form this is with from the previous example and .
- The inverse is from the previous example.
- Compute .
- Check the first equation: . ✓
- Check the second equation: . ✓
Interpretation: and . If a new right-hand side arrives, say , the same gives the new answer with one multiplication. This reuse is the main reason to know the inverse.
Let .
- Determinant: . So has no inverse.
- Look at the system , that is and .
- The first equation is twice the second, so must equal . The system asks for it to equal 1.
- The two equations contradict each other, so there is no solution.
Interpretation: the second column of is twice the first, so maps the plane onto a line. Outputs off that line are unreachable, and the inverse cannot exist.
Tradeoffs and failure modes
| Situation | What goes wrong | Better choice |
|---|---|---|
| Solving for one | Forming costs more and loses accuracy | Solve directly, for example with an LU factorization |
| Determinant is tiny but not zero | Rounding errors are amplified and the answer can be wrong | Check the condition number; use a better-conditioned formulation |
| Matrix is not square | No inverse exists | Use the Moore-Penrose pseudoinverse for least-squares problems |
| Matrix is triangular | Nothing special, but the inverse is easy | Use back substitution |
| Matrix is nearly singular in a fitting problem | Estimates blow up | Add a small penalty term, as in ridge regression |
| Deciding "is it singular?" from floating-point numbers | A determinant that should be zero comes out as | Use the rank, computed from a singular value decomposition |
The most common mistake is computing an inverse when a solve is enough. Numerical libraries expose a direct solver for , and it is both faster and more accurate. Use the explicit inverse for theory and for small matrices where you need the formula itself.
History
Gaussian elimination, the row-reduction method at the heart of computing inverses, appears in Chinese mathematical texts such as The Nine Chapters on the Mathematical Art, compiled in the first centuries CE. Carl Friedrich Gauss later used the elimination method in his work on least squares, in the early 1800s. Arthur Cayley's 1858 memoir on matrices defined matrix multiplication and the inverse in the modern way. The name Gauss-Jordan elimination, the variant that continues reducing until the left block is the identity, credits Wilhelm Jordan, who described it in his 1888 handbook of geodesy. The pseudoinverse for non-square matrices was introduced by E. H. Moore in 1920 and rediscovered by Roger Penrose in 1955. The inverse caught on because it turns a whole family of linear problems into one reusable operation.
Check yourself
QuestionFor which matrices is the inverse guaranteed not to exist?Show answer
Exactly those whose determinant equals zero. Then the columns are parallel or one of them is zero, and the map squashes the plane onto a line.
QuestionCompute the determinant of and then its inverse.Show answer
The determinant is . The inverse is . Check the top-left entry of the product: .
QuestionWhy does equal and not ?Show answer
Think of as doing first and then . To undo it you must undo the last step first, which is , and then undo . That order is the product . Check it directly: .
QuestionA matrix has determinant . What is ?Show answer
. Scaling area by in one step is undone by scaling by .
QuestionA least-squares fit of a model with two parameters needs to invert the matrix built from the data, and its determinant is even though the data values are of order 1. Why might a direct inverse be a poor idea?Show answer
The determinant is so close to zero relative to the entries that the inverse has entries of large size, and rounding errors in the data get multiplied by those entries. The parameter estimates can become unstable. Solve with a numerically stable method, check the condition number, or add a small penalty term so the matrix is well away from singular.