# Number of solutions to $x_1 + x_2 + x_3 + x_4$ = 10

How do I find the number of non-negative integer solutions of the equation $x_1 + x_2 + x_3 + x_4$ = 10 satisfying the condition $x_1<3$, $x_2<6$, $x_3<7$. Any answers will be much appreciated. Thanks.

• I would just do it on a computer, – Derek Holt Dec 29 '13 at 17:48
• @DerekHolt Yes even I can write a C++ code for this.But I am looking for a theoretical approach. – Heisenberg Dec 29 '13 at 17:49
• There are only a few solutions, so it would not take long to enumerate them by hand—for this problem it would probably be faster than writing and testing the computer program, unless you had the code lying around already. – MJD Dec 29 '13 at 17:53
• I would use a CAS, such as Mathematica, Maple,... I got $116$ BTW. – Derek Holt Dec 29 '13 at 17:59
• @DerekHolt Yes the answer should be 116 but I want to get it without using programming – Heisenberg Dec 29 '13 at 18:00

This is an inclusion-exclusion problem. There are three conditions at play:

A: "$x_1\ge 3$"
B: "$x_2\ge 7$"
C: "$x_3\ge 8$"

You want to count the cases where none of the conditions hold.

The solution to the base problem is $\left(\!{4\choose 10}\!\right)$. See this for a definition of the multichoose notation.

If we want condition A to hold, then replace $x_1$ by $x_1'=x_1+3$, which rearranges the equation to $x_1'+x_2+x_3+x_4=7$, which has solution $\left(\!{4\choose 7}\!\right)$. Similarly, if condition B holds, you have $\left(\!{4\choose 3}\!\right)$. If A and B both hold, there is a single way to do this; B and C cannot both hold.

• Thanks. Lets take a case where exactly two constraints are violated. Should I add it to the base or deduct it? – Heisenberg Dec 29 '13 at 18:07
• You alternate adding and subtracting; no conditions is +, one condition is -, two conditions is +, etc. – vadim123 Dec 29 '13 at 18:08
• Why would two conditions being violated be added? – Heisenberg Dec 29 '13 at 18:10
• You should read about inclusion-exclusion. The reason is that we overcount those cases. When $x_1=3, x_2=7$, we added it once for the base problem, then subtracted it for A, then subtracted it again for B. We need to add it again, to count it 0 times instead of -1 times. – vadim123 Dec 29 '13 at 18:14

Suppose $A,B,C$ are the sets that $x_1\geq 3,x_2\geq 6,x_3\geq 7$ Total number of solution without any restriction is $C(10+4-1,4-1)=C(13,3)$ ,further more:
$|A|=C(10,3)$ , $|B|=C(7,3)$, $|C|=C(6,3)$
$|A\cap B |=C(4,3)$ , $|C\cap B |=0$ , $|A\cap C |=C(3,3)$
$|A\cap B\cap C |=0$ , hence by inclusiıon exclusion we'll have:
$|x_1<3,x_2<6,x_3<7|=C(13,3)-|A|-|B|-|C|+|A\cap B |+|A\cap C |+|B\cap C |-|A\cap B \cap C|=$
$C(13,3)-C(10,3)-C(7,3)-C(6,3)+C(4,3)+C(3,3)=116$
that must be true, if i am not mistaken.

First look at all sorted integer partitions of $10$:

$$\mathcal{P}(10)=\left( \begin{array}{cccc} 7 & 1 & 1 & 1 \\ 6 & 2 & 1 & 1 \\ 5 & 3 & 1 & 1 \\ 5 & 2 & 2 & 1 \\ 4 & 4 & 1 & 1 \\ 4 & 3 & 2 & 1 \\ 4 & 2 & 2 & 2 \\ 3 & 3 & 3 & 1 \\ 3 & 3 & 2 & 2 \\ \end{array} \right)$$

Now for every element you have to decide how many feasible configurations it will yield. For example the partition $(7,1,1,1)$ will only yield one feasible configuration ($x_4=7$), while the partition $(6,2,1,1)$ will yield $6$ feasible configurations ($2$ possibilities for the $6$, for each you need to decide which of the $3$ remaining fields is covered by the $2$). Now you can go on like this and get the final result of $116$ if you summed correctly.

This can be done using the principle of Inclusion and Exclusion.
First, calculate the total number of possibilities (without the constraints). That's $\binom{10+3}{3}$. (Can you figure out why?) When $x_i\geq k$, we get $\binom{10+3-k}{3}$. (For the different $x_i$ and $k$ you mentioned.) When $x_i\geq k$ and $x_j\geq l$ with $i\neq j$, you get $\binom{10+3-k-l}{3}$ (when $k+l\leq 10$, otherwise, this is just $0$).