# Summation over specific tuples

I would like to write a function that would, given a positive integer $$n$$, compute the following:

$$S_n = \sum_{(x,y,z)} a_{(x,y,z)} f(x,y,z)$$, where the sum runs over all tuples $$(x,y,z)$$ such that $$x+y+z = n$$, and $$x,y,z$$ take values in {$$0,1,...,n$$}. The ultimate goal is to pass this function trough Solve to determine the coefficients $$a_{(x,y,z)}$$ with some other conditions from the problem.

My main problem is generating the appropriate tuples in a way that I could then pass through Sum.

Any help is appreciated.

• Have you already seen FrobeniusSolve[]? May 26, 2020 at 17:41
• I have not, I'll look it up May 26, 2020 at 17:46
• Yep, it looks like it works, thanks! May 26, 2020 at 17:55
• @johnny If you have a solution in hand, please write up an answer to your question, so it does not remain dangling for future users. May 26, 2020 at 18:11
• As @J.M. says, FrobeniusSolve[ConstantArray[1, n], n] would do; but if you can make any use of permutational equivalence, then IntegerPartitions[n, {n}, Range[0, n]] may also help as it generates a vastly smaller list (which needs to be permuted, however). May 26, 2020 at 20:03

## 1 Answer

As suggested by @MarcoB, here is my solution, using FrobeniusSolve:

Frobenius[n_] := FrobeniusSolve[{1, 1, 1}, n];
Sol[n_] :=
Sum[a[Part[Frobenius[n], i] /. List -> Sequence]
*OrderN[Part[Frobenius[n], i] /. List -> Sequence],
{i, 1, Length[Frobenius[n]]}]


In the code, corresponds to the $$f(x,y,z)$$ in the original question.

• Thank you for writing this up! (+1) May 28, 2020 at 5:25