What this calculator does
This tool computes the inverse of a square n by n real matrix A. The inverse \(A^{-1}\) is the unique matrix that satisfies \(A \times A^{-1} = I\), the identity matrix. Not every matrix has an inverse: only square matrices whose determinant is non-zero (non-singular matrices) are invertible. If your matrix is singular, the calculator tells you so instead of returning meaningless numbers.
How to use it
Pick the matrix size \(n\) from the dropdown, which resizes the input grid to \(n\) rows and \(n\) columns. Type a real number into every cell of matrix A. Choose how many significant digits you want in the displayed result, then read off the inverse matrix, its determinant, and the method used. The significant-digits setting only affects display rounding, not the internal computation, which always runs in full double precision.
The method explained
The calculator uses LU decomposition with partial pivoting. First it factors the matrix as \(PA = LU\), where P is a permutation matrix that swaps rows to keep the largest available pivot on the diagonal (this improves numerical stability and avoids dividing by tiny numbers), L is unit lower-triangular, and U is upper-triangular. Then, for each column \(e_k\) of the identity, it solves $$L y = P e_k$$ by forward substitution and $$U x = y$$ by back substitution; the resulting \(x\) is the k-th column of \(A^{-1}\). The determinant is the product of the U diagonal entries times the sign of the row permutation:
$$\det(A) = (-1)^{s}\prod_{k=1}^{n} U_{kk}$$
Worked example
Take \(A = \begin{bmatrix} 4 & 3 \\ 6 & 3 \end{bmatrix}\). Its determinant is $$4 \times 3 - 3 \times 6 = 12 - 18 = -6,$$ which is non-zero so A is invertible. Using the closed form for 2 by 2 matrices, $$A^{-1} = \frac{1}{\det} \begin{bmatrix} 3 & -3 \\ -6 & 4 \end{bmatrix} = \begin{bmatrix} -0.5 & 0.5 \\ 1 & -0.6666666667 \end{bmatrix}.$$ Multiplying A by this inverse returns the identity matrix, confirming the answer.
FAQ
What happens if my matrix is singular? If the determinant is zero (within a tiny tolerance), the matrix has no inverse and the calculator displays a "singular / not invertible" message.
Why use LU decomposition instead of the adjugate formula? LU with partial pivoting is far more numerically stable and efficient for larger matrices than cofactor expansion, which grows factorially in cost.
Do the significant-digit choices change the math? No. The computation is always done in full precision; the setting only controls how many significant figures are shown.