Algosim documentation: cofactor

cofactor

Returns a cofactor of a square matrix.

Syntax

Description

If A is a square matrix, i a valid row index of A, and j a valid column index of A, then cofactor(A, i, j) returns the (i, j) cofactor of A, that is, (−1)^(i+j) times the corresponding minor.

In other words,

cofactor(A, i, j) = (−1)^(i + j) ⋅ minor(A, i, j)
                  = (−1)^(i + j) ⋅ det(SubmatrixByRemoval(A, i, j)).

Examples

A ≔ ❨❨4, 1, 2, 3❩, ❨6, 1, 2, 3❩, ❨7, 6, 5, 0❩, ❨1, 2, 1, 6❩❩
⎛4  1  2  3⎞
⎜6  1  2  3⎟
⎜7  6  5  0⎟
⎝1  2  1  6⎠
cofactor(A, 2, 3)
−126

See also