I would like to use maple to compute \begin{align} P_i & = \sum_{1\leq j_1 < \cdots <j_{i-1} \leq i} \Delta_{(2,\ldots, n), (j_1,\ldots,j_{i-1}, i+1, \ldots, n)}(A) \Delta_{(j_1, \ldots, j_{i-1}, i+1, \ldots, n), (1, \ldots, n-1)}(B), \quad i=1,2,\ldots,n, \end{align} where $A, B$ are $n$ by $n$ matrices and $\Delta_{(i_1,\ldots,i_n),(j_1,\ldots,j_n)}(A)$ is the minor of $A$ with rows $i_1,\ldots,i_n$ and columns $j_1,\ldots,j_n$.

Here the difficulty is the number of loops is arbitrary. In maple, I can compute $P_i$ one by one for each $i$. But I have to write codes for each $i$. How can I compute $P_i$ in maple efficiently (codes which work for each $i$)? Thank you very much.


1 Answer 1


You do this by using combinat:-choose to choose the summation indices.

P:= proc(A::Matrix, B::Matrix, i::posint)
local j;
     add(A[2..-1, [j[], i+1..-1]].B[[j[], i+1..-1], 1..-2], j= combinat:-choose(i,i-1))
end proc; 
  • $\begingroup$ thank you very much. Does combinat:-choose(i,i-1) return all possible $i-1$ elements in $[1,\ldots,i]$ in increasing order or any $i-1$ elements in $[1,\ldots,i]$? $\endgroup$
    – LJR
    Commented Mar 4, 2014 at 8:26
  • $\begingroup$ It returns, in order as lists, all subsets of $\{1,...,i\}$ of size $i-1$. $\endgroup$
    – Carl Love
    Commented Mar 4, 2014 at 9:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .