[Math] Count the number of integer solutions to $x_1+x_2+\cdots+x_5=36$

combinatoricsdiophantine equationsinteger-partitions

How to count the number of integer solutions to $x_1+x_2+\cdots+x_5=36$ such that $x_1\ge 4,x_3 = 11,x_4\ge 7$

And how about $x_1\ge 4, x_3=11,x_4\ge 7,x_5\le 5$

In both cases, $x_1,x_2,x_3,x_4,x_5$ must be nonnegative integers.

Is there a general formula to calculate things like this?

Best Answer

Suppose you had no constraints on the $x_i$. Your problem is addressed by the "Stars and Bars" method (or, if you do not wish to count the order of your summands, the Partition Function).

Now, your first question can be reduced to the question with no constraints by asking:

What is the number of non-negative integer solutions to $x_1 + x_2 + x_4 + x_5 = 14$?

What I did was set $x_3 = 11$ and subtract 11 from the righthand side and remove $x_3$ from consideration, since we may as well regard $x_3$ as a constant.

For $x_1$ and $x_4$, subtract 4 and 7, respectively, from the righthand side. Now we care only that $x_1 \geq 0$ and $x_4 \geq 0$. In other words, we want the number of non-negative integer solutions to $x_1 + x_2 + x_4 + x_5 = 14$.

To take care of a constraint like $x_5 \leq 5$, first find the number of solutions with no constraints on $x_5$. Then, find the number of solutions with $x_5 \geq 6$. Subtract the latter from the former.

Related Question