Matrix Calculator
Multiply, transpose, invert and find the determinant of matrices. Partial pivoting keeps results stable, and a singular matrix reports no inverse instead of a screen of NaN.
About this tool
Matrix math shows up everywhere — solving systems of linear equations, transforming coordinates in graphics, fitting models in statistics — yet the arithmetic is easy to get wrong by hand. This calculator covers the four operations you reach for most: multiplication, transposition, the determinant and the inverse.
The part most online calculators get wrong is numerical stability. When a leading entry is zero, an elimination step without pivoting divides by zero and the whole result collapses. This tool chooses the largest available entry as the pivot at every step, so a matrix like [[0,1],[1,0]] is handled correctly instead of returning NaN.
A matrix with no inverse is reported as singular rather than filled with NaN, and a size mismatch names the two numbers that disagree. Everything is computed locally in your browser; nothing is sent anywhere.
Why the inverse of a whole-number matrix comes back clean
Intermediates keep full precision and only the finished result is tidied, so rounding noise such as −1.9999999999999996 is returned as −2. The inverse of 1 2 over 3 4 comes out as −2, 1, 1.5, −0.5 rather than a row of near-misses.
Floating-point arithmetic on a matrix does not produce tidy fractions. Computed the obvious way, the inverse of a two-by-two integer matrix arrives as values like −1.9999999999999996 and 0.9999999999999998 — correct to fifteen digits and useless to look at. The cleanup runs over the finished result rather than over intermediate steps, because rounding early is how errors compound.
The pass does two things. Values within a whisker of zero are set to exactly zero, which also strips the sign off a negative zero. Everything else is held against short decimals: if a value sits within a relative tolerance of a number with ten decimal places or fewer, it is snapped to that number, and −1.9999999999999996 matches −2 and becomes −2.
The tolerance is relative rather than absolute, and the search stops at ten decimal places. Both choices push the same way: a value that genuinely needs more precision — one that only agrees with a short decimal in the eleventh digit — is returned untouched, so the tidying cannot quietly flatten a result that was carrying real information.
What counts as zero when deciding a matrix is singular
A pivot counts as zero when it falls below 1e-12 times the largest entry in the matrix. Scaling the whole matrix up or down does not change that judgement, but mixing entries thirteen orders of magnitude apart can.
The threshold is relative on purpose. A matrix whose entries are all around a million carries floating-point residue about a million times larger than one whose entries are small integers, so a fixed absolute cut-off would call the first one singular and wave the second one through. Taking 1e-12 times the largest entry instead means the same matrix scaled up or down is judged the same way.
The floor of 1 under that maximum is what keeps the all-zero matrix working: its largest entry is zero, so without the floor the tolerance would also be zero and no pivot could ever be declared too small. With it, zero matrices and matrices whose rows cancel each other out both come back as singular, which is the right answer for both.
The trade-off is that a matrix spanning a very wide range of magnitudes can be judged singular when it is not. A diagonal of 1e6 beside 1e-7 has a determinant of 0.1 by hand, but comes back as zero here, because the small pivot sits under the tolerance the large entries set. Matrices like that are rare in the coursework and graphics work this page is built for, and they are the case worth knowing about.
How large and small results are written on screen
Whole numbers are printed in full, however long. Anything with a fractional part is shown to at most six decimals with trailing zeros removed, and switches to scientific notation below 0.0001 or above ten million.
Integers are checked first and printed exactly as they are, so an integer determinant of a thousand billion is shown in full rather than rounded off. Only values carrying a fractional part go through the decimal formatting, which is what keeps a clean result clean.
Between 0.0001 and ten million a fraction is printed to six decimals and then stripped of trailing zeros, so a third comes back as 0.333333 and 2.5 stays 2.5 instead of becoming 2.500000. Outside that range the display switches to scientific notation with four decimals, which is what stops a determinant of 1.2e-9 or 4.7e+12 from turning into a wall of digits.
Inside a matrix the cells are laid out as fixed-width text, right-aligned within each column, so the digits line up when you read down a column — the way a matrix is meant to be read. The size of the result is reported above it as rows by columns, so a three-by-two answer is never mistaken for a two-by-three one.
Ragged rows must fail, never be padded to match the first
When a matrix is pasted from a spreadsheet, uneven row lengths nearly always mean a missing number. Padding the short row with zeros would corrupt the determinant and the inverse while reporting no error, so this page refuses and names the row, the expected count and the actual one.
In practice: rows [1 2 3] and [4 5] produce RAGGED_ROWS, stating row 2 expected 3 and got 2; the reverse case [1 2] with [3 4 5] fails the same way, expecting 2 and getting 3. No human counting is required to find the bad line.
Why padding is wrong: a zero is a claim that the entry is zero. An extra zero changes the determinant, and a 3×3 that silently becomes 3×4 changes the dimensions of every product downstream, so the error travels all the way to the result with no warning at any point.
This is the same stance as the singular test: fail loudly and point at the location rather than return a plausible-looking number. The expensive mistake in a maths tool is the silent one, because the user has no reason to doubt a neatly formatted result.
Two input conventions go with it: entries may be separated by spaces or commas (tab-separated pastes from spreadsheets fall into the space case), and blank lines are skipped. A paste with empty rows will not raise a false alarm; a row that is short always will.
Frequently asked questions
What does a singular matrix mean?
A singular matrix has a determinant of zero, so it has no inverse — there is no matrix that multiplies back to the identity. This happens whenever one row is a multiple of another, or the rows do not span the full space. The tool says so in plain words instead of returning a grid of NaN.
Why does pivot selection matter?
Elimination works by dividing by the current leading entry. If that entry is zero, or very small, the division either blows up or loses precision. Choosing the largest available entry as the pivot at each step — partial pivoting — keeps the numbers well behaved. It does not change the true answer, only the route taken to reach it.
How do I enter a matrix?
Write one row per line, with the numbers separated by spaces or commas. A 2 by 2 matrix is two lines of two numbers. Every line must have the same number of entries; if one is short, the tool tells you which line and how many it expected.
When can two matrices be multiplied?
Only when the number of columns on the left equals the number of rows on the right. An m by n matrix times an n by p matrix gives an m by p result. If the two inner sizes disagree, no product exists, and the tool names both numbers so you can see which one to fix.
What is the determinant good for?
The determinant tells you how the matrix scales area or volume. A zero determinant means the transformation collapses space onto a lower dimension, which is exactly when no inverse exists. It also appears when solving linear systems and in change-of-variables formulas.
Related tools
Solve any triangle from three known values — SSS, SAS, ASA, AAS and the ambiguous SSA case — with area, perimeter, circumradius and inradius. SSA shows both possible triangles, not just one.
Work out how much concrete a slab, round column or hollow pier needs. Volume in cubic yards or meters, bag counts for common mix sizes, and weight.
Work out how many sheets of plywood, MDF or board a cut list needs. Lays the parts out on each sheet, applies the blade kerf, and reports the yield and the offcuts.
Build a fair round robin schedule for any number of teams, with automatic byes for odd counts and balanced home and away games.