Inverse Matrix Calculator A-1
Enter a square matrix (2×2 or 3×3), one row per line, numbers separated by spaces or commas. You get the inverse, the determinant, and the adjugate — with the steps and the NumPy code.
This free inverse matrix calculator finds the inverse of a 2×2 or 3×3 matrix instantly, and shows the determinant and adjugate that produce it — so you see the method, not just the answer. Type your square matrix above, press Invert A, and you get A-1 with the working laid out step by step and the matching NumPy code.
What a matrix inverse is
The inverse of a square matrix A is the matrix A-1 that undoes it. Multiplying a matrix by its inverse returns the identity matrix I — the matrix equivalent of the number one:
A × A-1 = A-1 × A = I
It is the direct analogue of the reciprocal for ordinary numbers. Just as 5 × (1/5) = 1, a matrix times its inverse gives the identity. And just as zero has no reciprocal, some matrices have no inverse: those are called singular. Only square matrices — the same number of rows as columns — can ever have an inverse, which is why this inverse matrix calculator asks for a square input.
The core identity
A-1 is the unique matrix for which A times A-1 equals the identity matrix I. If no such matrix exists, A is singular and cannot be inverted.
How to use the inverse matrix calculator
- Enter your matrix as a block of numbers, one row per line, with values separated by spaces or commas. It must be square: a 2×2 matrix has two lines of two numbers, a 3×3 has three lines of three.
- Press Invert A. The inverse appears as a matrix, with the determinant and size shown above it.
- Read the Show the working panel to see the determinant and the adjugate that produced the inverse.
- Adjust Decimal places if you want cleaner fractions rounded to a fixed precision, and use Copy result to grab the inverse as plain text.
If the matrix is singular — determinant zero — the tool tells you plainly that no inverse exists, rather than returning meaningless numbers.
Worked 2×2 example
Take the matrix A = [[4, 7], [2, 6]]. For any 2×2 matrix [[a, b], [c, d]] there is a compact formula:
A-1 = (1 / (ad − bc)) × [[d, −b], [−c, a]]
First compute the determinant, ad − bc = (4)(6) − (7)(2) = 24 − 14 = 10. Because it is not zero, the inverse exists. Swap the two diagonal entries, negate the off-diagonal entries, then divide every element by 10:
A-1 = (1/10) × [[6, −7], [−2, 4]] = [[0.6, −0.7], [−0.2, 0.4]]
You can check the result by multiplying: A × A-1 gives [[1, 0], [0, 1]], the identity, confirming the inverse is correct. The calculator above performs exactly these steps and shows the same answer.
The adjugate and determinant method
The 2×2 shortcut is a special case of a general rule that works for any square matrix:
A-1 = (1 / det A) × adj(A)
Here adj(A) is the adjugate (also called the adjoint): the transpose of the cofactor matrix. Building it takes three steps. First, for each position compute the minor — the determinant of the smaller matrix left after deleting that entry’s row and column. Second, apply the checkerboard sign pattern to turn minors into cofactors: the cofactor in row i, column j is (−1)i+j times the minor. Third, transpose the cofactor matrix — swap rows and columns — to get the adjugate. Divide every entry by the determinant and you have the inverse. This is precisely the algorithm the calculator runs, and the working panel shows the adjugate it built along the way.
When an inverse does not exist
A matrix has an inverse only when its determinant is not zero. If det A = 0, the matrix is singular and cannot be inverted — there is simply no matrix that multiplies with it to give the identity. Geometrically, a singular matrix collapses space onto a lower dimension (a line or a point), and once that information is lost there is no way to reverse the transformation.
A quick way to spot a singular matrix is to look for rows or columns that are multiples of one another. In [[1, 2], [2, 4]] the second row is exactly twice the first, so det = (1)(4) − (2)(2) = 0 and no inverse exists. Try the Singular example above to see how the calculator reports this case.
Before attempting any inversion, check the determinant. If it is zero — or extremely close to zero, which signals a nearly singular, numerically unstable matrix — the inverse is either undefined or unreliable. This calculator treats an absolute determinant below 1e-12 as singular.
The 3×3 method
For a 3×3 matrix the same adjugate-over-determinant recipe applies, just with more arithmetic. The determinant is found by cofactor expansion along the top row: multiply each of the three entries by the determinant of the 2×2 matrix that remains when you cross out its row and column, alternate the signs + − +, and add. Then every one of the nine cofactors is a signed 2×2 minor, the cofactor matrix is transposed into the adjugate, and each entry is divided by the determinant. Doing this by hand is error-prone, which is exactly where the calculator earns its keep — enter the nine numbers and read off the inverse.
Inverting a matrix in Python with NumPy
In real work you will invert matrices in code. NumPy does it in one line with numpy.linalg.inv:
import numpy as np
A = np.array([[4, 7], [2, 6]])
A_inv = np.linalg.inv(A)
print(A_inv) # [[ 0.6 -0.7] [-0.2 0.4]]
# verify:
print(A @ A_inv) # identity matrix
If the matrix is singular, np.linalg.inv raises a LinAlgError — NumPy’s way of telling you the same thing this calculator does. One important note: in practice you rarely need an explicit inverse. To solve a linear system Ax = b, prefer np.linalg.solve(A, b) over computing inv(A) @ b; it is faster and numerically more accurate, because forming the inverse explicitly amplifies rounding error.
Where the inverse matrix shows up in machine learning
The matrix inverse sits at the heart of classical machine learning. The most famous appearance is the normal equation for linear regression, which solves for the best-fit coefficients in closed form:
θ = (XTX)-1 XTy
That (XTX)-1 is a matrix inverse, and it is why ordinary least squares has an exact solution rather than needing iteration. Inverses also appear when solving general linear systems, computing the covariance-based Mahalanobis distance, whitening data, and in the update rules of Gaussian processes and Kalman filters. Whenever a model needs to “undo” a linear transformation or solve for parameters directly, an inverse (or a smarter equivalent like a matrix solve) is doing the work. Understanding what the inverse means makes those formulas far less mysterious.
Common mistakes to avoid
Three errors trip up most learners. First, trying to invert a non-square matrix — only square matrices have inverses; rectangular matrices have pseudo-inverses instead. Second, forgetting to check the determinant and then puzzling over garbage output from a singular matrix. Third, mixing up the adjugate transpose: the adjugate is the transpose of the cofactor matrix, and skipping that transpose gives a wrong answer for anything larger than the symmetric 2×2 shortcut. When in doubt, verify your result by multiplying A × A-1 and confirming you get the identity matrix.
Frequently asked questions
Which matrices can be inverted?
Only square matrices with a non-zero determinant. A square matrix whose determinant is zero is singular and has no inverse; non-square matrices never have a true inverse.
What does it mean if the determinant is zero?
A zero determinant means the matrix is singular. Its rows or columns are linearly dependent, it collapses space onto a lower dimension, and no inverse exists.
How do I check my inverse is correct?
Multiply the original matrix by your inverse. If you get the identity matrix — ones on the diagonal, zeros elsewhere — the inverse is correct.
Does this match NumPy’s result?
Yes. The inverse returned here matches numpy.linalg.inv exactly, because both use the determinant and adjugate (equivalently, the same underlying linear algebra).
Can it handle larger matrices than 3×3?
This tool covers 2×2 and 3×3 matrices, the sizes most common in learning and hand calculation. For larger matrices, use numpy.linalg.inv or a matrix solve in code.
Related linear algebra calculators
Explore the full linear algebra calculators hub, or keep building your toolkit with the matrix multiplication calculator and the matrix determinant calculator.