Cofactor Expansion Calculator
Enter any 2x2, 3x3, or 4x4 square matrix and choose which row or column to expand along. The calculator applies the Laplace cofactor expansion formula to find the determinant, then shows every minor, sign factor, and cofactor term step by step. You also get the full cofactor matrix and the adjugate, so you can go on to find the inverse by hand or verify a textbook answer.
What is cofactor expansion?
Cofactor expansion (also called Laplace expansion) is a recursive method for computing the determinant of any square matrix. To expand along row i, you multiply each entry a(i,j) in that row by its cofactor C(i,j) and sum the products: det(A) = a(i,1)*C(i,1) + a(i,2)*C(i,2) + ... + a(i,n)*C(i,n). The cofactor C(i,j) = (-1)^(i+j) * M(i,j) where M(i,j) is the minor, which is the determinant of the smaller matrix you get by deleting row i and column j from A. You can also expand along any column with the same formula. The result is always identical regardless of which row or column you choose, a theorem proven by Laplace.
How to use this calculator
Select the size of your matrix (2x2, 3x3, or 4x4) and type all entries separated by commas in row-major order (left to right, top to bottom). For a 3x3 matrix you enter 9 numbers; for a 4x4 you enter 16. Next, choose which row or column to expand along from the dropdown. The best strategy is to pick the row or column with the most zeros, because any zero entry contributes zero to the sum and you can skip computing its minor entirely. The calculator then shows you the determinant, the full cofactor expansion formula, the cofactor matrix, the adjugate, and a complete step-by-step worked solution.
The determinant and matrix invertibility
A square matrix A is invertible (also called non-singular or regular) if and only if det(A) is not zero. When det(A) = 0 the matrix is called singular: its rows are linearly dependent, it maps the zero vector to itself and also maps some non-zero vector to zero, and the associated linear system Ax = b is either inconsistent or has infinitely many solutions. When det(A) is non-zero, the unique solution to Ax = b is x = A^(-1)b, and the inverse can be written explicitly as A^(-1) = adj(A) / det(A), where adj(A) is the adjugate (the transpose of the cofactor matrix).
Practical strategy: choose the row or column with the most zeros
Cofactor expansion requires computing one (n-1)x(n-1) determinant for each non-zero entry in your chosen row or column. If a row contains two zeros, you only need one minor instead of three for a 3x3 matrix - cutting the work by two-thirds. For a 4x4 matrix with a row of three zeros, you compute just one 3x3 minor instead of four. This is why textbooks always advise choosing the row or column with the fewest non-zero entries, and it is also the strategy used by hand calculations in exams and homework. After you hit Calculate, try switching the expansion axis to a zero-heavy row or column and watch the formula simplify.
Sign pattern matrix for cofactor expansion
| Position | i+j | Sign factor (-1)^(i+j) | Meaning |
|---|---|---|---|
| (1,1) | 2 | +1 | Cofactor = +minor |
| (1,2) | 3 | -1 | Cofactor = -minor |
| (1,3) | 4 | +1 | Cofactor = +minor |
| (2,1) | 3 | -1 | Cofactor = -minor |
| (2,2) | 4 | +1 | Cofactor = +minor |
| (2,3) | 5 | -1 | Cofactor = -minor |
| (3,1) | 4 | +1 | Cofactor = +minor |
| (3,2) | 5 | -1 | Cofactor = -minor |
| (3,3) | 6 | +1 | Cofactor = +minor |
The sign factor (-1)^(i+j) for each position in a 3x3 matrix. "+" means the cofactor equals the minor; "-" means the cofactor is the negative of the minor.
Frequently asked questions
Does the answer change depending on which row or column I expand along?
No. This is guaranteed by the Laplace expansion theorem: the determinant is the same number regardless of which row or column you choose for the expansion. Different choices produce different intermediate calculations, but they all converge to the same final value. If you get different answers when expanding along two different rows, you have made an arithmetic error in one of them.
What is the difference between a minor and a cofactor?
The minor M(i,j) is the determinant of the submatrix formed by deleting row i and column j from the original matrix. The cofactor C(i,j) is the signed minor: C(i,j) = (-1)^(i+j) * M(i,j). The sign factor is +1 when i+j is even (positions on the main and secondary diagonals of the sign pattern) and -1 when i+j is odd. The distinction matters because the expansion formula uses cofactors, not raw minors.
How do I find the inverse of a matrix using cofactor expansion?
First compute the determinant. If it is zero, the matrix has no inverse. If it is non-zero, compute the full cofactor matrix C, then transpose it to get the adjugate adj(A) = C^T. The inverse is A^(-1) = adj(A) / det(A): divide every entry of the adjugate by the determinant. For a 2x2 matrix [[a,b],[c,d]] this simplifies to A^(-1) = (1/(ad-bc)) * [[d,-b],[-c,a]].
What does a zero determinant mean?
A zero determinant means the matrix is singular (non-invertible). Geometrically, the linear transformation represented by the matrix collapses space: a 2x2 singular matrix maps the plane onto a line, and a 3x3 singular matrix maps 3D space onto a plane or line. Algebraically, the rows (and columns) are linearly dependent, meaning at least one row can be written as a linear combination of the others. The system Ax = b either has no solution or infinitely many solutions.
Is cofactor expansion efficient for large matrices?
No. Cofactor expansion has factorial time complexity - for an n by n matrix it requires n! arithmetic operations in the worst case. For a 10x10 matrix that is over 3.6 million operations. In practice, computer software uses LU decomposition or Gaussian elimination, which run in O(n^3) time and are far faster for large matrices. Cofactor expansion is most useful for matrices up to about 4x4, for teaching the concept of cofactors (which appear in the matrix inverse formula), and for deriving theoretical results by hand.