Matrix Inverse Calculator

Type a square matrix, watch the determinant update as you go, then replay the Gauss-Jordan elimination one row operation at a time. Every value stays an exact fraction from start to finish, so <code>1/3</code> reads as a third rather than 0.333333.

Matrix inverse worktable

Size
Show
Examples
det(A) =n/aFill the left half to see whether an inverse exists.

Left half is A, right half starts as the identity. Move with the arrow keys, paste a whole matrix into any cell to fill from there, press Enter to invert. Entries accept 7, -2.5 or 3/8.

Why two calculators return different digits for one inverse

Most inverse calculators convert your entries to 64-bit floating point numbers before the first row operation. One third becomes 0.3333333333333333, and every later subtraction inherits the error. Run enough operations and the identity block on the left drifts away from clean ones and zeros, which is why some tools print 0.9999999999998 where a 1 belongs.

This page keeps every entry as a pair of arbitrary-size integers. A decimal like -2.5 becomes -5/2 on the way in, fractions stay fractions, and the arithmetic runs on BigInt values with no rounding step anywhere. The inverse you read is the exact inverse of the matrix you typed. Switch to the decimal view when you want digits, and the rounding happens once, at display time, rather than compounding through the elimination.

Try the near-singular example. Its determinant is one hundred-millionth. The exact answer holds entries near ten thousand, and float-based tools disagree with each other on the trailing digits of the same matrix.

Entries the parser accepts

Anything outside these forms marks the cell red and pauses the determinant readout.
You typeStored as
12Integer, no size limit worth worrying about
-2.5The fraction -5/2, exactly
3/8A ratio of two integers
0.1/0.3Decimals on both sides of the slash resolve to 1/3
blankZero, so a sparse matrix needs little typing

Reading the row operations

Gauss-Jordan works on both halves at once. Whatever you do to a row of A, you do to the same row of the identity block. When the left half becomes the identity, the right half holds A⁻¹, because the same sequence of operations that undoes A builds its inverse out of I.

The player labels three kinds of move:

  • Swap. Two rows trade places to put a non-zero entry in the pivot slot. Each swap flips the sign of the determinant.
  • Scale. A row is divided by its pivot so the pivot reads 1.
  • Clear. A multiple of the pivot row is subtracted from another row to zero out that column.

Highlighted cells are the row being touched, the boxed cell is the pivot, and an underline marks a value that changed since the previous step. Arrow keys move through the steps once the elimination is on screen, so you compare a snapshot against the one before it without hunting for the buttons.

Pivot choice is worth a note. A textbook picks the topmost non-zero entry, and a numerical library picks the largest to protect against rounding. With exact arithmetic there is nothing to protect against, so this page prefers a row whose pivot is 1 or -1. That keeps intermediate denominators small and the steps readable by hand.

A zero determinant is structural, not a rounding artifact

When the determinant is 0 the matrix is singular and no inverse exists. That is a statement about the rows, not about precision. One row is a combination of the others, so the transformation flattens space and throws away the information an inverse would need to restore. Loading the singular example makes this concrete: row 2 is exactly twice row 1.

Run a singular matrix here and the elimination still plays. It stops at the column where every remaining candidate pivot is zero and names that column, which is usually faster for spotting the dependent row than staring at the original grid.

Near-singular is the harder case. The determinant is non-zero, so an inverse exists and this page returns it exactly, but the matrix is ill-conditioned: a change in the fifth decimal of one entry swings the inverse wildly. Exact arithmetic answers the question you asked. It does not make an ill-conditioned model trustworthy, and if those entries came from measurements, the inverse inherits their uncertainty amplified by the conditioning.

When inverting is the wrong move

The inverse is the right object for coursework, for deriving a formula, and for small matrices you plan to reuse against many right-hand sides. Outside those cases it is often the long way around.

  • Solving Ax = b. Skip the inverse. Gaussian elimination on the augmented [A | b] costs about a third of the work and carries less error. Reach for the system of equations solver instead.
  • Least squares fitting. The textbook (XᵀX)⁻¹Xᵀy squares the conditioning of X. Statistical software uses a QR or SVD decomposition and never forms that inverse.
  • Large or sparse matrices. Inversion is cubic in n, and the inverse of a sparse matrix is usually dense. A 10,000 by 10,000 sparse system solves in seconds while its inverse would not fit in memory.

What this page will not do

The size selector stops at 5×5. Past that the step list grows past reading length, which defeats the point of showing the work. Entries have to be rational: pi, sqrt(2) and symbolic variables are rejected rather than silently approximated. Exact answers to matrices built from long decimals produce large denominators, so switch to the decimal view when a fraction stops being readable. For a determinant on its own, the determinant calculator is quicker, and for products, sums and transposes use the matrix calculator.

Questions about inverting matrices here

Details on the arithmetic, the step player and the limits of the tool.

Are the results exact or rounded?

Exact. Entries are stored as pairs of arbitrary-precision integers and every row operation runs on those integers, so no rounding happens during the elimination. Rounding occurs only when you switch to the decimal view, which formats the exact value to six places for display.

Why does my matrix show a determinant but no inverse?

It should not. A non-zero determinant guarantees an inverse, and the elimination completes whenever the determinant readout is non-zero. If the readout shows n/a instead of a number, one cell failed to parse and is outlined in red.

What does the right half of the grid represent?

It starts as the identity matrix. Every row operation applied to A is applied to it at the same time. Once the left half reaches the identity, the right half holds the inverse, which is the whole idea behind Gauss-Jordan elimination.

Can I paste a matrix from a spreadsheet?

Yes. Copy the cells, click the cell where the block should start, and paste. Values split on spaces, tabs, commas and line breaks, then fill left to right and top to bottom from the cell you clicked.

How do I check the answer by hand?

Multiply A by the result and confirm you get the identity matrix. Copy the inverse in fraction form and use the matrix calculator for the product. With exact arithmetic the identity comes out clean, with no trailing digits to interpret.

Why stop at 5x5?

A 5x5 inverse already runs to roughly forty row operations. Beyond that the step list is too long to follow, and showing the work is the reason this page exists. For larger matrices use a numerical library such as NumPy or SciPy.

Does the pivot order affect the answer?

No. Any valid pivot sequence produces the same inverse, since the inverse of a matrix is unique. The order changes only how large the intermediate fractions grow, which is why this page prefers pivots of 1 or -1 when a row offers one.

Is my matrix sent anywhere?

No. The arithmetic runs in your browser using BigInt values. Nothing is uploaded, logged or stored, and the page works offline once it has loaded.