Lelifi·tools

Cofactor Determinant Calculator

A cofactor expansion writes a determinant as one row of entries times their signed minors. For the 3x3 matrix with rows 2,-1,3 and 0,4,1 and 5,2,-1 the three terms are -12, -5 and -60, so the determinant is -77.

Decimals and negative entries are fine. Every calculation runs in your browser and nothing is uploaded.

Enter a 2x2, 3x3 or 4x4 matrix to see its determinant built term by term from minors and cofactors, with the expansion shown for every row and column.

By the Lelifi editors ·

Key takeaways

Cofactor sign board, (-1) to the power i plus jcolumn 1column 2column 3column 4+-+--+-++-+--+-+C(2,3) sits on a minus square, so the minor is multiplied by -1
The alternating signs for a 4x4 matrix. The top left corner is always plus, and each step right or down flips the sign.
Deleting row 1 and column 2 leaves a 2 by 2 minor2-1304152-1what remains015-1M(1,2) = 0 x (-1) - 1 x 5 = -51 plus 2 is odd, so C(1,2) = -M(1,2) = 5
Deleting row 1 and column 2 from the 3x3 matrix leaves the 2x2 minor M(1,2), which equals -5. The odd sum i plus j then flips it to a cofactor of 5.
On this page
  1. What a cofactor is
  2. Expanding a determinant along a row or a column
  3. Worked example: a 2x2 and a 3x3
  4. Worked example: a 4x4 where a whole column is zero
  5. Picking the cheapest line
  6. What the number tells you
  7. Minors, cofactors and the adjugate
  8. Checking an answer without redoing the work

What a cofactor is

A cofactor is a smaller determinant wearing a sign. Pick an entry a(i,j) in a square matrix, cross out row i and column j, and take the determinant of what is left. That leftover value is the minor M(i,j). Multiply it by plus one or minus one and you have the cofactor C(i,j).

In symbols: C(i,j) = (-1)^(i+j) M(i,j). The exponent decides only a sign, so the hard part of any cofactor is still a plain determinant, one size smaller.

The signs form a checkerboard that always starts with plus in the top left corner. The grid below is the pattern for a 4x4 matrix. Each row is the row above it with every sign flipped, so the whole board follows from the top left corner.

LineSign patternExample
Row 1+ - + -C(1,2) is the row 1, column 2 cofactor, and it carries a minus
Row 2- + - +C(2,2) is the row 2, column 2 cofactor, and it carries a plus
Row 3+ - + -C(3,1) carries a plus because 3 plus 1 is 4, an even number
Row 4- + - +C(4,3) carries a minus because 4 plus 3 is 7, an odd number

One small matrix shows the rule at work. For the 2x2 with rows 3, -2 and -5, 4, the minor M(1,1) is 4 and 1 plus 1 is even, so C(1,1) = 4. The minor M(1,2) is -5 and 1 plus 2 is odd, so C(1,2) = -(-5) = 5. No arithmetic changed between those two steps. Only the sign did.

Expanding a determinant along a row or a column

Laplace expansion in one line

The expansion turns a determinant into a sum along a single line. Fix a row i and add the entry times its cofactor for every column: det(A) = a(i,1) C(i,1) + a(i,2) C(i,2) + ... + a(i,n) C(i,n). Fix a column instead and the same sum runs down the rows. Both produce the same number, and that is not a coincidence. It is the content of Laplace's formula.

Two facts make the method practical. Every one of the 2n lines gives the identical total, so the choice of line is free. And because the cofactors already carry the alternating signs, the terms are added exactly as they come out. There is no separate sign to patch in afterwards, which is where most hand calculations go wrong.

The MIT OpenCourseWare 18.06 course builds the same result from the volume interpretation of a determinant, and the Wolfram MathWorld entry on the determinant states the expansion in the same form. If you want the linear algebra behind it rather than the recipe, the MIT 18.06 materials are free and start from first principles.

Worked example: a 2x2 and a 3x3

Small sizes first. Take the 2x2 matrix with rows 3, -2 and -5, 4. Expanding along the first row gives 3 x 4 = 12 for the first term and (-2) x (-5) = 10 for the second, with a minus between them: 12 - 10 = 2. The familiar ad minus bc rule is a cofactor expansion that nobody bothers to name.

Now the 3x3 matrix with rows 2, -1, 3 and 0, 4, 1 and 5, 2, -1. A 3x3 needs nine minors, one for each entry, and each is a 2x2 determinant. The table lists them by position.

MinorColumn 1Column 2Column 3
Row 1M(1,1) = -6M(1,2) = -5M(1,3) = -20
Row 2M(2,1) = -5M(2,2) = -17M(2,3) = 9
Row 3M(3,1) = -13M(3,2) = 2M(3,3) = 8

Expanding along row 1 uses the first row of that table. The first term is 2 x (-6) = -12, the second is (-1) x 5 = -5, the third is 3 x (-20) = -60. Adding the three: -12 - 5 - 60 = -77.

The calculator at the top of the page chooses the line with the most zeros, and row 2 of this matrix starts with a zero, so its step list begins with a term that drops out and carries two live terms. The total it prints is the same -77, which is the point of the rule that any line works.

Expanding along column 3 is the check. Its terms are 3 x (-20) = -60. Then 1 x (-9) = -9. Then (-1) x 8 = -8. Written in a different order, they still total -77. When two lines disagree, an arithmetic slip has happened somewhere, and the calculator prints all of them side by side so you can see which one broke.

Worked example: a 4x4 where a whole column is zero

A 4x4 by hand is where zeros pay for themselves. Take the matrix with rows 1, 0, 2, -1 and 3, 0, 0, 5 and 2, 1, 4, -3 and 1, 0, 5, 0. Column 2 reads 0, 0, 1, 0, so three of its four terms vanish before any arithmetic starts.

Only a(3,2) = 1 survives. Its sign is (-1) to the power 5, which is -1, so the whole determinant equals -1 times the minor M(3,2). Deleting row 3 and column 2 leaves the 3x3 with rows 1, 2, -1 and 3, 0, 5 and 1, 5, 0. That minor expands to -25 + 10 - 15, which is -30: the first term is 1 x (0 x 0 - 5 x 5), the second is -2 x (3 x 0 - 5 x 1), and the third is -1 x (3 x 5 - 0 x 1).

Put the sign back and the answer is -1 x (-30) = 30. The calculator works with the signed cofactor directly, so it shows that same term as 1 x 30 = 30 instead of naming the minor first.

Ten entry products did the whole job: nine inside the 3x3 minor and one for the outer multiply. Expanding along row 1 needs three 3x3 minors, so 30 products, and a 4x4 with no zeros anywhere in the chosen line needs the full 40. That gap is the reason the calculator picks the line with the most zeros for you.

LineEntries on that lineNonzero terms
Row 11, 0, 2, -13
Row 23, 0, 0, 52
Row 32, 1, 4, -34
Row 41, 0, 5, 02
Column 11, 3, 2, 14
Column 20, 0, 1, 01
Column 32, 0, 4, 53
Column 4-1, 5, -3, 03

Picking the cheapest line

Cost grows fast

Cofactor expansion is not the fastest way to compute a determinant. It is the easiest way to explain one, and for sizes up to 4x4 it is often the quickest by hand. The cost table below counts the entry products a straight expansion needs when every minor is worked out on its own.

Matrix sizeTerms in the chosen lineEntry products
2 x 222
3 x 339
4 x 4440
5 x 55205

The jump from 40 to 205 is the reason nobody expands a 10x10 by hand. Row reduction reaches the same determinant in a time that grows with the cube of the size instead of the factorial, which is what computer algebra systems use. For a 4x4 on paper, expansion with a good choice of line beats a page of row operations.

Choosing well is a one minute exercise. Count the zeros in each row and each column, and expand along the line with the most of them. A line with three zeros out of four reduces a 4x4 to a single 3x3. A line with no zeros at all forces four minors. When two lines tie, prefer the one whose entries are small, since the products stay short.

What the number tells you

A determinant is a single number that answers several questions at once.

A determinant of zero means the matrix is singular. Its rows are linearly dependent, it has no inverse, and a linear system built from it has either no solution or infinitely many. A nonzero determinant means the matrix is invertible and the system has exactly one solution, which is the condition Cramer's rule needs before it can be used.

The absolute value measures volume. The 3x3 matrix whose determinant is -77 maps the unit cube to a shape with volume 77, and the 4x4 above, with determinant 30, scales volumes by 30. The sign records orientation: a negative determinant means the map flips the shape over, the way a mirror does.

Three identities let you shortcut a lot of work. The determinant of a product is the product of the determinants, so det(AB) = det(A) x det(B). The determinant of a transpose equals the determinant of the original, which is why expanding along a column is legal at all. And the determinant of a triangular matrix is just the product of its diagonal, so a matrix with 2, 3 and 4 on the diagonal and anything above it has determinant 2 x 3 x 4 = 24.

Minors, cofactors and the adjugate

The four objects people mix up

Four related objects appear in the same chapter of every linear algebra book, and their names get swapped in a hurry. The table gives the definition and the size of each.

ObjectDefinitionShapeUsed for
Minor M(i,j)Determinant left after deleting row i and column j(n-1) x (n-1)Building cofactors
Cofactor C(i,j)(-1)^(i+j) times the minorA single numberDeterminant expansion, inverse
Cofactor matrixAll n squared cofactors kept in their positionsn x nOne step before the adjugate
Adjugate adj(A)Transpose of the cofactor matrixn x nInverse through adj(A) / det(A)

Two mistakes account for most lost marks here. The first is forgetting the transpose: the adjugate is the cofactor matrix flipped over its diagonal, not the cofactor matrix itself. The second is dividing by a zero determinant, which is undefined rather than infinite, because a singular matrix has no inverse at all.

For the 2x2 above with determinant 2, the cofactor matrix is 4, 5 and 2, 3 read by rows, and its transpose swaps the two off diagonal entries. Dividing each entry by 2 gives the inverse, whose top left entry is 2 and whose lower left entry is 2.5. Multiplying the original by that inverse returns the identity, which is the check worth doing once by hand.

Checking an answer without redoing the work

You do not need to recompute every minor to know whether a determinant is right. Four cheap tests catch nearly every mistake.

Expand along a different line. The widget prints the total for all of them, and a mismatch points straight at the term that broke. Scale a row by a number and the determinant should scale by the same number: doubling one row doubles the answer. Swap two rows and the sign should flip, which is easy to see on the 2x2 above, where swapping the rows gives rows -5, 4 and 3, -2, and a determinant of 10 - 12 = -2 instead of 2. Finally, look for a row or column of zeros: if any line is all zeros, the determinant is zero and no expansion is needed.

Decimals deserve one word of caution. The calculator snaps any result within one billionth of zero to exactly zero and rounds the display to six decimal places, because binary floating point cannot store 0.1 exactly and a determinant that should be zero can arrive as a tiny residue. Integer and simple decimal entries, which is most homework, come out exact.

Frequently asked questions

What is the cofactor formula?

A cofactor is C(i,j) = (-1)^(i+j) M(i,j), where M(i,j) is the determinant left after deleting row i and column j. For the 2x2 with rows 3, -2 and -5, 4, the minor M(1,2) is -5 and 1 plus 2 is odd, so C(1,2) = 5.

How do you find the determinant of a 3x3 matrix with cofactors?

Expand along one row: multiply each entry by its cofactor and add the three results. For rows 2, -1, 3 and 0, 4, 1 and 5, 2, -1 the three terms are -12, -5 and -60, so the determinant is -77.

Does it matter which row or column I expand along?

No. All rows and all columns give the same number, which is what makes the method safe to use. In the 3x3 example, row 1 and column 3 both return -77, and the calculator prints the total for every line so you can confirm it for your own matrix.

What is the difference between a minor and a cofactor?

A minor is the determinant of the smaller matrix left after deleting a row and a column. A cofactor is that same minor with a sign attached, the sign being plus when i plus j is even and minus when it is odd. The two numbers differ only in sign.

What does a determinant of zero mean?

A zero determinant means the matrix is singular: its rows are linearly dependent, it has no inverse, and the matching linear system has either no solution or infinitely many. Any row or column of all zeros forces a determinant of zero.

How many terms does a 4x4 cofactor expansion have?

Four terms in the chosen line, each one a 3x3 minor. Worked out in full that is 40 entry products, and a 5x5 needs 205, which is why row reduction takes over above 4x4.

Can I use cofactor expansion on a 5x5 matrix?

Yes, and the arithmetic is the same, but the cost is 205 entry products against 40 for a 4x4. Computers switch to row reduction, whose work grows with the cube of the size instead of the factorial.

Why does the sign follow (-1)^(i+j)?

The sign counts how many row and column swaps it takes to bring the entry to the top left corner. Each swap flips the sign of a determinant, so an even number of swaps leaves it alone and an odd number reverses it. That is exactly what the parity of i plus j records.

What is the adjugate matrix?

The adjugate is the transpose of the cofactor matrix. Every cofactor C(i,j) moves to position (j,i), and the determinant is unchanged by the transpose, which is why the adjugate divides cleanly into the inverse.

How do I get an inverse from cofactors?

Compute every cofactor, arrange them into the cofactor matrix, transpose it to get the adjugate, then divide each entry by the determinant: A inverse equals adj(A) divided by det(A). For the 2x2 with determinant 2, each entry of the adjugate is halved.

Can the calculator handle decimals and negative entries?

Yes. Any real number can be typed into any cell, including decimals and negatives, and the sizes 2x2, 3x3 and 4x4 are all supported. Results are rounded to six decimal places, and anything inside one billionth of zero is shown as zero.

Is cofactor expansion the fastest way to compute a determinant?

No. It costs 40 entry products at 4x4 and 205 at 5x5, while row reduction reaches the same answer far faster on large matrices. For 2x2, 3x3 and 4x4 by hand, or when you need to show the working, expansion is the better choice.

What happens if one row of the matrix is all zeros?

The determinant is zero, with no expansion needed. A line of zeros makes every term in that expansion zero, and the matrix is singular for the same reason: a row of zeros cannot be independent of the others.

Can I expand along a column that contains a zero?

Yes, and a zero entry removes its whole term. In the 4x4 example, column 2 holds 0, 0, 1, 0, so only one term survives and the entire determinant reduces to a single 3x3 minor, which comes out to 30.

Spotted a wrong number or a broken result?

More Everyday tools

See all Everyday tools

Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.