You solve a system of equations using an inverse matrix by writing the system as AX = B, checking that A is square with a nonzero determinant, then computing X = A⁻¹B. This works only when the coefficient matrix is invertible; singular or near-singular systems require elimination methods or a least-squares fallback instead.
This approach is compact, exact on paper, and dangerously misleading in floating-point software. The same formula that gives a clean integer answer for a 3×3 textbook problem can silently destroy a real 100×100 model.
The mechanism: why A⁻¹B reproduces the solution
Write your system as a matrix equation. Each row of A holds one equation's coefficients, X is the column of unknowns, and B is the column of constants. So 2x + 3y = 7 and x − y = 1 become A = [[2, 3], [1, −1]], X = [x, y]ᵀ, B = [7, 1]ᵀ.
Now multiply both sides by A⁻¹ on the left. A⁻¹AX = A⁻¹B collapses to X = A⁻¹B because A⁻¹A is the identity matrix. The unknowns fall out directly.
The inverse exists only when det(A) ≠ 0. The determinant measures how much the linear map scales volume. A zero determinant means the map squashes space onto a lower dimension, so distinct inputs collapse to the same output. In equation terms, your rows are linearly dependent.
Here is the deeper reason this formula is fragile. Computing A⁻¹ explicitly and then multiplying by B is not the same numerical operation as solving AX = B directly. The inverse amplifies whatever is already wrong with your data. To see why, you need the condition number.
Quantified context: the condition number decides everything
The condition number κ(A) equals ‖A‖·‖A⁻¹‖ and bounds how much a relative error in B can grow in X. If κ(A) = 10³, roughly three digits of accuracy vanish. At κ(A) = 10¹⁰ in double precision—about 16 significant digits—you are left with roughly 6 trustworthy digits.
This is the single most important number in the whole topic. A matrix with κ near 1 is well conditioned. A matrix with κ above 10¹² in double precision is numerically singular even if the determinant is technically nonzero.
Consider the Hilbert matrix, a classic test case. Its 5×5 version has κ around 4.8 × 10⁵. The 10×10 version jumps to about 1.6 × 10¹³. That crosses the double-precision danger line. You can solve a 10×10 Hilbert system on paper, but in floating-point it will produce garbage.
Practical guidance from numerical linear algebra: if κ(A) exceeds roughly 10^(precision digits − 3), distrust the result. For double precision that is about 10¹³. For single precision, only about 10⁴.
The plain-language version: the condition number tells you how many digits of your answer are real and how many are noise.
Edge cases and the systems that break the formula
Three failure modes dominate.
Singular systems. When det(A) = 0, no inverse exists. The system either has infinitely many solutions (consistent but dependent) or none (inconsistent). You need row reduction to tell which.
Underdetermined and overdetermined systems. If the number of equations does not equal the number of unknowns, A is not square and A⁻¹ is undefined. A rectangular system needs the pseudoinverse and least squares, not the ordinary inverse.
Ill-conditioned but technically invertible systems. This is the trap. det(A) might be 10⁻⁸ instead of exactly zero, so software happily inverts it and returns confident-looking numbers that are wrong in the third digit. Never treat "the inverse computed without error" as proof the answer is correct.
A counterintuitive caveat from working numerical analysts: dividing by a small determinant is not itself the problem. A matrix can have a tiny determinant and still be perfectly conditioned if its entries are uniformly tiny. Conversely, a matrix with a determinant near 1 can be badly conditioned. Condition number, not determinant size, is the honest diagnostic.
Timeline: how a solution degrades in practice
The table below follows a single ill-conditioned system through a typical workflow. Values are illustrative of the general pattern, not measurements from a specific dataset.
| Stage | What happens | Typical signal |
|---|---|---|
| Problem setup | Coefficient rows nearly dependent | κ(A) already large at 10⁶–10¹² |
| Inverse computed | Algorithm returns a matrix | No error flag; looks fine |
| Matrix multiply | A⁻¹B forms the answer | Answer plausible to 2–4 digits |
| Residual check | AX − B is not near zero | Residual small but error large |
| Perturbation test | Tiny change in B shifts X wildly | Amplification confirms instability |
| Verdict | Result untrustworthy | Switch to a stable solver |
The residual-versus-error distinction is the professional insight most thin explainers miss. A small residual—the leftover when you plug your answer back in—does not guarantee a small error in the unknowns. For ill-conditioned systems you can have both a tiny residual and a hugely wrong answer. That is why residual checking alone is insufficient.
Comparison: inverse method versus alternatives
Every method below solves the same class of problem. The choice depends on size, conditioning, and how many right-hand sides you have.
| Method | Best for | Cost (n×n) | Handles singular/near-singular? | Numerical stability |
|---|---|---|---|---|
| Explicit inverse A⁻¹B | Teaching, tiny systems, many right-hand sides | ~2n³/3 flops | No | Poor when κ is large |
| Gaussian elimination | General square systems | ~2n³/3 flops | Detects singularity | Good with pivoting |
| LU decomposition | Repeated solves, same A | ~2n³/3 once, cheap after | Partially | Good with pivoting |
| QR decomposition | Rectangular, least squares | ~2n³/3 to 4n³/3 | Overdetermined cases | Excellent |
| Iterative solvers | Very large sparse systems | Problem-dependent | With care | Depends on conditioning |
The flop counts here are order-of-magnitude context, not precise benchmarks. The point is that explicit inversion rarely wins on stability and offers no speed advantage over LU factorization for the same coefficient matrix.
Red-flag warnings before you reach for the inverse:
Determinant is zero or within rounding distance of zero. Any two rows look nearly proportional to each other. Condition number exceeds about 10¹³ in double precision. The system is not square. You need the answer to full machine accuracy, not just a plausible number. Your data in B carries measurement noise that will be amplified.
Misconceptions worth correcting
The biggest one: "if the software returns an answer, the system is solvable." Software returns an answer to almost anything, including nonsense, because floating-point arithmetic does not throw an error when the conditioning is bad. Only your diagnostics do that.
Second: "the inverse is the professional method." In practice, numerical analysts almost never form the inverse explicitly. They factorize and solve. The inverse as a concept is essential; the inverse as a computation is usually the wrong tool.
Third: "a unique solution means the inverse approach is safe." Uniqueness is a statement about exact arithmetic. It says nothing about how your computed answer survives round-off.
Fourth: "the determinant tells you if it is solvable." The determinant answers existence in exact math but is a poor conditioning measure in floating point. Two matrices with identical determinants can differ wildly in stability.
Practical actions: steps and thresholds you can apply
Step 1. Write the system as AX = B and confirm A is square. If it is not, stop and use least squares—the ordinary inverse does not apply.
Step 2. Compute the determinant. If it is exactly zero, the system is singular; classify it as dependent or inconsistent via row reduction.
Step 3. Estimate the condition number before trusting any numbers. In NumPy, use numpy.linalg.cond. Treat anything above about 10¹³ in double precision as unreliable.
Step 4. Prefer a factorization over an explicit inverse. Solve with LU or QR, which is more stable and equally fast.
Step 5. Check both the residual AX − B and, if feasible, a perturbation test: nudge B slightly and see how much X moves. Large movement means large κ.
Step 6. For a small hand-worked problem, the inverse is fine and instructive. Use it to build intuition, not to run production numerics.
A concrete threshold to internalize: in double precision, plan on losing roughly log₁₀(κ) significant digits. With κ = 10⁸, you keep about 8 of your 16 digits. That single rule covers most real-world decisions.
Limitations: what the inverse method cannot deliver
This method applies only to square, invertible systems in exact arithmetic, and only reliably in floating point when the matrix is well conditioned. It cannot classify singular systems, cannot handle rectangular systems, and cannot rescue ill-conditioned ones.
Even where it technically works, explicit inversion wastes work and stability compared with factorization. The formula's value is conceptual clarity, not computational practice.
That is the honest boundary. Use A⁻¹B to understand the structure of linear systems. Use stable solvers to get answers you can trust.