Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Get a cofactor of a matrix
ResourceFunction["Cofactor"][m,{i,j}] gives the (i,j) cofactor of the square matrix m. |
Here is the (1, 2) cofactor of a 3×3 matrix:
| In[1]:= | ![]() |
| Out[1]= |
The positively signed cofactor of the top left-hand corner of an array:
| In[2]:= |
| Out[2]= |
Define a random 4×4 matrix:
| In[3]:= |
| Out[3]= | ![]() |
Here is its determinant:
| In[4]:= |
| Out[4]= |
Expand the determinant along the first row:
| In[5]:= |
| Out[5]= |
Adding up gives the determinant again:
| In[6]:= |
| Out[6]= |
A 3×3 matrix:
| In[7]:= |
Compute its cofactor matrix using the resource function CofactorMatrix:
| In[8]:= |
| Out[8]= |
The (i,j) cofactor is equal to the (i,j)th element of the cofactor matrix:
| In[9]:= |
| Out[10]= |
Compute its adjugate:
| In[11]:= |
| Out[11]= |
The (i,j) cofactor is equal to the (j,i)th element of the adjugate:
| In[12]:= |
| Out[13]= |
Compute its matrix of minors:
| In[14]:= |
| Out[14]= |
The (i,j) cofactor is, up to a change in sign, equal to the (n-i+1,n-j+1)th element of the matrix of minors:
| In[15]:= | ![]() |
| Out[17]= |
This work is licensed under a Creative Commons Attribution 4.0 International License