[Math] Number of integer solutions w/ given eq.

combinatorics

recently in our discrete maths course we had this question. Any help is appreciated!

How many integer solutions does belove equation have?

$x_1+x_2+x_3+x_4+x_5+x_6=25$

with given constraints:

$-2\le x_1 \le 5$

$1\le x_2 \le 4$

$-2\le x_3 \le 6$

$3\le x_4 \le 7$

$2\le x_5 \le 8$

$3\le x_6 \le 7$

SOME PEOPLE CLAIM ITS DUPLICATE, WITH BRIEF OVERVIEW ONE CAN EASILY GET THAT IT AINT

Best Answer

HINT: Let $y_1=x_1+2$, $y_2=x_2-1$, $y_3=x_3+2$, $y_4=x_4-3$, $y_5=x_5-2$, and $y_6=x_6-3$. Do you see why the answer to your question is the number of solutions to the equation

$$y_1+y_2+y_3+y_4+y_5+y_6=20\tag{1}$$

in non-negative integers $y_1\le 7$, $y_2\le 3$, $y_3\le 8$, $y_4\le 4$, $y_5\le 6$, and $y_6\le 4$?

One way to calculate this is to use an inclusion-exclusion argument. Start with the usual stars and bars calculation of the number solutions to $(1)$ in non-negative integers; this is

$$\binom{20+6-1}{6-1}=\binom{25}5\;.$$

Now subtract the number of solutions with $y_1\ge 8$; this is simply the number of solutions in non-negative integers to

$$z_1+y_2+y_3+y_4+y_5+y_6=20-8=12\;.$$

Similarly, subtract the numbers of solutions with $y_2\ge 4$, the number with $y_3\ge 9$, and so on.

Unfortunately, you’ve now subtracted too much: any solution with $y_1\ge 8$ and $y_2\ge 4$, for instance, has been subtracted twice and therefore should be added back in. Thus, you need to add back in the number of solutions in non-negative integers to

$$z_1+z_2+y_3+y_4+y_5+y_6=20-8-4=8\;.$$

And you need to do the same thing for each pair of variables.

But now any solution that exceeds the upper bound for three variables has been counted once in the original $\binom{25}5$; subtracted $3$ times, once for each variable; and added back in $\binom32=3$ times, once for each pair of variables. This means that it’s been counted a net of one time, which is wrong: it shouldn’t be counted at all. Thus, we need to subtract the numbers of solutions in non-negative integers to

$$z_1+z_2+y_3+z_4+y_5+y_6=20-8-4-5=3\;,$$

and similarly for every set of three variables. It turns out that at this point we’re done, since there is no solution to $(1)$ in non-negative integers such that more than four of the variables exceed their upper bounds.

It is also possible to use generating functions.