TSE.
MathematicsFinanceHealthPhysicsEngineeringBrowse all

Mathematics · Linear Algebra · Linear Algebra

Matrix Inverse Calculator

Calculates the inverse of a 2×2 or 3×3 matrix using the adjugate and determinant method.

Calculator

Advertisement

Formula

A^{-1} is the inverse matrix. det(A) is the determinant of matrix A — if det(A) = 0, the matrix is singular and has no inverse. adj(A) is the adjugate (classical adjoint) of A, formed by transposing the matrix of cofactors. For a 2×2 matrix A = [[a,b],[c,d]], det(A) = ad - bc and A^{-1} = (1/(ad-bc)) * [[d,-b],[-c,a]].

Source: Gilbert Strang, Introduction to Linear Algebra, 5th Edition, Wellesley-Cambridge Press.

How it works

A square matrix A has an inverse A⁻¹ if and only if its determinant is non-zero (det(A) ≠ 0). The inverse satisfies the identity A · A⁻¹ = A⁻¹ · A = I, where I is the identity matrix. A matrix with det(A) = 0 is called singular or degenerate and cannot be inverted — this typically indicates that the rows or columns of the matrix are linearly dependent.

The general formula for the matrix inverse is A⁻¹ = (1/det(A)) · adj(A), where adj(A) is the adjugate matrix — the transpose of the cofactor matrix of A. For a 2×2 matrix A = [[a, b], [c, d]], the inverse simplifies elegantly to A⁻¹ = (1/(ad − bc)) · [[d, −b], [−c, a]]. For a 3×3 matrix, each element of the adjugate is computed as the signed minor of the corresponding transposed element, requiring nine cofactor calculations before dividing by the determinant.

Matrix inversion is applied across virtually every quantitative discipline. In engineering, it appears in finite element analysis and control system design. In machine learning, it underlies the normal equation for linear regression: θ = (XᵀX)⁻¹Xᵀy. In economics, input-output models use matrix inverses to determine how changes in final demand ripple through sectors. In computer graphics, inverse matrices are used to reverse geometric transformations such as rotation, scaling, and projection.

Worked example

2×2 Example: Suppose A = [[4, 7], [2, 6]]. First compute the determinant: det(A) = (4)(6) − (7)(2) = 24 − 14 = 10. Since det ≠ 0, the inverse exists. Applying the 2×2 formula: A⁻¹ = (1/10) · [[6, −7], [−2, 4]] = [[0.6, −0.7], [−0.2, 0.4]]. Verify: A · A⁻¹ = [[4·0.6 + 7·(−0.2), 4·(−0.7) + 7·0.4], [2·0.6 + 6·(−0.2), 2·(−0.7) + 6·0.4]] = [[1, 0], [0, 1]] ✓

3×3 Example: Let A = [[1, 2, 3], [0, 1, 4], [5, 6, 0]]. Compute det(A) = 1·(1·0 − 4·6) − 2·(0·0 − 4·5) + 3·(0·6 − 1·5) = 1·(−24) − 2·(−20) + 3·(−5) = −24 + 40 − 15 = 1. Because det = 1, the inverse is simply equal to the adjugate matrix. The nine cofactors are computed, transposed, and since det = 1, divided by 1. The resulting inverse is A⁻¹ = [[−24, 18, 5], [20, −15, −4], [−5, 4, 1]], which can be verified by confirming A · A⁻¹ = I.

Limitations & notes

This calculator handles only square 2×2 and 3×3 matrices. Non-square matrices do not have standard inverses — they may have a Moore-Penrose pseudoinverse, which is a separate computation. If the determinant is exactly zero or extremely close to zero, the matrix is singular or ill-conditioned: the calculator will return NaN to signal no inverse exists. Numerically, near-singular matrices (very small determinants) can produce large round-off errors in floating-point arithmetic, making the computed inverse unreliable in practice. For larger matrices (4×4 and beyond), Gaussian elimination or LU decomposition are preferred for numerical stability. Additionally, this calculator does not support complex-valued matrix entries.

Frequently asked questions

What does it mean if the determinant is zero?

A zero determinant means the matrix is singular — it has no inverse. This occurs when one row (or column) is a linear combination of the others, making the system of equations either inconsistent or underdetermined. In practice, this signals redundancy or dependency in your model.

How do I verify that a computed matrix inverse is correct?

Multiply your original matrix A by the computed inverse A⁻¹. If the result is the identity matrix (1s on the diagonal, 0s elsewhere), the inverse is correct. Small floating-point deviations (e.g., 0.9999999 instead of 1) are normal in numerical computation.

What is the difference between the inverse and the transpose of a matrix?

The transpose A^T simply flips the matrix across its main diagonal (rows become columns). The inverse A⁻¹ is the matrix that, when multiplied by A, gives the identity matrix. For orthogonal matrices (common in rotation), the transpose equals the inverse — but this is a special case, not the general rule.

Can I use this calculator to solve a system of linear equations?

Yes. If your system is Ax = b, then the solution is x = A⁻¹b. Compute A⁻¹ using this calculator, then multiply each row of A⁻¹ by the column vector b. This method works well for small systems but is computationally expensive for large ones compared to direct methods like LU factorization.

What is an ill-conditioned matrix and why does it matter?

An ill-conditioned matrix has a very small determinant relative to its entries, meaning small changes in input cause very large changes in the inverse. The condition number (ratio of largest to smallest singular value) quantifies this. Ill-conditioned matrices arise frequently in regression when predictor variables are highly correlated (multicollinearity), and their inverses should be interpreted with caution.

Last updated: 2025-01-15 · Formula verified against primary sources.