Matrix Calculator
Add, multiply, transpose and find the determinant and inverse of matrices, with the dimension rules and why some matrices have no inverse at all.
A non-zero determinant does not mean you can invert it
The determinant answers one question: is this matrix invertible in exact arithmetic? It is routinely read as answering a different one — how invertible is it — and it does not. The two are not even correlated.
The clearest case is a shear. [[1, 1000], [0, 1]] has a determinant of exactly
1 — the same as the identity matrix, which is as well-behaved as a
matrix gets. Its condition number, which measures how much it magnifies a change in the input,
is about 999,997 against the
identity's 1. Nudge the right-hand side of Ax = b by one
part in a billion and the answer moves a thousand times further. The determinant cannot see any
of that.
Hilbert matrices, where each entry is 1/(i+j+1), make the point unarguable. They are provably invertible at every size. Computing one and multiplying it by its own computed inverse should return the identity exactly; here is how far it actually lands:
| Size | Determinant | Invertible? | Worst error in H·H⁻¹ − I |
|---|---|---|---|
| 2×2 | 8.33e-2 | yes — non-zero | 0.0e+0 |
| 4×4 | 1.65e-7 | yes — non-zero | 3.4e-13 |
| 6×6 | 5.37e-18 | yes — non-zero | 4.7e-10 |
| 8×8 | 2.74e-33 | yes — non-zero | 3.3e-7 |
| 10×10 | 2.16e-53 | yes — non-zero | 0.00 |
| 12×12 | 2.83e-78 | yes — non-zero | 2.31 |
Every row passes the invertibility check. By twelve by twelve the computed inverse is wrong by more than 2 — larger than most of the entries it was supposed to produce — while the determinant is still a perfectly respectable non-zero number. Anything built on that inverse is returning noise, and nothing in the calculation says so.
The determinant does shrink towards zero as the Hilbert matrices grow, which is a hint. It is not the diagnosis, because the shear above has a determinant of 1 and is just as badly behaved. The quantity that actually predicts trouble is the condition number.
The practical rule that follows: to solve Ax = b, solve it directly rather than computing A⁻¹ and multiplying. Inversion does more arithmetic, loses more precision along the way, and answers a question you did not ask.
And the order of multiplication matters
Matrix multiplication is not commutative, which is easy to say and easy to forget the moment
the matrices mean something. With
A = [[1,2],[3,4]] and
B = [[0,1],[1,0]]:
AB = [[2,1],[4,3]]
BA = [[3,4],[1,2]]
Not a rounding difference — completely different matrices. This is why "rotate then translate" and "translate then rotate" put an object in different places, and why the order of transformations in graphics code is not a stylistic choice.
A detail worth noticing, because it ties the two halves of this page together: although AB and BA are different matrices, their determinants are identical. det(AB) always equals det(BA). That is a neat result, and it is also a warning — the determinant collapses a whole matrix into one number, and two things it reports as identical can behave nothing alike.
How to use
- Set the dimensions and enter your values.
- Choose an operation.
- Read the result and any warning about dimensions.
- Check the determinant before expecting an inverse.
Frequently asked questions
When can two matrices be multiplied?
When the first has as many columns as the second has rows. The result takes the first matrix's row count and the second's column count. This is why matrix multiplication so often fails on a dimension mismatch — the requirement is asymmetric.
Is matrix multiplication commutative?
No, and this is its most important property. Multiplying in the other order usually gives a different answer, and frequently is not even defined. Since matrices represent transformations, this reflects something real: rotating then scaling is genuinely not the same as scaling then rotating.
What does the determinant tell you?
How much the transformation scales area or volume, and whether it preserves orientation. A determinant of zero means the transformation collapses space into a lower dimension, which is exactly why such a matrix has no inverse — information has been destroyed and cannot be recovered.
What is a singular matrix?
One with a zero determinant, and therefore no inverse. Numerically, near-singular matrices are the greater practical problem: they are technically invertible but the computation amplifies rounding error enormously, giving an answer that looks fine and is wrong.
Why should I avoid computing an inverse?
Because solving a system directly is both faster and more numerically stable than inverting a matrix and multiplying. Numerical analysts treat explicitly forming an inverse as a warning sign in code, since the operations that need it are rare and the ones that appear to are usually better done another way.
What is the transpose for?
Flipping rows and columns. It appears throughout linear algebra — in dot products, in least-squares fitting, and in the definition of symmetric matrices, which equal their own transpose and have particularly well-behaved properties.
🔒 This tool runs entirely in your browser. Nothing you enter is uploaded, logged, or stored.