2
$\begingroup$

Using the multiplicative compound matrix --see definition at Are compound matrices implemented in mathematica?

one may define also additive compound matrices

(*Multiplicative compound matrix*)
MulCMat[A_?MatrixQ, k_Integer] := 
  Module[{m, n, p, q}, {m, n} = Dimensions[A];
   p = Subsets[Range[1, m], {k}];
   q = Subsets[Range[1, n], {k}];
   Table[Det[A[[i, j]]], {i, p}, {j, q}]];
A = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};
Print["Wiki example of multiplicative compound", 
 MulCMat[A, 2] // MatrixForm]

(*Additive compound matrix*)
AdCMat[A_, k_Integer] := 
  Module[{m, Id}, m = Length[A]; Id = IdentityMatrix[m]; 
   Limit[Simplify[MulCMat[Id + t A, k] - MulCMat[Id, k]]/t, t -> 0]];
A = {{a11, a12, a13}, {a21, a22, a23}, {a31, a32, a33}};
Print["Second additive compound ", AdCMat[A, 2] // MatrixForm]

Unfortunately, my program does not work on the matrix I have, which is

ja = {{-e \[Beta]e - \[Gamma]r - \[Gamma]s - \[CapitalLambda] + 
     i (-\[Beta] + \[Nu]), -s \[Beta]e - \[Gamma]r, -\[Gamma]r + 
     s (-\[Beta] + \[Nu])}, {i \[Beta] + e \[Beta]e, 
    s \[Beta]e - \[Gamma]e - \[CapitalLambda] + i \[Nu], 
    s \[Beta] + e \[Nu]}, {0, 
    ei, -\[Gamma] - \[CapitalLambda] + (-1 + 2 i) \[Nu]}};
AdCMat[ja, 2]

How to fix this?

$\endgroup$
2
  • 1
    $\begingroup$ How does additive compound matrix make any sense for nonsquare matrices? $\endgroup$ Jan 14 at 9:02
  • $\begingroup$ @HenrikSchumacher It may not. I have not checked this in the reference mentioned below, since I only need this in the square case, for estimating stability of systems of ODEs. researchgate.net/profile/James-Muldowney-2/publication/… $\endgroup$
    – florin
    Jan 14 at 13:27

1 Answer 1

2
$\begingroup$

You can compute the multiplicative compound matrix using Minors (which is also mentioned in the comment by Daniel Lichtblau to your linked question)

B = RandomInteger[{1, 100}, {10, 10}];
MulCMat[B, 5] === Minors[B, 5]
(* True *)

It is also more efficient to define the additive compound matrix via a derivative, which is what your Limit[_,t->0] is trying to do (see also my answer here)

CalcACM[matrix_, k_] := D[Minors[IdentityMatrix[Length@matrix] + t*matrix, k], t] /. t -> 0

This gives you for your matrix ja

CalcACM[ja, 2]
(* {
    {-e \[Beta]e + s \[Beta]e - \[Gamma]e - \[Gamma]r - \[Gamma]s -  2 \[CapitalLambda] + i \[Nu] + i (-\[Beta] + \[Nu]),  s \[Beta] + e \[Nu], \[Gamma]r - s (-\[Beta] + \[Nu])},
    {ei, -e \[Beta]e - \[Gamma] - \[Gamma]r - \[Gamma]s - 2 \[CapitalLambda] + (-1 + 2 i) \[Nu] +  i (-\[Beta] + \[Nu]), -s \[Beta]e - \[Gamma]r},
    {0, i \[Beta] + e \[Beta]e, s \[Beta]e - \[Gamma] - \[Gamma]e - 2 \[CapitalLambda] + i \[Nu] + (-1 + 2 i) \[Nu]}
} *)

Edit

The reason why your code failed is due to a reuse of the symbol i, which appears both as a variable in ja and as a Table iterator in MulCMat. To avoid such problems, the iterators used for Table should be made local in Module as well, i.e.

MulCMat[A_?MatrixQ, k_Integer] := 
Module[{m, n, p, q, i, j}, {m, n} = Dimensions[A];
  p = Subsets[Range[1, m], {k}];
  q = Subsets[Range[1, n], {k}];
  Table[Det[A[[i, j]]], {i, p}, {j, q}]
];

After making this change, AdCMat[ja,2] and CalcACM[ja,2] give the same result.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.