Cofactor Matrix Calculator
Enter a 2x2, 3x3, or 4x4 square matrix and this calculator finds the cofactor matrix, the minors matrix, the adjugate (adjoint), and the determinant. Every step is shown so you can follow the computation from submatrix to signed cofactor.
Formula
Worked example
For A = [[1,2,3],[0,4,5],[1,0,6]]: Minor M(1,1) = det([[4,5],[0,6]]) = 24 - 0 = 24, so C(1,1) = (+1)(24) = 24. Minor M(1,2) = det([[0,5],[1,6]]) = 0 - 5 = -5, so C(1,2) = (-1)(-5) = 5. The sign pattern alternates like a checkerboard. The adjugate is the transpose of the full cofactor matrix.
What is a cofactor matrix?
The cofactor matrix (also called the matrix of cofactors or comatrix) is a square matrix of the same size as the original, where each entry C(i,j) is the cofactor of the corresponding entry in the original matrix. The cofactor C(i,j) is found by taking the minor M(i,j) - the determinant of the smaller matrix you get by deleting row i and column j - and then multiplying by a sign factor of (-1)^(i+j). This creates a checkerboard pattern of positive and negative signs across the matrix. Cofactors are fundamental to cofactor expansion (Laplace expansion) for computing determinants, to finding the inverse of an invertible matrix, and to Cramer's rule for solving linear systems.
How to calculate the cofactor matrix
To find the cofactor matrix of an n x n matrix A, repeat these steps for every position (i, j): first, delete row i and column j from A to form an (n-1) x (n-1) submatrix; second, compute the determinant of that submatrix - this is the minor M(i,j); third, apply the sign (-1)^(i+j) to get the cofactor C(i,j) = (-1)^(i+j) * M(i,j). Assemble all n^2 cofactors into a new n x n matrix - that is the cofactor matrix. For a 2x2 matrix [[a,b],[c,d]], the cofactors are simply C(1,1) = d, C(1,2) = -c, C(2,1) = -b, C(2,2) = a, giving a cofactor matrix [[d,-c],[-b,a]].
Cofactor matrix, adjugate, and the matrix inverse
The adjugate matrix (also called the classical adjoint or adj(A)) is the transpose of the cofactor matrix. It is central to one of the most important results in linear algebra: the inverse formula A^(-1) = adj(A) / det(A), valid whenever det(A) is not zero. This means you can find the matrix inverse in three steps: (1) compute the cofactor matrix C, (2) transpose C to get adj(A), (3) divide every entry of adj(A) by det(A). If det(A) = 0 the matrix is singular and no inverse exists, though the cofactor matrix is still defined. This inverse formula is exact and avoids the rounding errors of Gaussian elimination for small matrices.
Why cofactors matter in determinant expansion
The cofactor expansion formula (Laplace expansion) states that the determinant of an n x n matrix equals the sum over any row or column of each entry multiplied by its cofactor: det(A) = a(i,1)*C(i,1) + a(i,2)*C(i,2) + ... + a(i,n)*C(i,n). Expanding along a row or column containing zeros is especially efficient since those terms vanish. This calculator always expands along the first row, but the result is the same regardless of which row or column you choose. Cofactor expansion reduces an n x n determinant to n determinants of size (n-1) x (n-1), then applies the same rule recursively down to 2x2 or 1x1 base cases.
Sign pattern (checkerboard) for cofactors
| Position (i,j) | (-1)^(i+j) | Sign |
|---|---|---|
| (1,1) | (-1)^2 = 1 | + |
| (1,2) | (-1)^3 = -1 | - |
| (1,3) | (-1)^4 = 1 | + |
| (2,1) | (-1)^3 = -1 | - |
| (2,2) | (-1)^4 = 1 | + |
| (2,3) | (-1)^5 = -1 | - |
| (3,1) | (-1)^4 = 1 | + |
| (3,2) | (-1)^5 = -1 | - |
| (3,3) | (-1)^6 = 1 | + |
The sign applied to minor M(i,j) to get cofactor C(i,j) follows (-1)^(i+j). The first few positions are shown below (1-indexed).
Frequently asked questions
What is the difference between a cofactor and a minor?
A minor M(i,j) is simply the determinant of the submatrix formed by removing row i and column j. A cofactor C(i,j) is the minor multiplied by the sign factor (-1)^(i+j). So minors are always non-negative (or any sign, they are just determinants), while cofactors carry the checkerboard sign pattern that makes them add correctly in cofactor expansion.
How do I use the cofactor matrix to find the inverse?
Compute the cofactor matrix, then transpose it to get the adjugate matrix adj(A). The inverse is A^(-1) = adj(A) divided by det(A). This formula only works when det(A) is not zero. For large matrices, Gaussian elimination is numerically more stable, but for 2x2 or 3x3 matrices this formula gives exact results.
What happens if the determinant is zero?
If det(A) = 0 the matrix is called singular. The cofactor matrix is still computed normally, but you cannot divide by det(A) to get an inverse because division by zero is undefined. A singular matrix maps multiple input vectors to the same output, so its transformation is not reversible.
Does expanding along a different row or column change the result?
No. Cofactor expansion works along any row or column and always gives the same determinant. Choosing a row or column that contains zeros reduces the number of non-zero terms you need to compute, which is helpful for hand calculation. This calculator always expands along the first row.
What is the adjugate matrix?
The adjugate (also called the classical adjoint or adj(A)) is the transpose of the cofactor matrix - you swap rows and columns. Entry (i,j) of the adjugate equals C(j,i), not C(i,j). It appears in the matrix inverse formula A^(-1) = adj(A) / det(A) and in Cramer's rule for solving square linear systems.
Can I compute cofactors for non-square matrices?
No. Cofactors are defined only for square matrices, because you need to remove one row and one column and still be left with a square submatrix whose determinant you can compute. Non-square matrices do not have an inverse in the usual sense and do not have a cofactor matrix.