# How do I generate a table of cofactors from minors of a matrix?

I'm trying to figure out how to find the determinant of a 5x5 matrix by co-factor expansion in the second row. I have already calculated the minors of the matrix using Minors. I'm also trying to figure out how to generate the cofactors of the minor matrices using the Table command.

A = {{1, 2, 3, 4, 4}, {2, 1, 2, 3, 4}, {3, 2, 1, 2, 3}, {4, 3, 2, 1, 2},
{4, 4, 3, 2, 1}};

Amin = Minors[A]
(* {{-20, -22, 0, 10, 12}, {-22, -37, -16, 11, 10}, {0, -16, -32, -16, 0},
{10, 11, -16, -37, -22}, {12, 10, 0, -22, -20}} *)


Could someone give me step-by-step instructions or concepts to solve this problem? To emphasize, please note that I am only asking for instructions.

• Maybe something like Times[A, KroneckerProduct[#, #] &[(-1)^Range[Length[A]]]] would do? Mar 4 at 16:14
• I want to understand with step by step instructions. Mar 4 at 16:30
• (-1)^Range[Length[A]] produces the vector {-1, 1, -1, 1, -1}. Taking the KroneckerProduct turns this into a matrix of alternating sings. Times just multiplies each entry of A with the corresponding sign. Mar 4 at 16:35
• Check Minors reference guide page, Properties & Relations section second and third examples. Mar 4 at 18:37
• How would i create a table of cofactors first? Mar 4 at 20:31

Define a Cofactor and CofactorMatrix functions:

Cofactor[m_?MatrixQ, {i_Integer, j_Integer}] := (-1)^(i + j)*

CofactorMatrix[m_?MatrixQ] :=
Table[Cofactor[m, {i, j}], {i, #}, {j, #}] &@Length@m


Next, we define the DetByCofactorExpansion function:

DetByCofactorExpansion[mat_?MatrixQ, row_Integer] :=
CofactorMatrix[mat][[row]] . mat[[row]]

DetByCofactorExpansion[A, 2]

(*32*)


You already got the minors.

Then the determinant of a matrix can be obtained by the Laplace expansion (see e.g.: https://en.wikipedia.org/wiki/Laplace_expansion). Here is an example:

laplDet[mat_, row_] :=
Sum[(-1)^(row + j)  Amin[[row, j]]  mat[[row, j]], {j, Length[mat]}];
laplDet[A, 2]

32

• How would i create a table of cofactors first? Mar 4 at 20:19
• The Laplace expansion is an expansion in minors with weights (cofactors) given by corresponding matrix elements of the original matrix with alternating signs. Mar 4 at 20:57