🏆 US-Registered Digital Marketing Agency
Advertisement
Advertisement
MATHEMATICS

Matrix Inverse Calculator — Gauss-Jordan, step by step

Invert a square matrix up to four by four, follow every row operation, and get a plain answer when the matrix has no inverse at all.

One row per line, entries separated by spaces or commas. Must be square: 2×2, 3×3 or 4×4.
Exact whole numbers are printed without decimals so an integer inverse stays readable.
A pivot smaller than this is treated as zero. Raise it if rounding noise in measured data is producing a spurious inverse.
The step list is what you compare against your own working when the two answers disagree.
Inverse matrix A⁻¹
 
Determinant
Matrix size
Rank
Worst error in A·A⁻¹
 
Tip: a zero determinant is not a rounding problem to work around. It means the matrix collapses at least one direction of space onto nothing, and no inverse exists that could undo that.
Advertisement

The inverse of a square matrix A is the matrix A⁻¹ that undoes it: multiply the two together in either order and you get the identity. Not every square matrix has one. This matrix inverse calculator runs Gauss-Jordan elimination on the augmented matrix [A | I], lists each row operation as it performs it, and returns either the inverse or a clear statement that the matrix is singular — never a grid of NaN or Infinity, which is how most quick scripts fail on exactly the cases that matter.

Arb Digital built the page around the failure case on purpose. Finding an inverse when one exists is routine. The genuinely useful behaviour is recognising when one does not, saying why, and reporting the rank so you know how much of the matrix collapsed. That distinction is the difference between a tool you can trust with real measured data and one that quietly returns rubbish.

What This Matrix Inverse Calculator Does

It accepts a square matrix of 2, 3 or 4 rows, augments it with the identity, and reduces the left half to the identity using row swaps, row scaling and row subtraction. Whatever the right half has become at the end is A⁻¹. Along the way it reports the determinant as the product of the pivots, the rank, and a verification figure: the largest deviation from the identity when A is multiplied back by the computed inverse. That last number is the honest measure of how much floating-point rounding has crept in.

Inversion is a different operation from the arithmetic on our matrix calculator, which adds, subtracts, multiplies, scales and transposes but does not row-reduce; and it goes further than our determinant calculator, which returns the single number that tells you whether an inverse exists without constructing it. Use this page when you need the inverse matrix itself and want to see how it was reached.

How to Use It

  1. Type the matrix one row per line. Spaces or commas both work. The number of rows must equal the number of entries in each row.
  2. Leave the tolerance alone for exact data. The default treats anything below one billionth as a zero pivot, which is right for numbers you typed yourself.
  3. Raise the tolerance for measured data. Real measurements carry noise, and a pivot of 10⁻⁷ in that context is a zero wearing a disguise.
  4. Read the determinant before the inverse. If it is zero or very close to it, the entries of the inverse are enormous and untrustworthy even when the tool returns them.
  5. Check the verification figure. Anything far from zero means the problem is ill-conditioned and the inverse should not be used as though it were exact.

The Method and How It's Calculated

Gauss-Jordan elimination works on the augmented matrix [A | I]. For each column in turn the algorithm picks a pivot — the row with the largest absolute value in that column, swapped up into position, which is called partial pivoting and keeps rounding under control — then divides that row through so the pivot becomes 1, then subtracts multiples of it from every other row so the rest of the column becomes zero. Every operation applied to the left half is applied to the right half at the same time. When the left half is the identity, the right half is A⁻¹.

Take the default matrix, 1 2 3 / 0 1 4 / 5 6 0. Its determinant is 1, and elimination produces the exact integer inverse −24 18 5 / 20 −15 −4 / −5 4 1. You can verify one entry by hand: the first row of A times the first column of A⁻¹ is 1×(−24) + 2×20 + 3×(−5) = −24 + 40 − 15 = 1, which is the top-left entry of the identity, as required. The first row of A times the second column is 1×18 + 2×(−15) + 3×4 = 18 − 30 + 12 = 0, as required off the diagonal.

The determinant falls out of the same process for free: it is the product of the pivots, adjusted by a sign flip for each row swap. That is why the tool can report the determinant without a separate cofactor expansion, and why the two numbers can never disagree with each other. The elimination and inversion algorithms are developed in order in the MIT OpenCourseWare 18.06SC Linear Algebra course, which treats inversion as elimination applied to an augmented matrix exactly as here.

Advertisement

What Singular Actually Means

A singular matrix is one whose determinant is zero, and the reason no inverse exists is geometric rather than algebraic. A matrix maps space to space. If its rows are linearly dependent — one is a multiple of another, or a sum of two others — then the map squashes a whole direction of space down to nothing. Two different starting points land on the same result, and no second transformation can separate them again, because the information that distinguished them was destroyed.

The rank tells you how much survived. A 3×3 matrix of rank 3 is invertible. Rank 2 means the map flattens three-dimensional space onto a plane; rank 1 means it collapses everything onto a line. Try it: replace the last row of the default matrix with the sum of the first two, 1 3 7, and the determinant becomes zero, the rank drops to 2, and the calculator reports singularity instead of inventing numbers. That is the correct answer, not an error.

Nearly Singular Is the Dangerous Case

Exact singularity announces itself. The case that damages real work is a matrix whose determinant is small but not zero, so an inverse is returned and looks perfectly ordinary. Such matrices are called ill-conditioned, and their defining behaviour is that a tiny change in the input produces a huge change in the inverse. Since measured inputs always carry error, the resulting inverse can be almost entirely noise.

The classic symptom is enormous entries in the inverse of a matrix whose own entries are modest. If A contains numbers around 1 and A⁻¹ contains numbers around 10⁶, the determinant is tiny and you are on thin ice. The verification figure in the results grid is the direct test: multiply back and see how far from the identity you land. In applied work the standard response is not to invert at all — solving the system directly, as our system of equations calculator does, is both faster and numerically better behaved than forming an inverse and multiplying by it.

Why the 2×2 Shortcut Does Not Generalise

For a 2×2 matrix there is a memorable formula: swap the diagonal entries, negate the off-diagonal ones, and divide everything by the determinant ad − bc. It is worth knowing and worth checking by hand. What it is not is the start of a pattern. The 3×3 version requires nine cofactors, each a 2×2 determinant, assembled into the adjugate and transposed; the 4×4 version requires sixteen 3×3 determinants.

The cost grows factorially, which is why no serious implementation uses cofactors past 3×3. Gauss-Jordan grows with the cube of the size instead, so a 4×4 costs roughly what you would expect rather than dozens of nested determinant calculations. If the cofactor route is what your course requires, the intermediate 2×2 and 3×3 determinants can be checked one at a time on our determinant calculator. The same progression from 2×2 formula to general elimination is laid out in the Matrix Algebra for Engineers lecture notes.

Properties Worth Memorising

Four identities save real time. The inverse of a product reverses the order: (AB)⁻¹ = B⁻¹A⁻¹, mirroring the rule for transposes. The inverse of an inverse is the original matrix. The determinant of the inverse is the reciprocal of the determinant, which is an instant check on any inverse you have computed — multiply the two determinants and you should get exactly 1. And the transpose and inverse commute, so (Aᵀ)⁻¹ equals (A⁻¹)ᵀ.

The eigenvalue relationship is the one that gets used most in applied work: if λ is an eigenvalue of A, then 1/λ is an eigenvalue of A⁻¹, with the same eigenvector. That immediately explains why a matrix with a zero eigenvalue cannot be inverted — the reciprocal does not exist — and why a matrix with one very small eigenvalue is ill-conditioned, since its inverse must contain the enormous reciprocal. Our eigenvalue calculator gives you those values for the same matrix.

Reading the Step List

The row operations are listed in the order performed, using the standard notation: R2 ← R2 − 3·R1 means the new second row is the old second row minus three times the first. Row swaps appear as R1 ↔ R3 and each one flips the sign of the determinant. Scaling appears as R2 ← R2 ÷ 4, which divides the determinant by the same factor and is why the calculator tracks the running product of pivots separately.

When your hand answer disagrees with the tool's, the step list localises the disagreement quickly. Compare the augmented matrix after the first column is cleared; if it already differs, the error is in your first elimination and everything after it is downstream. Most hand errors are a dropped negative in a single multiplier, and they show up in that first comparison.

Need models that hold up under scrutiny?

Arb Digital builds attribution and forecasting work on numerically sound methods, and tells you when the data cannot support the conclusion you wanted.

Browse All Free Tools Talk To Our Team

Common Mistakes to Avoid

  • Trying to invert a non-square matrix — only square matrices have inverses, and a rectangular one needs a pseudoinverse, which is a different object entirely.
  • Treating a zero determinant as a rounding issue — it is a structural fact about the matrix, and raising the tolerance to force an answer produces numbers with no meaning.
  • Applying a row operation to the left half only — every step must be applied to the augmented identity at the same time or the right half stops being the inverse.
  • Assuming (AB)⁻¹ equals A⁻¹B⁻¹ — the order reverses, exactly as it does for transposes.
  • Inverting when you only need to solve — computing A⁻¹ and multiplying is slower and less accurate than solving the system directly.

Related Free Tools From Arb Digital

Perform the surrounding arithmetic with the matrix calculator, test invertibility in one number with the determinant calculator, solve the underlying system with the system of equations calculator, or explore the vectors a matrix acts on with the vector calculator. The full free online tools hub lists every mathematics tool we publish.

Frequently Asked Questions

What does it mean when a matrix has no inverse?

It means the matrix is singular: its determinant is zero and its rows are linearly dependent. The transformation collapses at least one direction of space, destroying information that no later transformation can recover.

How does Gauss-Jordan elimination find the inverse?

You write the matrix beside an identity matrix of the same size and reduce the left half to the identity using row operations, applying every operation to both halves. Whatever the right half has become is the inverse.

What size matrices does this calculator handle?

Square matrices from 2 by 2 up to 4 by 4. The number of rows must match the number of entries in every row, and ragged input is rejected with an explanation rather than silently reshaped.

Why are the entries of my inverse so large?

Because the determinant is small. Every entry of the inverse is divided by it, so a near-zero determinant inflates the result and makes the matrix ill-conditioned, meaning small input errors become large output errors.

Is the determinant of the inverse related to the original?

Yes, it is the reciprocal. Multiply the determinant of a matrix by the determinant of its inverse and you should get exactly one, which makes a fast check on any inverse you have computed.

What is the singularity tolerance for?

It is the size below which a pivot is treated as zero. Exact typed numbers need only a very small tolerance, but measured data carries noise, so a slightly larger threshold stops the tool from inverting what is really a singular matrix.

Should I invert a matrix to solve a linear system?

Usually not. Solving the system directly by elimination is faster and numerically more stable than forming the inverse and multiplying by it, which introduces extra rounding at every entry.

This page explains a mathematical method for study and for checking your own working. It is not a substitute for showing your method, and it is not medical, legal, or financial advice.

Advertisement
Advertisement

Take it further