Calculus, Linear Algebra & Discrete Math Matrices & Linear Algebra Laplace cofactor expansion and LU factorisation

Matrix Determinant Calculator (2×2, 3×3, n×n)

Enter a square matrix row by row and this calculator returns its determinant, expanded along the first row so you can follow every cofactor term, and cross-checked against the product of the pivots from LU elimination. It also reports the rank and tells you plainly whether the matrix is singular. Matrices up to 5×5 are supported — leave the trailing rows blank for anything smaller, and the size is read from what you type.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
Row 1Separate entries with commas or spaces. Fractions such as 3/4 are accepted. Leave a row blank if your matrix is smaller.3, 1, 4, 1
Row 2Separate entries with commas or spaces. Fractions such as 3/4 are accepted. Leave a row blank if your matrix is smaller.5, 9, 2, 6
Row 3Separate entries with commas or spaces. Fractions such as 3/4 are accepted. Leave a row blank if your matrix is smaller.5, 3, 5, 8
Row 4Separate entries with commas or spaces. Fractions such as 3/4 are accepted. Leave a row blank if your matrix is smaller.9, 7, 9, 3
Row 5Only needed for a 5×5 matrix. Separate entries with commas or spaces. Fractions such as 3/4 are accepted. Leave a row blank if your matrix is smaller.

It returns

  • Determinant det A — Zero means singular: no inverse, dependent rows.
  • Rank — The number of linearly independent rows, defined for any shape.
  • Trace (sum of the diagonal)
  • Volume scale factor |det A| — The factor by which the map multiplies n-dimensional volume.

The formula

detA=j=1n(1)1+ja1jM1j
det[abcd]=adbc
detA=(1)si=1nuii

In plain text: det A = Σⱼ (−1)^(1+j) · a₁ⱼ · M₁ⱼ

  • a₁ⱼThe entry in row 1, column j (—)
  • M₁ⱼThe minor: the determinant of A with row 1 and column j deleted (—)
  • (−1)^(1+j)The checkerboard sign, +1 for odd j and −1 for even j (—)
  • nThe size of the square matrix (—)

The expansion may be taken along any row or column; the first row is conventional. The answer never depends on the choice.

Updated Category Matrices & Linear Algebra Verified against published test cases Reading time 10 min

What the determinant tells you

The determinant is one number that answers several questions at once. Geometrically it is the signed factor by which the linear map scales area in two dimensions, volume in three, and hypervolume beyond. Take the unit square, apply the matrix [[3,0],[0,2]], and you get a 3-by-2 rectangle: the determinant is 6, and that is the area. The sign records orientation — a negative determinant means the map has flipped the plane over, turning a counter-clockwise loop into a clockwise one.

Algebraically the determinant answers the only question that usually matters: is the matrix invertible? A determinant of zero means the map has collapsed space onto something thinner — a plane onto a line, a line onto a point — and collapse cannot be undone, so no inverse exists. Every equivalent statement follows: the rows are linearly dependent, the columns fail to span, the homogeneous system Ax = 0 has solutions other than zero, and zero is an eigenvalue.

That is why the determinant appears as a gatekeeper everywhere. Cramer's rule divides by it. The characteristic polynomial that produces eigenvalues is det(A − λI) = 0. The change-of-variables formula for multiple integrals multiplies by the absolute value of the Jacobian determinant. In each case a zero determinant is the signal that the construction has broken down.

Two ways to compute it, and when to use each

Cofactor (Laplace) expansion is the definition you learn first. Walk along the first row; for each entry, multiply it by the determinant of the smaller matrix you get by deleting its row and column, attach the checkerboard sign (−1)1+j, and add the results. For a 3×3 this is three 2×2 determinants and takes under a minute by hand.

It scales terribly. A cofactor expansion of an n×n matrix costs on the order of n! multiplications: 6 for a 3×3, 24 for a 4×4, 120 for a 5×5, and about 3.6 million for a 10×10. Nobody computes a large determinant this way.

Elimination is what every numerical library does. Row-reduce to upper-triangular form, tracking two things: each row swap flips the sign, and each row scaling divides the determinant by the same factor. A triangular matrix has determinant equal to the product of its diagonal, so the answer falls out at the end. The cost is about n³/3 operations — 333 for a 10×10 instead of 3.6 million.

This calculator does both. The cofactor table is there so you can follow the reasoning; the LU pivot table is there as an independent cross-check on the same number. When they agree, as they do for every well-conditioned matrix, you can be confident in the result.

One property is worth memorising because it makes many determinants free: if the matrix is triangular, the determinant is just the product of the diagonal. Row operations of the type “add a multiple of one row to another” leave the determinant completely unchanged, which is precisely why elimination works.

Worked example: the 3×3 matrix [[6, 1, 1], [4, −2, 5], [2, 8, 7]]

Expand along the first row. Three minors, three signs.

  1. First term, j = 1. Delete row 1 and column 1, leaving [[−2, 5], [8, 7]]. Its determinant is (−2)(7) − (5)(8) = −14 − 40 = −54. The sign is (−1)1+1 = +1, and the entry is 6, so the contribution is +6 × (−54) = −324.
  2. Second term, j = 2. Delete row 1 and column 2, leaving [[4, 5], [2, 7]]. Its determinant is (4)(7) − (5)(2) = 28 − 10 = 18. The sign is (−1)1+2 = −1, and the entry is 1, so the contribution is −1 × 18 = −18.
  3. Third term, j = 3. Delete row 1 and column 3, leaving [[4, −2], [2, 8]]. Its determinant is (4)(8) − (−2)(2) = 32 + 4 = 36. The sign is (−1)1+3 = +1, and the entry is 1, so the contribution is +36.
  4. Add them. −324 − 18 + 36 = −306.

Now check it by elimination. Subtract ⅔ of row 1 from row 2 and ⅓ of row 1 from row 3: the matrix becomes [[6, 1, 1], [0, −8/3, 13/3], [0, 23/3, 20/3]]. Add 23/8 of the new row 2 to row 3: the (3,3) entry becomes 20/3 + (23/8)(13/3) = 20/3 + 299/24 = 160/24 + 299/24 = 459/24. The diagonal product is 6 × (−8/3) × (459/24) = −16 × 459/24 = −306, with no row swaps and therefore no sign change. The two methods agree.

The determinant is not zero, so this matrix is invertible, its three rows are linearly independent, and it scales volume by a factor of 306 while reversing orientation.

How to read your answer

Zero is the only special value. Everything else is a matter of degree. A determinant of exactly zero means singular; anything non-zero means invertible, and the size of the number by itself tells you nothing about how well-behaved the inverse will be.

That last point catches people out. It is tempting to read a small determinant as “nearly singular”, but the determinant scales like the n-th power of the matrix entries: multiply every entry of a 10×10 matrix by 0.1 and the determinant falls by a factor of 1010 while the matrix is exactly as invertible as before. The honest measure of near-singularity is the condition number, which the matrix inverse calculator reports.

Compare the determinant with the rank. For an n×n matrix, det ≠ 0 is equivalent to rank = n. When the determinant is zero, the rank tells you how badly: rank n−1 means the map collapsed one dimension, rank 1 means everything landed on a single line. That is why the rank is shown here even for matrices that have no determinant at all.

Use the sign. In computer graphics a negative determinant on a transform means the winding order of your triangles has reversed and back-face culling will hide the wrong faces. In a change of variables you take the absolute value, which is exactly why the Jacobian formula has bars around it.

Determinant properties worth knowing by heart

Each property either saves you an entire calculation or protects you from a common error.
PropertyStatementWhy it matters
Triangulardet = product of the diagonalMakes elimination the practical method
Row swapFlips the signPartial pivoting must track swaps
Row additionAdding a multiple of one row to another changes nothingElimination is free of side effects
Row scalingMultiplying one row by k multiplies det by kScaling a whole n×n matrix by k multiplies det by kⁿ
Duplicate rowsdet = 0Instant singularity test
Productdet(AB) = det(A)·det(B)Composing maps multiplies volume factors
Transposedet(Aᵀ) = det(A)You may expand along a column instead
Inversedet(A⁻¹) = 1/det(A)Undoing a map divides the volume factor
Identitydet(I) = 1The map that changes nothing scales nothing

The row-scaling rule is the one most often misapplied: doubling every entry of a 3×3 matrix multiplies its determinant by 8, not by 2.

Mistakes that produce a wrong determinant

  • Forgetting the checkerboard sign. The middle term of a 3×3 first-row expansion is subtracted. Writing +a₁₂M₁₂ is the single most common arithmetic slip in the topic.
  • Using the rule of Sarrus on a 4×4. The diagonal-stripes trick works for 3×3 only. There is no 4×4 version, and inventing one gives a number that is not the determinant.
  • Scaling a row during elimination and not dividing it out. Adding a multiple of one row to another is free; multiplying a row by k is not. Track it or avoid it.
  • Reading a small determinant as nearly singular. It scales as the n-th power of your units. Use the condition number for that judgement.
  • Asking for the determinant of a non-square matrix. It does not exist. What you probably want is the rank, or the determinant of AᵀA if you are heading toward a least-squares problem.
  • Trusting a floating-point zero. With decimal entries, elimination can return 1e−17 where the exact answer is 0. Judge singularity against the size of the matrix entries, not against zero.

Why the calculator shows two methods

The cofactor table and the LU pivot table compute the same number by completely different routes. Agreement between them is a genuine check on the arithmetic, and disagreement in the last digits is itself informative: it means the matrix is ill-conditioned and elimination has lost precision. For integer matrices, cofactor expansion is exact, which is why it is the value reported.

Where the determinant leads

Once you know the determinant is non-zero, the natural next steps are all available. The matrix inverse calculator uses the adjugate divided by exactly this determinant for small matrices, and Gauss-Jordan elimination for larger ones. Cramer's rule solves a linear system as a ratio of determinants, replacing one column at a time with the right-hand side — elegant for a 2×2 or 3×3, hopeless beyond that. For a general system, row reduction to RREF is faster and also tells you what happens when the determinant is zero.

Determinants also drive the spectral side of linear algebra. Setting det(A − λI) = 0 produces the characteristic polynomial whose roots are the eigenvalues, and the constant term of that polynomial is the determinant itself — which is why the determinant always equals the product of the eigenvalues. The trace, shown alongside, equals their sum.

In three dimensions, the determinant of the 3×3 matrix built from three vectors is their scalar triple product, the signed volume of the parallelepiped they span; the top row of that determinant expansion is exactly the cross product. And LU decomposition gives you the pivot product directly if the factorisation itself is what you need.

Frequently asked questions

What does a determinant of zero mean?

It means the matrix is singular: it has no inverse, its rows are linearly dependent, and the linear map it represents collapses space onto a lower dimension. Practically, a system Ax = b with a zero determinant either has no solution or infinitely many, never exactly one. The rank shown alongside tells you how many dimensions survived the collapse.

How big a matrix can this handle?

Up to 5×5. Type one row per box and leave the rest blank; the size is read from what you enter, so a 3×3 needs only the first three boxes filled with three entries each. Beyond 5×5, cofactor expansion is no longer a sensible thing to display — a 6×6 has 720 terms — and elimination is the only practical route.

Can I enter fractions or decimals?

Yes to both. Write fractions with a slash, as in 3/4 or -1/2, and decimals normally. Separate entries with commas or spaces. When every entry is a whole number the determinant is reported exactly; with decimal entries you get a floating-point result and the calculator says so.

Why is the determinant of my triangular matrix just the diagonal product?

Because every cofactor expansion below the diagonal hits a zero. Expand a lower-triangular matrix along its first row: only a₁₁ is non-zero, so the whole determinant is a₁₁ times the determinant of the smaller triangular matrix beneath it, and the argument repeats. This property is what makes elimination the standard algorithm — you reduce to triangular form and read off the product.

Is det(A + B) equal to det(A) + det(B)?

No, and this is the most common false assumption about determinants. Try A = B = the 2×2 identity: det(A) + det(B) = 2, but A + B = [[2,0],[0,2]] whose determinant is 4. The determinant is multiplicative, not additive: det(AB) = det(A)·det(B) is true, and it is the property you should reach for instead.

What is a normal value for a determinant?

There is no normal value, because the determinant carries the n-th power of whatever scale your entries have. A matrix of entries around 10 in size will typically have a 3×3 determinant in the hundreds or thousands purely from the scaling. Judge it relative to your data: compare |det| against the product of the row lengths, which equals |det| exactly when the rows are mutually perpendicular and exceeds it otherwise.

Why do I get a tiny non-zero determinant for a matrix I know is singular?

Floating-point rounding. If your entries are decimals, elimination accumulates rounding error and a true zero can come out as 1e−16. The calculator uses exact cofactor arithmetic on integer matrices to avoid this, and flags anything below a threshold scaled to the size of your entries as singular. If you know your matrix should be exact, enter the entries as fractions rather than rounded decimals.

Does the determinant tell me if a system has a unique solution?

Yes, for a square system. Non-zero determinant means exactly one solution, for any right-hand side. Zero means either no solution or infinitely many, and the determinant alone cannot distinguish those two — for that you need to compare the rank of the coefficient matrix with the rank of the augmented matrix, which the RREF calculator does for you.

References

  • Introduction to Linear Algebra, 5th ed., chapter 5 (Determinants) — Gilbert Strang, Wellesley-Cambridge Press
  • Matrix Computations, 4th ed., §3.2 (The LU Factorization) — Gene H. Golub and Charles F. Van Loan, Johns Hopkins University Press
  • Linear Algebra and Its Applications, 5th ed., chapter 3 — David C. Lay, Steven R. Lay and Judi J. McDonald, Pearson