MatrixCalc

Matrix inverse calculator

Invert a square matrix and follow every row operation — by Gauss-Jordan elimination on [A | I], the adjugate formula or Montante's method. Exact fractions, not rounded decimals.

Matrix A
rows: 3
cols: 3
Matrix B
rows: 3
cols: 3
Operations
Result
Pick an operation to see the result here. Errors will show up in this area.

Tips: adjust sizes (max 50×50). For A×B, cols(A)=rows(B). det/inverse/trace/power require square matrices.

React, Tailwind & shadcn/ui. No external math deps. — English

Enter your matrix, open the Advanced tab and press A⁻¹. If the matrix is singular you get a clear message instead of a wrong answer. The step-by-step panel shows the intermediate values as exact fractions — 3/5 rather than 0.6000000001 — because it runs on rational arithmetic rather than floating point.

When an inverse exists

The inverse A⁻¹ is the matrix that undoes the original: A·A⁻¹ = A⁻¹·A = I. It exists only for square matrices, and only when the determinant is non-zero. A matrix with zero determinant is called singular, and it has no inverse at all — not a large one, not an approximate one, none. Information was destroyed by the transformation and no matrix can recover it.

The 2×2 shortcut

Swap the diagonal, negate the off-diagonal, divide by the determinant:

ab
cd
⁻¹ = 1/(ad − bc) ·
d−b
−ca

The division by ad − bc is where singularity announces itself: if the determinant is zero there is nothing to divide by, and the formula breaks down exactly when the inverse fails to exist.

Gauss-Jordan on the augmented matrix

This is the general method and the one the calculator shows step by step. Write A next to the identity matrix, then run row operations until the left half becomes the identity. Whatever the right half turned into is A⁻¹:

4710
2601
103/5−7/10
01−1/52/5

If at some point a row on the left becomes all zeros, stop: the matrix is singular and the inverse does not exist. Always verify the result by multiplying — A·A⁻¹ should give exactly the identity, and the A × B button does that check for you in two clicks.

The 3×3 loaded above works out to integers, because its determinant is exactly −1:

211
132
100
⁻¹ =
001
−213
3−1−5

Read the last row of the original: it picks out the first coordinate and discards the other two. The inverse has to put that information back, which is why its entries are large compared with the matrix it inverts. That is the general pattern — the closer the determinant sits to zero, the bigger the inverse becomes, since det(A⁻¹) = 1/det(A).

Nearly singular is its own problem

A matrix does not have to be singular to be troublesome. If the determinant is merely small relative to the size of the entries, the matrix is ill-conditioned: a tiny change in the input produces a huge change in the inverse, and in floating point that change can be pure rounding error. Solving a system through such an inverse can return an answer with no correct digits in it while looking perfectly plausible.

This is the practical reason the advice below matters. The step-by-step panel here sidesteps the issue entirely by working in exact fractions, so what you read is the true inverse rather than a floating-point approximation of it.

Why you rarely want the inverse itself

Most of the time the inverse is not the goal — solving Ax = b is, and the inverse is just the route people remember from class. It is the expensive route. Computing A⁻¹ and then multiplying costs roughly three times the arithmetic of row-reducing [A | b] directly, and it loses accuracy at both stages instead of one.

Where the inverse genuinely earns its place is when you need the matrix itself rather than one solution: reading off how each input influences each output, composing it with other transformations, or feeding it into a formula that is stated in terms of A⁻¹. If you only want x, use elimination; if you need many solutions for the same A, use LU decomposition, which is cheaper still.

The adjugate (cofactor) formula

A⁻¹ = adj(A) / det(A), where the adjugate is the transpose of the cofactor matrix. Build the matrix of cofactors C(i,j) = (−1)^(i+j)·M(i,j), transpose it, divide by the determinant.

It is elegant and it is what proofs use, because it expresses the inverse in closed form rather than as the outcome of an algorithm. It is also impractical: it needs determinants of size n−1. Beyond 3×3, use Gauss-Jordan.

Useful checks and properties

  • Always verify: multiply your answer by the original and confirm you get the identity.
  • (A·B)⁻¹ = B⁻¹·A⁻¹ — the order reverses.
  • (Aᵀ)⁻¹ = (A⁻¹)ᵀ
  • det(A⁻¹) = 1 / det(A), so a nearly-singular matrix has a huge inverse.
  • An orthogonal matrix satisfies A⁻¹ = Aᵀ, which makes inversion free.
  • To solve Ax = b, do not compute A⁻¹ and multiply. Row-reduce [A | b] in the RREF calculator instead — fewer operations and better numerical accuracy.

Common mistakes

  • Inverting the entries one by one. The inverse is not the matrix of reciprocals — 1/a(i,j) has nothing to do with it.
  • Getting the order wrong. (A·B)⁻¹ = B⁻¹·A⁻¹, not A⁻¹·B⁻¹.
  • Solving systems through the inverse. For Ax = b, row-reducing [A | b] is fewer operations and numerically more accurate.
  • Using the adjugate on big matrices. It needs determinants of size n−1. Past 3×3 it is far slower than elimination.
  • Confusing the inverse with the transpose. They coincide only for orthogonal matrices. In general the two have nothing to do with each other.

Frequently asked questions

Why does the calculator say my matrix has no inverse?
Its determinant is zero, which makes it singular. Check whether one row is a multiple or a sum of the others — that is what causes it.
Can a non-square matrix be inverted?
Not in the usual sense. Rectangular matrices can only have a one-sided or pseudo-inverse, which is a different operation.
Why are the steps shown as fractions?
The step-by-step engine uses exact rational arithmetic, so intermediate values stay precise. You can switch the panel to decimals at any time.
How do I check my answer is right?
Multiply the inverse by the original matrix. The result must be the identity: ones on the diagonal, zeros everywhere else.
Should I invert a matrix to solve a linear system?
Almost never. Row-reducing the augmented matrix [A | b] costs about a third as much arithmetic and is numerically more stable than forming the inverse and multiplying.

Other calculators