What an inverse matrix is
The inverse of A is the matrix that undoes it. If A rotates and stretches space, A⁻¹ unrotates and unstretches, and applying them in sequence leaves everything exactly where it started — that is what A·A⁻¹ = I means. The identity matrix I is the do-nothing map, with ones on the diagonal and zeros everywhere else.
Not every matrix has one. If A flattens three dimensions onto a plane, information is gone for good and no matrix can restore it. That collapse is detected by the determinant: A has an inverse if and only if det(A) ≠ 0, and the calculator refuses, with an explanation, when it is zero. A matrix with no inverse is called singular; one with an inverse is invertible or non-singular.
The inverse is what makes matrix algebra feel like ordinary algebra. To solve Ax = b you would like to divide by A, and x = A⁻¹b is as close as matrices get — with one important caveat covered further down, which is that computing the inverse is almost never the right way to solve the system.
Gauss-Jordan: row-reduce [A | I] to [I | A⁻¹]
Write A next to the identity matrix, giving an n×2n array. Now row-reduce the left half to the identity, applying every operation to the whole row so the right half comes along. When the left half becomes I, the right half has become A⁻¹.
The reason is short. Every elementary row operation is itself a matrix multiplication on the left. If a chain of them Ek…E₁ turns A into I, then Ek…E₁A = I, so Ek…E₁ is A⁻¹ — and applying that same chain to I produces exactly that product. You are not doing two calculations; you are recording one.
The calculator uses partial pivoting: at each column it swaps the largest available entry into the pivot position before eliminating. That is not for elegance. Dividing by a pivot much smaller than the entries beneath it amplifies rounding error, and pivoting keeps every multiplier at magnitude one or less.
The adjugate formula, A⁻¹ = adj(A)/det(A), is the other classical route and the one that proves the inverse exists. The adjugate is the transpose of the cofactor matrix: entry (i, j) of adj(A) is (−1)i+j times the minor Mji. For a 2×2 it collapses to the familiar swap-and-negate rule. For a 3×3 it means nine 2×2 determinants, which is tedious but doable; for anything larger it is hopeless, because it needs n² minors of size n−1. The calculator shows the adjugate for matrices up to 3×3 because it makes the fractional structure of the answer visible.
Worked example: inverting [[2, −1, 0], [−1, 2, −1], [0, −1, 2]]
This is the 3×3 second-difference matrix, the discrete version of a second derivative and one of the most common matrices in numerical analysis.
- Determinant first. Expand along the first row: 2 × det[[2,−1],[−1,2]] − (−1) × det[[−1,−1],[0,2]] + 0 = 2(4 − 1) + 1(−2 − 0) = 6 − 2 = 4. Non-zero, so the inverse exists.
- Set up the augmented array. [[2,−1,0 | 1,0,0], [−1,2,−1 | 0,1,0], [0,−1,2 | 0,0,1]].
- Clear column 1. Divide row 1 by 2 to make the pivot 1: [1, −0.5, 0 | 0.5, 0, 0]. Add row 1 to row 2: [0, 1.5, −1 | 0.5, 1, 0]. Row 3 already has a zero there.
- Clear column 2. Divide row 2 by 1.5: [0, 1, −2/3 | 1/3, 2/3, 0]. Add half of it to row 1: [1, 0, −1/3 | 2/3, 1/3, 0]. Add it to row 3: [0, 0, 4/3 | 1/3, 2/3, 1].
- Clear column 3. Multiply row 3 by 3/4: [0, 0, 1 | 0.25, 0.5, 0.75]. Add ⅓ of it to row 1 and ⅔ of it to row 2.
- Read off the right half. A⁻¹ = ¼ × [[3, 2, 1], [2, 4, 2], [1, 2, 3]] = [[0.75, 0.5, 0.25], [0.5, 1, 0.5], [0.25, 0.5, 0.75]].
Check one entry by multiplication: row 1 of A times column 1 of A⁻¹ is 2(0.75) + (−1)(0.5) + 0(0.25) = 1.5 − 0.5 = 1, which is the (1,1) entry of the identity. Row 2 of A times column 1 of A⁻¹ is (−1)(0.75) + 2(0.5) + (−1)(0.25) = −0.75 + 1 − 0.25 = 0. Correct.
The condition number follows from the two row-sum norms: the largest absolute row sum of A is 1 + 2 + 1 = 4 (the middle row), and of A⁻¹ is 0.5 + 1 + 0.5 = 2 (also the middle row), so κ∞ = 4 × 2 = 8. That is a very well-conditioned matrix.
How to read the condition number
The condition number, not the determinant, tells you how trustworthy a solve will be. κ(A) = ‖A‖·‖A⁻¹‖ measures how much a relative error in your data can be amplified in the answer: a relative perturbation of size ε in b can produce a relative change of up to κ·ε in x. The rule of thumb is that you lose about log₁₀(κ) significant digits. With double precision giving you roughly 16 digits, κ = 10⁸ leaves you 8, and κ = 10¹⁶ leaves you none.
The best possible value is κ = 1, achieved by the identity and by any scaled orthogonal matrix. The example above at κ∞ = 8 is excellent. The calculator warns above 10⁶.
Contrast that with the determinant, which is a poor measure of near-singularity because it scales as the n-th power of the entries. Multiply a well-conditioned 4×4 by 0.01 and its determinant falls by 10⁸ while κ does not move at all — the matrix is exactly as invertible as before.
The residual output is your proof. A·A⁻¹ − I should be zero. For an integer matrix with a modest condition number it comes out at 10⁻¹⁶ or exactly zero. A residual around 10⁻⁸ on a matrix you expected to be clean means the elimination lost half its digits, and κ will confirm why.
Inverses of small matrices worth recognising
| Matrix | det | Inverse | κ∞ |
|---|---|---|---|
| [[4,7],[2,6]] | 10 | [[0.6,−0.7],[−0.2,0.4]] | 14.3 |
| [[1,0],[0,1]] | 1 | itself | 1 |
| [[0,1],[1,0]] | −1 | itself | 1 |
| [[2,−1],[−1,2]] | 3 | ⅓[[2,1],[1,2]] | 3 |
| [[2,−1,0],[−1,2,−1],[0,−1,2]] | 4 | ¼[[3,2,1],[2,4,2],[1,2,3]] | 8 |
| diag(a, b) | ab | diag(1/a, 1/b) | max(|a|,|b|)/min(|a|,|b|) |
| [[1,2],[2,4]] | 0 | none — singular | — |
The n×n second-difference matrix has determinant exactly n+1, and its inverse has entries min(i,j)·(n+1−max(i,j))/(n+1) — which is why the 4×4 default above inverts to fifths.
Things that go wrong with inverses
- Inverting to solve a system. Computing A⁻¹ and multiplying costs about three times as much work as solving Ax = b directly by elimination, and it is less accurate. Form the inverse only when you genuinely need the matrix itself.
- Assuming (AB)⁻¹ = A⁻¹B⁻¹. The order reverses: (AB)⁻¹ = B⁻¹A⁻¹. Think of dressing — socks then shoes — and undressing in the opposite order.
- Treating a tiny determinant as the danger signal. It is not; the condition number is. Scaling changes one and not the other.
- Rounding the entries before inverting. On an ill-conditioned matrix, rounding your inputs to four decimals can change the inverse in the first digit. Enter exact fractions where you have them.
- Expecting an inverse for a rectangular matrix. Only square matrices have true inverses. Rectangular ones can have a left or right pseudo-inverse, which solves a least-squares problem rather than an exact one.
- Forgetting that the inverse of an integer matrix is rarely an integer matrix. It is integer exactly when the determinant is ±1, which is why the adjugate table is the more readable form: integer entries over one common denominator.
The inverse is a description, not an algorithm
Numerical analysts have a standing rule: never compute an inverse if what you want is a solution. Solving Ax = b by elimination costs about n³/3 operations; forming A⁻¹ costs about n³ and then multiplying costs another n². The direct solve is also backward-stable, while multiplying by a computed inverse is not. Use the inverse when the matrix itself is the object of interest — a covariance precision matrix, a transformation you need to store and reuse, or a proof — and use elimination when you want an answer.
Related tools and when to reach for them
Check invertibility first with the determinant calculator, which also reports the rank so you can see how far a singular matrix has collapsed. If you have an actual system to solve, go straight to the RREF calculator, which handles the augmented matrix and tells you whether the solution is unique, absent or a family. For a 2×2 or 3×3 system with a non-zero determinant, Cramer's rule gives each unknown as a ratio of determinants.
To verify an inverse by hand, multiply it back with the matrix multiplication calculator and confirm you get the identity — that is exactly the residual this page reports. If you need repeated solves with the same matrix and different right-hand sides, an LU decomposition is the professional answer: factor once, then each new solve costs only n² instead of n³.
The condition number is a spectral quantity in disguise. In the 2-norm it is the ratio of the largest to the smallest singular value, and for a symmetric matrix that is the ratio of the largest to the smallest absolute eigenvalue — which is why a matrix with an eigenvalue near zero is close to singular.
