# How to write Ordered partition in a summation involving a huge expression

$$b_n=\sum_{m=2}^{\lfloor\frac{n}{3}\rfloor}\left\{(-1)^m\frac{l_m}{m+1}\sum_{i_1+i_2+...+i_m=n}a^{(1)}_{i_1}a^{(2)}_{i_2}...a^{(m)}_{i_m}\right\}$$ The $$i_k\geq3$$, for any $$k$$. Here $$a^{(k)}$$ represents a variable and $${i_k}$$ is just an indexing according to the partition of $$n$$.

P.S: Integer partition will not work. Ordered partition is required precisely. How do we write this in Mathematica?

• user74846 AFAIK ordered set partitions are simply set partitions plus permutations. If this is correct, you can get them by e.g.: Flatten[Permutations /@ IntegerPartitions[4], 1] Commented Sep 27, 2020 at 12:25
• Can you explain what you mean by Ordered partition? What have you tried?
– A.G.
Commented Sep 27, 2020 at 12:28
• use FrobeniusSolve[ConstantArray[1,m],n] to get indexes of the inner sum
– I.M.
Commented Sep 27, 2020 at 12:35
• @I.M., I'm looking for the same thing but the indexing should be greater or equal to 3. How do I modify? Commented Sep 28, 2020 at 9:26
• @DanielHuber, yes that's right. I tried that code, but didn't work.. any other way? Commented Sep 28, 2020 at 9:27

As @I.M. suggested

FrobeniusSolve[ConstantArray[1,m],n]


with give all m tuples of indices at least 0 summing to n. However, you have added the extra constraint that each index should be at least 3. Subtracting 3 from each index, we get that the sum should be n-3m instead and can construct your indices as

f[m_,n_] := FrobeniusSolve[ConstantArray[1,m],n-3m]+3


For example n=12, m=3 yields

In[3]:= f[3,12]

Out[3]= {{3, 3, 6}, {3, 4, 5}, {3, 5, 4}, {3, 6, 3}, {4, 3, 5}, {4, 4, 4},

>    {4, 5, 3}, {5, 3, 4}, {5, 4, 3}, {6, 3, 3}}


This example builds a homogeneous polynomial with $$m$$ variables and total degree $$n$$.

$$p(m,n) = \sum_{i_1 + \dots + i_m = n} x_{1}^{i_1} \dots x_{m}^{i_m}$$

Power, can be converted to a two-indexed form.

ClearAll[index] ;
index[m_,n_] := FrobeniusSolve[ConstantArray[1,m],n] ;
(* m - number of variables *)
(* n - total monomial power *)
m = 2 ; n = 6 ;
vars = Array[x,m] ;
list = index[m,n] ;
poly = Total[Map[Apply[Times],Transpose[vars^Transpose[list]]]]
poly /. Power[x[a_],b_] :> x[a,b]   /. x[a_] :> x[a,1]
m = 3 ;  n = 3 ;
vars = Array[x,m] ;
list = index[m,n] ;
poly = Total[Map[Apply[Times],Transpose[vars^Transpose[list]]]]
poly /. Power[x[a_],b_] :> x[a,b]   /. x[a_] :> x[a,1]

• There appears irresistibly many terms for higher values of n, which do not fall into the condition mentioned in the question. Though, the third variety of output is what I'm seeking for, given that the conditions satisfy. It messes up when I'm actually dealing with the actual summation that I want to code Commented Sep 28, 2020 at 12:15