# Inclusion-Exclusion

How many integer solutions are there to the equation $x_1 + x_2 + x_3 + x_4 = 32$ with $0 \leq x_i \leq 10$ for $i = 1, 2, 3, 4$?

How many integer solutions are there to the inequality $$y_1 + y_2 + y_3 + y_4 < 184$$

with $y_1 > 0$, $0 < y_2 \leq 10$, $0 \leq y_3 \leq 17$, and $0 \leq y_4 < 19$?

Here are two problems. I can see this combination $(32+4-1,4-1)$ but I am having trouble finding out what to subtract from that.

Also, the second problem is looking for a more complicated solution. I understand that $y_1+y_2+y_3+y_4+y_5 = 182$ and $(182,4)$ for the combination but what do it have to subtract from that?

Thank you.

-
Your latest revision effectively defaced the question, leaving it utterly meaningless. Please do not do this again. – Andrés E. Caicedo Oct 11 '13 at 2:02
@AndresCaicedo Did OP do it again? I see a revision, and then an OP edit, but I don't know when exactly you commented. – Calvin Lin Oct 11 '13 at 3:53
@CalvinLin Yes, they attempted defacing again. – Andrés E. Caicedo Oct 11 '13 at 4:29

What you have to subtract from $\binom{35}3$ are the solutions (in non-negative integers) in which at least one $x_k$ exceeds the limit of $10$. How many solutions have $x_1>10$? These are the solutions that have $x_1\ge 11$, so there is a natural bijection between them and non-negative solutions to $$y_1+y_2+y_3+y_4=21\;:$$ just let $x_1=y_1+11$ and $x_k=y_k$ for $k=2,3,4$. Thus, there are $\binom{21+4-1}{4-1}=\binom{24}3$ solutions to the original equation in which $x_1>10$. Similarly, there are $\binom{24}3$ in which $x_2>10$, $\binom{24}3$ in which $x_3>10$, and $\binom{24}3$ in which $x_4>10$, so as a second approximation there are

$$\binom{35}3-4\binom{24}3\tag{1}$$

solutions to $x_1+x_2+x_3+x_4=32$ with $0\le x_k\le 10$ for $k=1,2,3,4$.

Unfortunately, some of the ‘bad’ solutions have been subtracted twice. Specifically, any solution in which two of the variables exceed the limit of $10$ have been subtracted twice. For example, the solution $11+11+10+0=32$ was subtracted once because $x_1>10$ and a second time because $x_2>10$. To compensate for this overcorrection, we must add to $(1)$ the number of solutions in which two of the variable exceed $10$.

Solutions in which $x_1>10$ and $x_2>10$ correspond to non-negative solution to $$y_1+y_2+y_3+y_4=10\;:$$ just let $x_1=y_1+11$, $x_2=y_2+11$, $x_3=y_3$, and $x_4=y_4$. There are $\binom{10+4-1}{4-1}=\binom{13}3$ such solutions, and there are $\binom42=6$ possible pairs of variables, so we can improve the approximation $(1)$ to

$$\binom{35}3-4\binom{24}3+6\binom{13}3\;.\tag{2}$$

No further corrections are needed, since it’s not possible for more than two of the variables to exceed the limit of $10$, and $(2)$ is therefore the answer.

The second question requires one additional trick in order to compensate for the inequality: add a fifth variable to take up the difference between $y_1+y_2+y_3+y_4$ and $183$, so that you’re counting integer solutions to

$$y_1+y_2+y_3+y_4+y_5=183\tag{3}$$

that satisfy $y_1>0$, $0<y_2\le 10$, $0\le y_3\le 17$, $0\le y_4<19$, and $y_5\ge 0$. Next, note that if we let $z_1=y_1-1$, $z_2=y_2-1$, and $z_k=y_k$ for $k=3,4,5$, solutions to $(3)$ with its boundary conditions correspond to solutions to

$$z_1+z_2+z_3+z_4+z_5=181$$

satisfying $z_1,z_5\ge 0$, $0\le z_2<10$, $0\le z_3<18$, and $0\le z_4<19$. Ignoring the upper bounds for a moment, we have as a starting point

$$\binom{181+5-1}{5-1}=\binom{185}4$$

solutions, but of course some of them violate upper bounds. See if you can use the ideas in the first solution to carry out the inclusion-exclusion argument needed here. It’s a little more complicated, because the bounds aren’t all the same, and more than two of them can be exceeded, but the ideas used are exactly the same.

-
Nitpicking, but please don't use $y_i$ for the first part... – Calvin Lin Oct 11 '13 at 1:47
@Calvin: Why not? The two problems are independent. Had I been setting the problems, I’d have used $x_k$ in both in the first place. – Brian M. Scott Oct 11 '13 at 3:40
Small typo: should be $y_4$ instead of $r_4$ just after equation $(3)$. Otherwise a great answer. (+1) – Ben Nov 20 '13 at 0:22
@Ben: Thanks, and thanks for catching the typo. – Brian M. Scott Nov 20 '13 at 0:23

For the first part, I suggest using a change of variables $a_i = 10 - x_i$. Then, we still have $0 \leq a_i \leq 10$ but the condition now becomes

$$a_1 + a_2 + a_3 + a_4 = 8$$

Hence, the condition that $a_i \leq 10$ is actually not necessary! Thus, by stars and bars, the number of solutions is ${ 8 + 4 - 1 \choose 4-1 } = 165.$

This agrees with Brian's solution, after you evaluate the binomial coefficients. (Phew!) Of course, this trick only works because the numbers are small (large), and in general, you have to use PIE as Brian did.

-

Use generating functions. Let $f(x)=1+x+...+x^{10}$ then find the coefficient of $x^{32}$ in $(f(x))^4$.

-