Understanding the cofactor matrix calculator — concept and principle
This calculator builds the matrix of minors, the cofactor matrix and the adjugate of a square matrix, and checks the determinant from the first row. Use it for linear algebra homework, for finding an inverse by the adjugate method or to check each step of a hand calculation.
How it is calculated
Minor M_ij = determinant of A with row i and column j removed
Cofactor C_ij = (−1)^(i+j) × M_ij
Sign pattern: + − + / − + − / + − + …
Adjugate adj(A) = Cᵀ; A⁻¹ = adj(A) ÷ det(A) when det(A) ≠ 0
Check: det(A) = a₁₁C₁₁ + a₁₂C₁₂ + … + a₁ₙC₁ₙ
The principle
Each cofactor measures how the determinant depends on one entry: if you change a_ij by a small amount, the determinant changes by that amount times C_ij. That is why multiplying a row of A by its own row of cofactors gives the determinant, while multiplying it by another row's cofactors gives zero (it is the determinant of a matrix with two equal rows). Transposing the cofactor matrix puts these products in the right places, so A × adj(A) = det(A) × I and the inverse follows.
Worked example
Default input: A = [1 2 3; 0 4 5; 1 0 6].
- Minors: row 1: 24, −5, −4; row 2: 12, 3, −2; row 3: −2, 5, 4, giving the matrix of minors [24 −5 −4; 12 3 −2; −2 5 4].
- Apply the sign pattern [+ − +; − + −; + − +].
- Cofactor matrix C = [24 5 −4; −12 3 2; −2 −5 4].
- Adjugate adj(A) = Cᵀ = [24 −12 −2; 5 3 −5; −4 2 4].
- det(A) = 1 × 24 + 2 × 5 + 3 × (−4) = 22, so A⁻¹ = adj(A) ÷ 22.
How to read the result
If the determinant is 0, the cofactor matrix still exists but there is no inverse. For a 2 × 2 matrix [a b; c d] the cofactor matrix is [d −c; −b a]. Large cofactors relative to the determinant warn that the inverse has large entries, so small input errors will be magnified.
Common mistakes
- Applying the signs to the minors twice, or not at all.
- Forgetting to transpose when moving from cofactors to the adjugate.
- Computing a minor with the wrong row or column removed.
- Dividing by the determinant before checking that it is not 0.
Frequently asked questions
What is the difference between the cofactor matrix and the adjugate?
The adjugate is the transpose of the cofactor matrix.
How do I find the inverse with cofactors?
Build the cofactor matrix, transpose it, and divide by the determinant.
What is the cofactor matrix of a 2 × 2 matrix?
For [a b; c d] it is [d −c; −b a].
Sources: D. Margalit & J. Rabinoff, Interactive Linear Algebra, §4.2 Cofactor Expansions · A. Davis, P. Zachlin et al., Coordinated Linear Algebra (University of Nebraska–Lincoln), §5.3