Matrix calculator

Determinant, inverse and condition number — and the reason the determinant cannot tell you whether a matrix is singular, however small it gets. Nothing you type here leaves your browser — it is worked out on your own device, so there is nothing to send and nothing to log.

“Is it singular” is not a question the determinant can answer

A singular matrix has a determinant of exactly zero. Computed in floating point it almost never comes out as zero — and, more awkwardly, it does not come out near zero either. It comes out at whatever scale the entries happen to live at.

Take the identity matrix — the most perfectly conditioned matrix there is, condition number exactly 1 — and scale it down:

Both are perfectly invertible. Both have a condition number of 1. But a calculator testing “|det| < 10−10 means singular” calls the second one singular, and it is not. Whatever value the threshold is given, scaling down far enough defeats it — and nothing about the matrix has changed except the units somebody wrote it in.

The opposite direction is harder to produce than it looks, and this page does not claim it: a matrix that is exactly singular hits a zero pivot during elimination and returns a determinant of exactly zero, so the naive test catches it too. The failure that matters in practice is the next section.

The determinant moves with your units; the condition number does not

For an n×n matrix, det(kA) = kn det(A). Change from metres to millimetres and a 3×3 determinant grows by a factor of a billion, with the matrix meaning exactly the same thing.

Measured here, scaling one matrix by 1, by a thousand and by a million:

That is the whole argument. One of those numbers is about the matrix and the other is about the units it was written in.

A comfortable determinant with three digits left

This is the case that costs people answers rather than arguments — written in powers of ten deliberately, because the expanded digits collide with a serial number this site has undertaken to withhold, and the build gate that enforces that cannot tell a matrix entry from a serial:

[[105, 105], [105, 105(1 + 10−12)]]

Its determinant is 0.01 — nowhere near any threshold anybody would set, and it looks entirely healthy. Its condition number is 4×1012, which means 12.6 of the 16 digits a double holds are gone. About three and a half remain.

No verdict of “invertible” conveys that, and a page that prints only the determinant cannot. The number to look at is how many digits are left.

What the condition number actually tells you

It is the factor by which an error in the input can be magnified in the answer. Its logarithm is the number of decimal digits you lose: a condition number of 108 costs eight of the roughly sixteen digits a double holds, leaving eight.

So “singular” is not really a yes or no. It is the point where the condition number exceeds 1 ÷ ε — about 4.5×1015 — and there are no correct digits left at all. This page reports the number rather than only the verdict, because the number is the useful part.

Whole numbers get an exact answer

When every entry is an integer, the determinant is computed by fraction-free (Bareiss) elimination, which keeps every intermediate value a whole number — each division is guaranteed to come out exactly. No rounding enters at any point.

For those matrices “zero” means zero, and the page says so. It also stops and says it cannot give an exact answer if the intermediate values grow past the range where integers are exact, rather than carrying on and returning a number that has quietly stopped being one.

Why not the method you were taught

Cofactor expansion — pick a row, multiply each entry by the determinant of the matrix left when you delete its row and column — is correct, teachable, and O(n!).

Elimination is O(n³): 125, 1,000 and 3,375 for the same three. At the sizes people actually paste in, that is the difference between an answer and a hung browser tab.

The inverse is checked, not asserted

Where there is an inverse, this page multiplies it back by the original and reports how far the result is from the identity. That is a measurement of the error in the answer you were given, rather than a promise about it — and on an ill-conditioned matrix you can watch it grow.

How this was checked

Graded against SymPy, which computes determinants over exact rationals with no floating point anywhere, and NumPy, whose condition numbers come from a singular value decomposition — a completely different route from the 1-norm product used here. 34 cases, including Hilbert matrices, matrices singular by construction, and sizes where cofactor expansion would be hopeless.

Where to go next