1

How many solutions are there to the equation in the title with the following constraints: $0 ≤ x_i, x_1 ≤ 6, x_2 ≤ 10, x_3 ≤ 15, x_4 ≤ 21?$

So, to do this I tried the following:
(A) Total number is ${31 \choose 28}$ ways.
(B) $x_1$ having $7$+ is ${24 \choose 21}$ ways.
(C) $x_1$ having $7$+ and $x_2$ having $11$+ is ${13 \choose 10}$ ways.
There is no way that $x_3$ can have 15+ since $7 + 11 + 15 > 28$.
Answer is $A - B + C = 2,757$ ways.

Is this correct?

RobPratt
  • 45,619
  • No, you have to subtract the number of ways each constraint can be violated, then add each way two of the constraints can be violated, subtract each way three of the constraints can be violated, then add each way all four constraints can be violated. – N. F. Taussig Dec 03 '20 at 01:09
  • 1
    For purposes of the comment, I am going to use C1 for condition 1 (x1 < 6), C2 for condition 2, etc. So you are saying, I should have A - (B + ways C2 is violated + ways C3 is violated + ways C4 is violated) + (C + ways C1 and C3 are violated + C1 & C4 + C2 & C3 + C2 & C4 + C3 & C4) - (C1 & C2 & C3 + C1 & C2 & C3 + C1 & C3 & C4 + C2 & C3 & C4) + (ways all four can be violated) ???? –  Dec 03 '20 at 01:16
  • 1
    So, I got ${31 \choose 28} – ({24 \choose 21} + {20 \choose 17} + {15 \choose 12}+{9 \choose 6}) + ({13 \choose 10} + {8 \choose 5} + {4 \choose 1}) = 1,138 ways$ –  Dec 03 '20 at 01:29
  • 2
    yes, the answer is $1138$ (confirmed by brute force) – achille hui Dec 03 '20 at 01:37
  • I am glad that you figured it out. – N. F. Taussig Dec 03 '20 at 09:27

2 Answers2

0

This is how I would calculate it.

$T_1 = \binom{31}{3}$
ignores all upper constraints.

$T_2 = \binom{24}{3}$
$x_1 \geq 7.$

$T_3 = \binom{20}{3}$
$x_2 \geq 11.$

$T_4 = \binom{15}{3}$
$x_3 \geq 16.$

$T_5 = \binom{9}{3}$
$x_4 \geq 22.$

$L_1 = T_2 + T_3 + T_4 + T_5.$
$L_1$ represents # of ways that at at least one constraint violated.

Running total so far is $T_1 - L_1$.

$T_6 = \binom{13}{3}$
$x_1 \geq 7, x_2 \geq 11.$

$T_7 = \binom{8}{3}$
$x_1 \geq 7, x_3 \geq 16.$

$T_8 = 0$
$x_1 \geq 7, x_4 \geq 22.$ : impossible

$T_9 = \binom{4}{3}$
$x_2 \geq 11, x_3 \geq 16.$

$T_{10} = 0$
$x_2 \geq 11, x_4 \geq 22.$ : impossible

$T_{11} = 0$
$x_3 \geq 16, x_4 \geq 22.$ : impossible

$L_2 = T_6 + T_7 + T_8 + T_9 + T_{10} + T_{11}.$
$L_2$ represents # of ways that at at least two constraints violated.

Running total so far is $T_1 - L_1 + L_2$.

The above is the final total, because you can not have more than two constraints violated and still have the sum $\leq 28.$

user2661923
  • 35,619
  • 3
  • 17
  • 39
0

Let $$U=\{(x_1,x_2,x_3,x_4)\in \mathbb Z^4\mid x_1+x_2+x_3+x_4=28,\ x_i \geq 0,\ i=1,2,3,4 \},$$ $$A_k=\{(x_1,x_2,x_3,x_4)\in \mathbb Z^4\mid x_1+x_2+x_3+x_4=28,\ x_k\leq a_k,\ x_i \geq 0,\ i=1,2,3,4 \},$$ where $a_1=6$, $a_2 = 10$, $a_3 = 15$, $a_4 = 21$.

The number of solutions you want is \begin{align} |A_1\cap A_2 \cap A_3 \cap A_4| &= |U| -|(A_1\cap A_2 \cap A_3 \cap A_4)^c| \\ &= |U| - |A_1^c \cup A_2^c \cup A_3^c\cup A_4^c|\\ &= |U| - (|A_1^c|+|A_2^c|+|A_3^c|+|A_4^c|)\\ &+(|A_1^c\cap A_2^c|+|A_1^c\cap A_3^c|+|A_1^c\cap A_4^c|+|A_2^c\cap A_3^c|+|A_2^c\cap A_4^c|+|A_3^c\cap A_4^c|)\\ &-(|A_1^c\cap A_2^c\cap A_3^c|+|A_1^c\cap A_2^c\cap A_4^c|+|A_1^c\cap A_3^c\cap A_4^c|+|A_2^c\cap A_3^c\cap A_4^c|)\\ &+(|A_1^c\cap A_2^c\cap A_3^c\cap A_4^c|) \end{align}

which follows from the inclusion-exclusion principle.

Note that $A_k^c =\{(x_1,x_2,x_3,x_4)\in \mathbb Z^4\mid x_1+x_2+x_3+x_4=28,\ x_k\geq a_k+1,\ x_i \geq 0,\ i=1,2,3,4 \}.$

I'll show how to calculate these on an example and leave the rest to you (note that lots of the above sets will be empty). Let's look at $|A_1^c\cap A_2^c|$. This is the number of nonnegative integer solutions of $$x_1+x_2+x_3+x_4 = 28,\ x_1 \geq 7,\ x_2\geq 11.$$

Now, $$x_1+x_2+x_3+x_4 = 28 \implies (x_1 - 7) + (x_2 -11) + x_3 + x_4 = 10,$$ so the number of solutions is $\binom {10+4-1}{4-1}$.

The rest can be calculated analogously.

Ennar
  • 23,082