# Multiple Constrained Sum

I need to perform a multiple summation, that obeys some conditions. This arises in the study of a statistical physics model. q=Exp[-β]. I would like to ask if someone knows how to speed up the following code, or write an equivalent one in order to perform the multiple summation. The integer variables a_i are to be summed from 0 to infinity while the integers b_i run from -a_i to infinity and also need to be ordered like:

b1>b2>b3>b4 ....>bn


and the b summation needs to be performed from the smallest one to the biggest one.

My code to implement this is (ie. 4 objects):

Sum[q^(2 a1 + 2 a2 + 2 a3 + 2 a4 + b1 + b2 + b3 + b4) Boole[b1> b2 > b3 > b4],
{b1, -a1 , Infinity}, {b2, -a2 , Infinity}, {b3, -a3 , Infinity}, {b4, -a4 , Infinity}]


this gives cases for the a's and then I do the four a summations in a next step ( I also simplify the expressions before the next step).

Sum[%, {a1, 0 , Infinity}, ...]


So this works ok up to 3 b's but then it gets infinitely slow for more than 3 and I want to go up to 4 or 5. Is there any way to rewrite this such that it can get faster? ( I have tried to use functions like UnitStep but it is again slow ) Important! One needs to perform all b sums at once, since otherwise you do not get all the possibilities for a's!

• Any reason you're not just using e.g. Sum[q^(2 a1 + 2 a2 + 2 a3 + 2 a4 + b1 + b2 + b3 + b4) , {b1, -a1, Infinity}, {b2, -a2, b1 - 1}, {b3, -a3, b2 - 1}, {b4, -a4, b3 - 1}] for step 1? – ciao Sep 4 '15 at 10:04
• Greetings! Make the most of Mma.SE and take the tour now. Help us to help you, write an excellent question. Edit if improvable, show due diligence, give brief context, include minimum working examples of code and data in formatted form. As you receive give back, vote and answer questions, keep the site useful, be kind, correct mistakes and share what you have learned. – rhermans Sep 4 '15 at 13:13
• @PanagiotisBetzios, what do you mean that the suggestion by ciao is not ordered? In the summation as he wrote it, b1> b2 > b3 > b4 is true without invoking the Boole operator. – Jason B. Sep 4 '15 at 14:04
• If you do this it automatically orders also a1, a2 etc , but I need to take cases where say a4>a3 as well as cases where a4<a3, with Boole it seems to take all cases but with this solution it takes only one of the two cases for a's , or at least this is what I think happens... – Panagiotis Betzios Sep 4 '15 at 14:27
• @rhermans Not rude at all. I always found rather funny the huge amount of info that must be given to new users to get them on track. Looks like these sites are countries with very particular behaviors :D , che. – Dr. belisarius Sep 4 '15 at 14:32