Group Abstract Group Abstract

Message Boards Message Boards

0
|
8.8K Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Compute constrained summation?

Posted 10 years ago

Screenshot.

P0, P1 and P2 are constants. The problem is to assign a,b,c all possible values so that their sum is always 33 and compute the sum.

4 Replies
Posted 10 years ago

IntegerPartitions might be useful, but that uses positive values and needs a tweak to also include a=0

Join[Map[Join[{0}, #]&, IntegerPartitions[33, {2}]], IntegerPartitions[33, {3}]]
POSTED BY: Bill Simpson

Do you mean also $b\ge0$ and $c\ge0$? Else, for each $a$ there are an infinite number of integer pairs $a,b$. Otherwise you could generate an index set with:

t = Flatten[Table[{i, j, k}, {i, 0, 33}, {j, 0, 33}, {k, 0, 33}], 2];
indx=Select[t, (Total[#] === 33) \[And] (#[[2]] + #[[3]] > 0) &];
POSTED BY: John McGee
Sum[33! p0^a p1^b p2^c Boole[a + b + c == 33]/(a! b! c!), {a, 0, 33}, {b, 0, 33}, {c, 0, 33}]

huge output

POSTED BY: S M Blinder

I suggest you start by trying to implement a simpler problem of the same type.

POSTED BY: Frank Kampas
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard