# Diagonal minors of matrix

I need to calculate the minor of a matrix. I am going to use Mathematica example here,

(mat = Table[i^2 + i j + j^3, {i, 4}, {j, 4}]) // MatrixForm;

Minors[mat, 3, Identity] // MatrixForm;

Minors[mat] // MatrixForm;


Since I am going to calculate the minors of big matrices and I only need to know the diagonal elements, is there a way just to calculate the diagonal elements in minor matrix?

• Can't you use Diagonal instead of Identity in your second example ? – b.gates.you.know.what Feb 28 '15 at 21:59

Update: You can also use Part

Det[mat[[#, #]]] & /@ Reverse[Subsets[Range[Length@mat] , {3}]]
(* {-36, -288, -252, -24} *)

Grid[{MatrixForm@#, Det@#} & /@ (mat[[#, #]] & /@
Reverse[Subsets[Range[Length@mat] , {3}]]), Dividers -> All]


Determinants of 2X2 submatrices on the diagonal:

Grid[{MatrixForm@#, Det@#} & /@ (mat[[#, #]] & /@
Reverse[Subsets[Range[Length@mat] , {2}]]), Dividers -> All]


Original post:

mat = Table[i^2 + i j + j^3, {i, 4}, {j, 4}]

Det[Drop[mat, {#}, {#}]] & /@ Range[Length@mat]
{-36, -288, -252, -24}


Timings for random 100X100 real and integer matrices:

tstmat = RandomReal[100, {100, 100}];
(res1 = Det[Drop[tstmat, {#}, {#}]] & /@ Range[Length@tstmat]); // AbsoluteTiming // First
(* 0.156253 *)
(res2 = Diagonal@Minors[tstmat]); // AbsoluteTiming // First
(* 1.596787 *)
res1 == Reverse@res2
(* True *)

tstmat2 = RandomInteger[100, {100, 100}];
(res1 = Det[Drop[tstmat2, {#}, {#}]] & /@ Range[Length@tstmat2]); // AbsoluteTiming // First
(* 1.234382 *)
(res2 = Diagonal@Minors[tstmat2]); // AbsoluteTiming // First
(* 125.368340 *)
res1 == Reverse@res2
(* True *)

• Hi Kguler, Thanks for replying me back, it seems a efficient way, I am trying to apply it for my own program where I need to calculate the Minors[mat,k] where k changes from zero to the size of mat. Where k=3, i will get what you have described above, but for k=2, now the Minors matrix becomes 6x6 matrix(4!/(2! (4 - 2)!)). How I can I use Drop function to avoid calculating the off-diagonal element of minors? – setareh Mar 9 '15 at 22:49
• @setareh, please see the update. – kglr Mar 10 '15 at 8:52
• Hi kguler, I am trying to use this method to run my code, – setareh Apr 5 '15 at 17:44
Diagonal @ Minors[mat]


(* {-24, -252, -288, -36} *)

• "Since I am going to calculate the minors of big matrices and I only need to know the diagonal elements, is there a way just to calculate the diagonal elements in minor matrix?" — Surely, performance is an issue here. – rm -rf Feb 28 '15 at 22:01