What a matrix inverse is
The inverse of a square matrix A is the matrix A⁻¹ that satisfies A·A⁻¹ = A⁻¹·A = I, where I is the identity matrix. It is the matrix equivalent of a reciprocal, and it is what lets you solve Ax = b as x = A⁻¹b.
Not every matrix has one. If the determinant is zero the matrix is singular, meaning the linear transformation collapses space into a lower dimension — and a collapse cannot be undone.
- Determinant ≠ 0 — the inverse exists and is unique.
- Determinant = 0 — no inverse; the rows are linearly dependent.
- Determinant near 0 — the inverse exists but is numerically fragile; small input errors become large output errors.
The 2×2 shortcut
For a 2×2 matrix there is a closed form worth memorising:
A⁻¹ = 1/(ad − bc) · [[d, −b], [−c, a]]
Swap the diagonal entries, negate the off-diagonal ones, and divide by the determinant ad − bc. For A = [[4, 7], [2, 6]] the determinant is 24 − 14 = 10, so the inverse is [[0.6, −0.7], [−0.2, 0.4]].
Larger matrices have no such compact formula in practice. Cramer's rule exists but requires one determinant per entry, which is far more work than elimination.
Gauss-Jordan elimination
The standard algorithm augments A with the identity matrix and applies row operations until the left block becomes I. Whatever ends up on the right is A⁻¹.
- Write [A | I] side by side.
- For each column, pick the row with the largest absolute value in that column (partial pivoting) and swap it into position.
- Scale the pivot row so the pivot becomes 1.
- Eliminate that column from every other row.
- Repeat for the next column; the right-hand block is now A⁻¹.
Why pivot at all? Choosing the largest available pivot keeps the multipliers below 1 and stops rounding errors from being amplified. Without it, some perfectly invertible matrices produce garbage in floating point.
Worked example
Take A = [[4, 7], [2, 6]]. Augment to [4 7 | 1 0; 2 6 | 0 1]. Scale row 1 by 1/4 to get [1 1.75 | 0.25 0]. Eliminate: row 2 becomes [0 2.5 | −0.5 1]. Scale row 2 by 0.4: [0 1 | −0.2 0.4]. Back-substitute into row 1: [1 0 | 0.6 −0.7].
So A⁻¹ = [[0.6, −0.7], [−0.2, 0.4]], and the determinant is the product of the pivots: 4 × 2.5 = 10. The verification line reports the largest deviation of A·A⁻¹ from the identity, which should be around 10⁻¹⁶.
Where matrix inverses are used
- Solving linear systems — x = A⁻¹b, though in practice elimination is preferred for a single right-hand side.
- Computer graphics — the inverse of a transform matrix undoes a rotation, scale or translation.
- Statistics — regression coefficients are (XᵀX)⁻¹Xᵀy, and the inverse of the covariance matrix appears in every multivariate method.
- Control theory — state feedback and observability tests both require matrix inverses.
- Cryptography — Hill ciphers decrypt by multiplying by the modular inverse of a key matrix.
Determinant, singularity and conditioning
The determinant is the volume scale factor of the transformation. A determinant of 3 triples every area; a determinant of 0.5 halves it; a determinant of zero collapses the plane onto a line or a point, and that collapse cannot be undone.
Near-singular is a different problem from singular. A matrix with a determinant of 1e-8 is technically invertible, but the inverse will have entries around 1e8 and any rounding error in the input is magnified by the same factor. The condition number measures exactly this amplification.
| |det| | Condition | Practical consequence |
|---|---|---|
| Large (≫ 1) | Well conditioned | Inverse is stable and small |
| Near 1 | Ideal | Inverse is numerically clean |
| Small (≪ 1) | Ill conditioned | Inverse is large and sensitive |
| Exactly 0 | Singular | No inverse exists |
Never solve a system by inverting. Computing A⁻¹b is slower and less accurate than LU decomposition with partial pivoting. The inverse is for analysis; the solve is for computation.
Using the inverse to solve Ax = b
The reason matrix inverses matter is that they solve linear systems. If A is invertible, the unique solution of Ax = b is x = A⁻¹b, and that is true for any number of right-hand sides at once.
| det(A) | System | Solutions |
|---|---|---|
| Non-zero | Ax = b | Exactly one |
| Zero | Ax = b, b in the range | Infinitely many |
| Zero | Ax = b, b outside the range | None |
This is the linear-algebra version of the one-to-one test. A non-zero determinant means the transformation is injective and surjective at once, so every target has exactly one preimage — which is precisely what an inverse requires.
The tool verifies its own answer by multiplying A by the computed inverse and reporting the largest deviation from the identity. For a well-conditioned matrix that figure is around 1e-16; for a nearly singular one it grows, which is a warning rather than a bug.
Beyond 2×2: what changes
The 2×2 case has a closed form that fits on a line. Larger matrices do not, and every practical method is a systematic elimination rather than a formula.
| Size | Method | Operations (order) |
|---|---|---|
| 2×2 | Closed form | A handful |
| 3×3 | Cofactors or elimination | ≈ 10² |
| 4×4 | Gauss-Jordan | ≈ 10³ |
| 100×100 | LU decomposition | ≈ 10⁶ |
| 1000×1000 | Blocked LU, parallel | ≈ 10⁹ |
The cubic growth is why nobody inverts a large matrix unless they have to. Solving Ax = b directly costs about a third as much and produces a more accurate answer, because the intermediate quantities stay smaller.
The 3×3 case is worth knowing by hand. The determinant is a sum of six signed products, and the inverse is the transpose of the cofactor matrix divided by that determinant — a formula short enough to memorise and reliable enough to use.
Above 4×4, elimination is the only sane route, and the tool caps at 4 for that reason: the input grid would become unusable before the arithmetic became interesting.
Why the identity is the target
The inverse is defined by A·A⁻¹ = I, so the identity matrix is the only correct answer to check against. Every method — the 2×2 formula, cofactors, Gauss-Jordan — is just a different route to the same product.
The tool prints the largest deviation from the identity as a diagnostic. A value near 1e-16 means exact arithmetic up to rounding; a value near 1e-6 means the matrix is nearly singular and the inverse should not be trusted for anything important.
Frequently asked questions
How do I know whether a matrix has an inverse?
Compute the determinant. If it is zero the matrix is singular and no inverse exists; this calculator reports that case explicitly rather than returning an error code.
What is the inverse of a 2×2 matrix?
1/(ad − bc) times [[d, −b], [−c, a]]. Swap the diagonal, negate the off-diagonal, divide by the determinant.
Why is my inverse inaccurate?
Near-singular matrices amplify rounding error. If the determinant is very small relative to the entries, the inverse is mathematically valid but numerically unreliable.
Can I invert a non-square matrix?
Not in the ordinary sense. Non-square matrices may have a left or right pseudo-inverse, which solves a least-squares problem instead.
Is A⁻¹ the same as 1/A?
For scalars yes, but matrices have no division. A⁻¹ means the matrix that multiplies A to give the identity, and it must be computed, not divided.
What does the verification line tell me?
It reports the largest absolute difference between A·A⁻¹ and the identity matrix. A value near 10⁻¹⁵ means the result is correct to machine precision.