Linear Algebra
How to Find the Inverse of a Matrix
By MathSolver Pro Editorial Team · Published
The inverse of a square matrix undoes what the matrix does, just as dividing undoes multiplying. A matrix has an inverse exactly when its determinant is nonzero. This guide covers the quick 2 by 2 formula, the general Gauss-Jordan method and how inverses solve systems of equations.
What the inverse is
For numbers, the reciprocal of 5 is because . Matrices have no division, but they have the same idea. The inverse of a square matrix is the matrix that satisfies:
Here is the identity matrix, the matrix version of 1. If describes a transformation, such as rotating and stretching the plane, then is the transformation that puts everything back where it started. Only square matrices can have inverses, and even then not all of them do. A matrix with an inverse is called invertible or nonsingular; one without is called singular.
The test is the determinant: is invertible exactly when . A zero determinant means the matrix flattens space into a lower dimension, so different inputs land on the same output and there is no way to undo the transformation.
The 2 by 2 formula
For a matrix there is a short formula: swap the diagonal entries, change the signs of the off-diagonal entries and divide by the determinant.
Example 1: inverting a 2 by 2 matrix
- Let . Its determinant is , which is nonzero.
- Swap 4 and 6, and negate 7 and 2: .
- Divide by 10: .
- Check the first row of : and . The second row gives and in the same way, so the product is .
By contrast, has determinant . Its first row is twice its second, so it has no inverse, and the formula would ask you to divide by zero.
Gauss-Jordan elimination for any size
For and larger matrices, the standard method is Gauss-Jordan elimination. Write and the identity side by side as an augmented matrix . Use row operations to turn the left half into . The same operations turn the right half into . If a row of zeros appears on the left, the matrix is singular and has no inverse.
Example 2: a 3 by 3 inverse
- Let have rows , and , and start with .
- Row 3 minus 5 times row 1: the left part of row 3 becomes and the right part .
- Row 3 plus 4 times row 2: row 3 becomes .
- Row 2 minus 4 times row 3: row 2 becomes .
- Row 1 minus 3 times row 3: row 1 becomes .
- Row 1 minus 2 times row 2: row 1 becomes .
- So has rows , and .
This matrix happens to have determinant 1, which is why its inverse contains only whole numbers. Most inverses involve fractions, so keep entries as fractions rather than rounded decimals while you work.
The adjugate formula
There is also a formula that generalises the rule. Replace each entry with its cofactor, the signed determinant of the minor left after deleting that entry's row and column, then transpose the result to get the adjugate, written :
The adjugate formula is useful for theory and for matrices with simple entries, but it needs nine determinants for a matrix and grows rapidly with size. For anything larger, Gauss-Jordan elimination is the practical choice.
Solving systems with the inverse
A linear system written as can be solved by multiplying both sides on the left by , giving . This mirrors solving by dividing by 5.
Example 3: a system solved by the inverse
- Solve and . The coefficient matrix is from Example 1.
- : and .
- Check: and .
The method is especially convenient when you must solve several systems with the same coefficients but different right-hand sides, because the inverse is computed only once. For a single system, elimination is usually quicker, as explained in solving systems of equations.
Properties of inverses
- The inverse of a product reverses the order, just as taking off socks and shoes reverses the order you put them on.
- If is invertible, the inverse is unique.
- .
- For a nonzero number , .
- A diagonal matrix with nonzero diagonal entries is inverted by taking the reciprocal of each diagonal entry.
Inverses in practice
Inverse matrices are essential in theory and appear in computer graphics, where undoing a camera transformation means applying its inverse, in cryptography, where the Hill cipher decodes messages with an inverse matrix, and in statistics, where the least squares formula for regression contains an inverse.
Numerical software, however, rarely computes an inverse explicitly just to solve a system. Elimination-based methods are faster and less sensitive to rounding errors, particularly for nearly singular matrices whose determinant is close to zero. The inverse matrix calculator shows every Gauss-Jordan step with exact fractions, and the matrix calculator lets you verify that really equals the identity.
Why the 2 by 2 formula works
The formula is easy to verify, and seeing why it works makes it easier to remember. Multiply the original matrix by the swapped-and-negated matrix:
The result is the determinant times the identity. Dividing by the determinant leaves exactly the identity, which is what an inverse must produce. The calculation also shows why a zero determinant is fatal: the product is then the zero matrix, and no amount of scaling can turn it into the identity.
Common mistakes when inverting
- Negating the diagonal entries instead of swapping them in the formula.
- Forgetting to divide by the determinant at the end.
- Applying a row operation to the left half of but not to the right half.
- Multiplying on the wrong side: the solution is , and is usually not even defined.
- Rounding fractions to decimals early, so that the final check no longer gives the identity exactly.
Each of these errors is caught by the same habit: multiply your answer by the original matrix before moving on. The check costs a minute and is far quicker than redoing an entire calculation later.
Practice problems
Try these before checking the answers. First, invert the matrix with rows and . Its determinant is , so the inverse is simply the swapped-and-negated matrix, with rows and . Second, decide whether the matrix with rows and is invertible. Its determinant is , so it is singular. Third, invert the diagonal matrix with entries 2, 4 and 5 on the diagonal: the inverse has diagonal entries one half, one quarter and one fifth. Finally, use the first answer to solve and : multiplying the inverse by the constants gives and , and both equations check out.
Frequently asked questions
How can I tell quickly whether a matrix has an inverse?
Compute its determinant. If the determinant is nonzero, the inverse exists. If it is zero, for example because one row is a multiple of another, the matrix is singular.
Can a non-square matrix have an inverse?
Not a two-sided inverse. Rectangular matrices can have one-sided or pseudo-inverses, used in least squares problems, but the ordinary inverse is defined only for square matrices.
How do I check that my inverse is correct?
Multiply the original matrix by your answer. If the product is the identity matrix, the inverse is right. Checking one row of the product often catches errors quickly.
Why is the inverse of AB equal to B inverse times A inverse?
Because applies first and then . To undo it you must undo first, then , which gives . Multiplying confirms that .
Is computing the inverse the best way to solve a linear system?
For a single system, usually not. Elimination finds the solution with fewer operations and less rounding error. The inverse pays off when many systems share the same coefficient matrix.