2
$\begingroup$

I am studying computer science and take a discrete math modules, right now trying to learn combinational theory. I know how to solve when cases are $\geq 1$ and x's are all positive but not sure how to solve for cases such as these.

How many solutions $(x_1, x_2, x_3, x_4, x_5)$ are there to the equation

$x_1 - x_2 - x_3 + x_4 + x_5 = 3 $

where each $x_i$ is an integer and

\begin{align*} x_1 &\leq 1, \\ x_2 &\geq 2, \\ x_3 &\geq 1, \\ x_i &\leq -1 + 4i \text{ for } i \in \{4,5\}? \end{align*}

I try

$-x_1 \geq -1$

$x_2 \geq 2$

$x_3 \geq 1$

$-x_4 \geq -15$

$-x_5 \geq -19$

Thus

$y_1 = x_1 + 2$

$y_2 = -x_2 + 1$

$y_3 = -x_3$

$y_4 = x_4 + 16$

$y_5 = x_5 + 20$

Getting

$y_1 + y_2 + y_3 + y_4 + y_5 = x_1 - x_2 - x_3 + x_4 + x_5 + 2 + 1 + 16 + 20$ = 42

Thus getting

$\binom{41}{4}$

However the solution is $\binom{40}{4}$ and I don't know what's the mistake I made to not get the correct answer.

$\endgroup$
1
  • $\begingroup$ As stated, there is no requirement that the $x_i$s be non-negative. Would you please confirm that this is the correct interpretation, or not, as the case may be? $\endgroup$
    – awkward
    Commented May 1 at 17:47

1 Answer 1

1
$\begingroup$

$x_1 - x_2 - x_3 + x_4 + x_5 = 3 $

where each $x_i$ is an integer and

\begin{align*} x_1 &\leq 1, \\ x_2 &\geq 2, \\ x_3 &\geq 1, \\ x_i &\leq -1 + 4i \text{ for } i \in \{4,5\}? \end{align*}

This is a challenging/complicated problem to attack.

My approach will be to dispense with any attempt at elegance, and take one slow, careful step at a time.

Superficially, it seems that this problem can be attacked via Stars and Bars theory. For this theory, see this article and this article.

However, there are two roadblocks that must be cleared first:

  • Stars and Bars theory is based on summing variables (e.g. $~a_1 + a_2 + \cdots + a_5 ~$).
    This particular roadblock may be handled as the original poster handled it, via a change of variables (e.g. $~y_2 = -x_2, ~y_3 = -x_3~$).

  • In a Stars and Bars problem, represented by $~a_1 + a_2 + \cdots + a_5, ~$ while upper limits on the variables $~a_1, \cdots, a_5~$ are optional, lower limits on these variables are mandatory. In fact, basic Stars and Bars theory is based on the presumption that each variable has a lower limit of $~0.~$

In this problem, once the 1st bullet point above is implemented, you have the $~5~$ variables, $~x_1, y_2, y_3, x_4, x_5,~$ each of which has an upper limit, but no lower limit.

Therefore, the first step must be to use analysis to construct lower limits on these variables.


First, examine how the change of variables has altered the problem: enumerate the number of solutions to

  • $x_1 + y_2 + y_3 + x_4 + x_5 = 3.$

  • $x_1,y_2,y_3,x_4,x_5 \in \Bbb{Z}.$

  • $~x_1 \leq 1, ~y_2 \leq -2, ~y_3 \leq -1, ~x_4 \leq 15, ~x_5 \leq 19.$

Now, if each of these variables was set to its maximum value, then the sum would be $~[ ~1 + (-2) + (-1) + 15 + 19 ~] = 32.$

Since $~32 - 3 = 29,~$ you can immediately construct the necessary lower bounds on each of these variables. These bounds are given by

  • $x_1 \geq 1 - 29 = -28.$
  • $y_2 \geq -2 - 29 = -31.$
  • $y_3 \geq -1 - 29 = -30.$
  • $x_4 \geq 15 - 29 = -14.$
  • $x_5 \geq 19 - 29 = -10.$

The next step is to use a change of variables, so that the lower bound on each of these variables is $~0.~$ This may be done as follows:

  • $a_1 = x_1 + 28 \implies 0 \leq a_1 \leq 29 ~: ~a_1 \in \Bbb{Z}.$
  • $a_2 = y_2 + 31 \implies 0 \leq a_2 \leq 29 ~: ~a_2 \in \Bbb{Z}.$
  • $a_3 = y_3 + 30 \implies 0 \leq a_3 \leq 29 ~: ~a_3 \in \Bbb{Z}.$
  • $a_4 = x_4 + 14 \implies 0 \leq a_4 \leq 29 ~: ~a_4 \in \Bbb{Z}.$
  • $a_5 = x_5 + 10 \implies 0 \leq a_5 \leq 29 ~: ~a_5 \in \Bbb{Z}.$

Further, since $~x_1 + y_2 + y_3 + x_4 + x_5 = 3,~$ the problem has been transformed into enumerating the number of solutions that satisfy the $~5~$ bullet points above, where

$$a_1 + a_2 + \cdots + a_5 = 3 + [~28 + 31 + 30 + 14 + 10] = 116.$$


At this point in the analysis, each of the variables $~a_1,\cdots,a_5~$ has a lower bound of $~0,~$ and an upper bound of $~29.~$ Here, I am going to (finally) conquer the problem with the method given in this answer. The linked answer provides a blueprint of how to combine Inclusion-Exclusion with Stars-And-Bars to manage the upper bounds of each variable.

Note that (for example) $~[ ~a_1 \leq 29 ~] \iff [ ~a_1 < 30 ~],~$ assuming that $~a_1 \in \Bbb{Z}.~$

Following the model given in the linked answer, you have that the number of solutions is given by

$$\sum_{r = 0}^5 (-1)^r T_r,~$$

where

  • $T_0 = \displaystyle \binom{116 + 4}{4} = \binom{120}{4}.$

  • $T_1 = \displaystyle \binom{5}{1} \times \binom{86 + 4}{4} = \binom{5}{1} \times \binom{90}{4}.$

  • $T_2 = \displaystyle \binom{5}{2} \times \binom{56 + 4}{4} = \binom{5}{2} \times \binom{60}{4}.$

  • $T_3 = \displaystyle \binom{5}{3} \times \binom{26 + 4}{4} = \binom{5}{3} \times \binom{30}{4}.$

  • $T_4 = \displaystyle \binom{5}{4} \times \binom{-4 + 4}{4} = \binom{5}{4} \times \binom{0}{4} = 0.$

  • Similarly, $~T_5 = 0.$


Therefore, the number of solutions is

$$(T_0 + T_2) - (T_1 + T_3)$$

$$= \left\{ ~\binom{120}{4} + \left[ ~10 \times \binom{60}{4} ~\right] ~\right\} - \left\{ ~\left[ ~5 \times \binom{90}{4} ~\right] + \left[ ~10 \times \binom{30}{4} ~\right] ~\right\}$$

$$= [ ~8214570 + 4876350 ~] - [ ~12775950 + 274050 ~] = 40920 = \binom{33}{4}.$$

Incidentally, I ran a java program to sanity check the final computation of $~40920.$

The program ran a 5-nested loop, where :

  • $-28 \leq x_1 \leq 1.$
  • $-31 \leq y_2 \leq -2.$
  • $-30 \leq y_2 \leq -1.$
  • $-14 \leq x_4 \leq 15.$
  • $-10 \leq x_5 \leq 19.$

The java program then manually counted each occurrence where $~x_1 + y_2 + y_3 + x_4 + x_5 = 3,~$ and the java program returned $~40920.~$

So, if this answer has an analytical or arithmetic mistake, the mistake must have occurred before the determination of the lower and upper bounds for $~x_1, ~y_2, ~y_3, ~x_4, ~x_5.$

Assuming that my answer has no mistake, my only explanation for the official solution is that there must be a mistake in the original posting of the question, on this webpage.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .