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.

  • 1
    $\begingroup$ Have you already seen FrobeniusSolve[]? $\endgroup$ – J. M.'s torpor May 26 '20 at 17:41
  • $\begingroup$ I have not, I'll look it up $\endgroup$ – johnny May 26 '20 at 17:46
  • $\begingroup$ Yep, it looks like it works, thanks! $\endgroup$ – johnny May 26 '20 at 17:55
  • 2
    $\begingroup$ @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. $\endgroup$ – MarcoB May 26 '20 at 18:11
  • 1
    $\begingroup$ 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). $\endgroup$ – Roman May 26 '20 at 20:03

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.

  • $\begingroup$ Thank you for writing this up! (+1) $\endgroup$ – MarcoB May 28 '20 at 5:25

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.