Linear algebra
Determinant and inverse matrix calculator
Enter a square matrix and get the determinant, the rank and the inverse matrix, with an immediate check on invertibility.
What the determinant is for
The determinant is a number attached to a square matrix that captures one decisive property: if it is zero the matrix is singular, meaning its rows (or columns) are linearly dependent and the transformation it represents collapses space into a lower dimension. If it is non-zero the matrix is invertible, the associated linear system has a unique solution, and the transformation can be undone.
Geometrically the absolute value of the determinant is the volume scale factor: a 2 × 2 matrix with determinant 3 turns a unit square into a parallelogram of area 3. The sign says whether orientation is preserved or flipped. A zero determinant means area or volume is wiped out entirely, which is exactly the geometric picture of linear dependence.
Cofactor expansion, the method taught in class, has factorial cost and becomes impractical beyond 9 × 9 matrices. This calculator uses Bareiss elimination, a variant of Gaussian elimination that keeps every intermediate division exact: on a matrix of whole numbers the determinant is computed in arbitrary-precision arithmetic and the result is exact, free of the rounding errors typical of floating-point work.
The inverse exists only when the determinant is non-zero, and it is obtained by reducing the matrix side by side with the identity: the same elementary operations are applied to both until the first becomes the identity, at which point the second is the inverse. The rank, shown next to the determinant, says how many rows are genuinely independent: for an invertible n × n matrix it is exactly n.
Common mistakes
- Taking the determinant of a non-square matrix: the operation is undefined, you need as many rows as columns.
- Treating Sarrus' rule as a general method: it works only for 3 × 3 matrices and gives wrong answers at higher sizes.
- Forgetting that swapping two rows flips the sign of the determinant, while adding a multiple of one row to another leaves it unchanged.
- Assuming the determinant of a sum is the sum of the determinants: it is not. What is true is that det(AB) = det(A) × det(B).
- Treating a matrix with a very small but non-zero determinant as safely invertible: it is invertible in principle, but ill-conditioned, and the inverse amplifies every error in the data.
Frequently asked questions
How do you calculate the determinant of a 2 × 2 matrix?
Multiply the entries on the main diagonal and subtract the product of the other diagonal: for [[a, b], [c, d]] the determinant is ad − bc. For 3 × 3 matrices you can use Sarrus' rule, and beyond that Gaussian elimination is the practical method.
What does a zero determinant mean?
That the matrix is singular: the rows are linearly dependent, no inverse exists, and the associated linear system has no unique solution. Geometrically the transformation reduces the dimension of space, collapsing areas or volumes.
When does the inverse matrix exist?
Only for square matrices with a non-zero determinant. In that case the inverse is unique and satisfies A × A⁻¹ = A⁻¹ × A = I, where I is the identity matrix of the same order.
How are the determinant and the rank related?
For an n × n matrix the determinant is non-zero if and only if the rank is n, that is if all the rows are independent. A lower rank always implies a zero determinant, and it tells you how many rows really are independent.
Is the result exact or approximate?
If every entry is a whole number the determinant is computed in exact arbitrary-precision arithmetic, so it is exact. With decimal entries the work is done in floating point and the result carries a small rounding error.
How this calculation works
The determinant is computed with Bareiss fraction-free elimination, at O(n³) cost: at each step the entry at (i, j) becomes (m[i][j] × m[k][k] − m[i][k] × m[k][j]) divided by the previous pivot, and every division is exact. Each row swap flips the sign. On all-integer matrices the work is done in arbitrary-precision arithmetic. The inverse comes from reducing [A | I] to reduced row echelon form: when the left half becomes the identity, the right half is A⁻¹.
Related calculators
Matrices and vectors
Addition, product, determinant, transpose, dot product and magnitude for matrices and vectors.
Systems of linear equations
Gauss-Jordan elimination: unique solution, infinitely many solutions or no solution.
Eigenvalues and eigenvectors
Characteristic polynomial, real and complex eigenvalues, eigenvectors and trace.
Vector mathematics
Dot and cross products, the angle between two vectors, projection and areas.