Cofactor Matrix Calculator
This calculator works out the cofactor matrix of any 2x2 or 3x3 matrix, one of the core building blocks of linear algebra behind matrix inversion, determinant expansion and Cramer's rule. Select whether you are working with a 2x2 or 3x3 matrix, then type your values into the on-screen grid; default matrices are already filled in so you can see how it works before entering your own numbers. As soon as you change a value, the calculator recalculates and returns the complete cofactor matrix C, laid out in the same shape as your original matrix. Below that sits a step-by-step breakdown for every position, showing the minor determinant M[i][j], the checkerboard sign factor (-1)^(i+j), and how the two combine to give each cofactor. A results panel also reports the determinant of your matrix and whether it is invertible, since the adjugate, the transpose of the cofactor matrix, is what you divide by the determinant to find the inverse. A sign-pattern chart shows the plus and minus layout for both sizes so you can check your working by eye. Use this tool to check homework, verify hand calculations, or see how cofactor expansion feeds into determinants and inverses. Results use exact integer arithmetic where your inputs are whole numbers; for matrices larger than 3x3 or heavy decimal work, dedicated numerical software is a better fit.
Matrix Size
Enter Matrix A
Step-by-Step Working
Sign Pattern for Cofactors
The checkerboard sign pattern (-1)^(i+j) applied to each minor:
2x2 pattern
3x3 pattern
What Is the Cofactor Matrix?
The cofactor matrix (also called the matrix of cofactors) is a square matrix formed by computing the cofactor of every element of the original matrix. The cofactor C[i][j] at position (i, j) combines two pieces of information: the minor M[i][j] (a smaller determinant) and a sign determined by the position.
The formula is: C[i][j] = (-1)^(i+j) × M[i][j]
The minor M[i][j] is the determinant of the submatrix formed by deleting row i and column j from the original matrix. The sign factor (-1)^(i+j) creates the familiar checkerboard pattern of plus and minus signs.
How to Compute a 3x3 Cofactor Matrix
For a 3x3 matrix A with elements a[i][j] (using 0-based indexing):
- For each position (i, j), delete row i and column j from A to get a 2x2 submatrix.
- Compute the determinant of that 2x2 submatrix: det([[a, b],[c, d]]) = ad - bc.
- Multiply by the sign factor: (+1) if i+j is even, (-1) if i+j is odd.
- Place the result at position (i, j) in the cofactor matrix.
Worked Example
For the default matrix A:
| Col 1 | Col 2 | Col 3 | |
|---|---|---|---|
| Row 1 | 1 | 2 | 3 |
| Row 2 | 4 | 5 | 6 |
| Row 3 | 7 | 8 | 9 |
Computing each cofactor:
- C[1][1] = (+1) × det([[5,6],[8,9]]) = (45 - 48) = -3
- C[1][2] = (-1) × det([[4,6],[7,9]]) = -(36 - 42) = 6
- C[1][3] = (+1) × det([[4,5],[7,8]]) = (32 - 35) = -3
- C[2][1] = (-1) × det([[2,3],[8,9]]) = -(18 - 24) = 6
- C[2][2] = (+1) × det([[1,3],[7,9]]) = (9 - 21) = -12
- C[2][3] = (-1) × det([[1,2],[7,8]]) = -(8 - 14) = 6
- C[3][1] = (+1) × det([[2,3],[5,6]]) = (12 - 15) = -3
- C[3][2] = (-1) × det([[1,3],[4,6]]) = -(6 - 12) = 6
- C[3][3] = (+1) × det([[1,2],[4,5]]) = (5 - 8) = -3
The cofactor matrix is:
| Col 1 | Col 2 | Col 3 | |
|---|---|---|---|
| Row 1 | -3 | 6 | -3 |
| Row 2 | 6 | -12 | 6 |
| Row 3 | -3 | 6 | -3 |
Note: the determinant of this matrix is 0 (the rows are linearly dependent), which is why the cofactor matrix above has a consistent pattern. This matrix has det(A) = 0.
Uses of the Cofactor Matrix
The cofactor matrix is used in several important linear algebra operations:
- Adjugate matrix: The adjugate (classical adjoint) is the transpose of the cofactor matrix. It is used to compute the matrix inverse.
- Matrix inverse: A^(-1) = (1 / det(A)) × adj(A), where adj(A) is the adjugate. This only exists when det(A) is non-zero.
- Cofactor expansion: The determinant can be computed by expanding along any row or column using cofactors: det(A) = sum of a[i][j] × C[i][j] for all j in a chosen row i.
- Cramer's rule: Solving linear systems Ax = b using determinants relies on cofactor expansion.
Related Calculators
- Maths and Stats Calculators: full hub for algebra and statistics tools.
- Matrix Determinant Calculator: find det(A) for 2x2, 3x3 and larger matrices.
- Matrix Inverse Calculator: compute A^(-1) using the adjugate method.
- Adjoint Matrix Calculator: the transpose of the cofactor matrix.
- 3x3 Determinant Calculator: step-by-step determinant using cofactor expansion.
Method: Standard cofactor formula from linear algebra: C[i][j] = (-1)^(i+j) × M[i][j], where M[i][j] is the (i,j) minor determinant. See: Anton, H. & Rorres, C., Elementary Linear Algebra, Wiley; Lay, D.C., Linear Algebra and Its Applications, Pearson.
This calculator computes cofactor matrices for 2x2 and 3x3 matrices. Results use exact integer arithmetic where inputs are integers. For larger matrices or floating-point applications, dedicated numerical software is recommended.