Skip to content
  • Open the math solver
  • Ask the AI tutor
  • Find an AP course
  • Create a quiz
  • Open the calculator
  • Graphing Calculator
  • Browse all calculators
  • Read math guides
↑ ↓Enter to open · Esc to close
Solve a problem

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 15\frac{1}{5} because 5⋅15=15 \cdot \frac{1}{5} = 1. Matrices have no division, but they have the same idea. The inverse of a square matrix AA is the matrix A−1A^{-1} that satisfies:

AA−1=A−1A=IAA^{-1} = A^{-1}A = I

Here II is the identity matrix, the matrix version of 1. If AA describes a transformation, such as rotating and stretching the plane, then A−1A^{-1} 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: AA is invertible exactly when det⁡(A)≠0\det(A) \ne 0. 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 2×22 \times 2 matrix there is a short formula: swap the diagonal entries, change the signs of the off-diagonal entries and divide by the determinant.

(abcd)−1=1ad−bc(d−b−ca)\begin{pmatrix} a & b \\ c & d \end{pmatrix}^{-1} = \frac{1}{ad - bc}\begin{pmatrix} d & -b \\ -c & a \end{pmatrix}

Example 1: inverting a 2 by 2 matrix

  1. Let A=(4726)A = \begin{pmatrix} 4 & 7 \\ 2 & 6 \end{pmatrix}. Its determinant is 4⋅6−7⋅2=104 \cdot 6 - 7 \cdot 2 = 10, which is nonzero.
  2. Swap 4 and 6, and negate 7 and 2: (6−7−24)\begin{pmatrix} 6 & -7 \\ -2 & 4 \end{pmatrix}.
  3. Divide by 10: A−1=(0.6−0.7−0.20.4)A^{-1} = \begin{pmatrix} 0.6 & -0.7 \\ -0.2 & 0.4 \end{pmatrix}.
  4. Check the first row of AA−1AA^{-1}: 4(0.6)+7(−0.2)=14(0.6) + 7(-0.2) = 1 and 4(−0.7)+7(0.4)=04(-0.7) + 7(0.4) = 0. The second row gives 00 and 11 in the same way, so the product is II.

By contrast, (2412)\begin{pmatrix} 2 & 4 \\ 1 & 2 \end{pmatrix} has determinant 4−4=04 - 4 = 0. 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 3×33 \times 3 and larger matrices, the standard method is Gauss-Jordan elimination. Write AA and the identity side by side as an augmented matrix [A∣I][A \mid I]. Use row operations to turn the left half into II. The same operations turn the right half into A−1A^{-1}. If a row of zeros appears on the left, the matrix is singular and has no inverse.

Example 2: a 3 by 3 inverse

  1. Let AA have rows (1,2,3)(1, 2, 3), (0,1,4)(0, 1, 4) and (5,6,0)(5, 6, 0), and start with [A∣I][A \mid I].
  2. Row 3 minus 5 times row 1: the left part of row 3 becomes (0,−4,−15)(0, -4, -15) and the right part (−5,0,1)(-5, 0, 1).
  3. Row 3 plus 4 times row 2: row 3 becomes (0,0,1∣−5,4,1)(0, 0, 1 \mid -5, 4, 1).
  4. Row 2 minus 4 times row 3: row 2 becomes (0,1,0∣20,−15,−4)(0, 1, 0 \mid 20, -15, -4).
  5. Row 1 minus 3 times row 3: row 1 becomes (1,2,0∣16,−12,−3)(1, 2, 0 \mid 16, -12, -3).
  6. Row 1 minus 2 times row 2: row 1 becomes (1,0,0∣−24,18,5)(1, 0, 0 \mid -24, 18, 5).
  7. So A−1A^{-1} has rows (−24,18,5)(-24, 18, 5), (20,−15,−4)(20, -15, -4) and (−5,4,1)(-5, 4, 1).

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 2×22 \times 2 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 adj⁡(A)\operatorname{adj}(A):

A−1=1det⁡(A)adj⁡(A)A^{-1} = \frac{1}{\det(A)}\operatorname{adj}(A)

The adjugate formula is useful for theory and for 3×33 \times 3 matrices with simple entries, but it needs nine 2×22 \times 2 determinants for a 3×33 \times 3 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 Ax=bA\mathbf{x} = \mathbf{b} can be solved by multiplying both sides on the left by A−1A^{-1}, giving x=A−1b\mathbf{x} = A^{-1}\mathbf{b}. This mirrors solving 5x=105x = 10 by dividing by 5.

Example 3: a system solved by the inverse

  1. Solve 4x+7y=14x + 7y = 1 and 2x+6y=22x + 6y = 2. The coefficient matrix is AA from Example 1.
  2. x=A−1b\mathbf{x} = A^{-1}\mathbf{b}: x=0.6(1)−0.7(2)=−0.8x = 0.6(1) - 0.7(2) = -0.8 and y=−0.2(1)+0.4(2)=0.6y = -0.2(1) + 0.4(2) = 0.6.
  3. Check: 4(−0.8)+7(0.6)=14(-0.8) + 7(0.6) = 1 and 2(−0.8)+6(0.6)=22(-0.8) + 6(0.6) = 2.

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

(AB)−1=B−1A−1,(AT)−1=(A−1)T,(A−1)−1=A(AB)^{-1} = B^{-1}A^{-1}, \qquad (A^T)^{-1} = (A^{-1})^T, \qquad (A^{-1})^{-1} = A
  • The inverse of a product reverses the order, just as taking off socks and shoes reverses the order you put them on.
  • If AA is invertible, the inverse is unique.
  • det⁡(A−1)=1det⁡(A)\det(A^{-1}) = \frac{1}{\det(A)}.
  • For a nonzero number kk, (kA)−1=1kA−1(kA)^{-1} = \frac{1}{k}A^{-1}.
  • 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 AA−1AA^{-1} 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:

(abcd)(d−b−ca)=(ad−bc00ad−bc)\begin{pmatrix} a & b \\ c & d \end{pmatrix}\begin{pmatrix} d & -b \\ -c & a \end{pmatrix} = \begin{pmatrix} ad - bc & 0 \\ 0 & ad - bc \end{pmatrix}

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 2×22 \times 2 formula.
  • Forgetting to divide by the determinant at the end.
  • Applying a row operation to the left half of [A∣I][A \mid I] but not to the right half.
  • Multiplying b\mathbf{b} on the wrong side: the solution is A−1bA^{-1}\mathbf{b}, and bA−1\mathbf{b}A^{-1} 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 (2,1)(2, 1) and (5,3)(5, 3). Its determinant is 6−5=16 - 5 = 1, so the inverse is simply the swapped-and-negated matrix, with rows (3,−1)(3, -1) and (−5,2)(-5, 2). Second, decide whether the matrix with rows (3,6)(3, 6) and (1,2)(1, 2) is invertible. Its determinant is 6−6=06 - 6 = 0, 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 2x+y=42x + y = 4 and 5x+3y=115x + 3y = 11: multiplying the inverse by the constants gives x=3(4)−11=1x = 3(4) - 11 = 1 and y=−5(4)+2(11)=2y = -5(4) + 2(11) = 2, 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 ABAB applies BB first and then AA. To undo it you must undo AA first, then BB, which gives B−1A−1B^{-1}A^{-1}. Multiplying confirms that (AB)(B−1A−1)=I(AB)(B^{-1}A^{-1}) = I.

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.

MathSolver Pro Editorial Team

Math content and review

Our editorial team writes every guide to explain the reasoning behind each method, not just the answer. Each worked example is checked against the site's own solver engines and automated tests before it is published, and articles are revised whenever a method or an exam format changes.