2

Determine the number of integer solutions of the equation $$ x_{1}+x_{2}+x_{3}+x_{4}=20 $$ under the restrictions: $$ \begin{array}{l} 2 \leq x_{1} \leq 6 \\ 0 \leq x_{2} \leq 5 \\ 2 \leq x_{3} \leq 8 \\ 2 \leq x_{4} \leq 6 \end{array} $$ I did $x_1=y_1+2$ then $0\leq y_1 \leq4$

$x_2=y_2$ then $0\leq y_2 \leq5$

$x_3=y_3+2$ then $0\leq y_3 \leq6$

$x_4=y_4+2$ then $0\leq y_4 \leq4$

So $y_1+y_2+y_3+y_4 \leq 19$ So the number of solutions is

$\sum_{k=0}^{19}\left(\begin{array}{c} k+3 \\ k \end{array}\right)=\sum_{k=0}^{19}\left(\begin{array}{c} k+3 \\ 3 \end{array}\right)$ is right?

  • @hardmath just in the last one in $x_4$ its $y_4$ – Olga Gonzalez Mar 03 '21 at 22:22
  • No, the answer is more complicated due to the upper limits. Please clarify your limits because the subsequent working is in contradiction to the given values. – Joffan Mar 03 '21 at 22:23
  • 1
    Now you fixed the definitions of the $y_i$ and their inequalities but now the inequality for the sum changes also. (That said you might consider shifting everything so the lower bounds are 1, this might make the bookkeeping that follows a little easier...) – Ian Mar 03 '21 at 22:27
  • 1
    @hardmath oh sorry I wrote it wrong now I already corrected them – Olga Gonzalez Mar 03 '21 at 22:28
  • I'm pretty sure your way won't work because there are restriction on y_1,y_2 , y_3 are different. The way you did assumes the restriction on each variable is same – tryst with freedom Mar 03 '21 at 22:35
  • 1
    @hardmath $y_1+y_2+y_3+y_4=20-6=14$ right? – Olga Gonzalez Mar 03 '21 at 22:53
  • To the best of my knowledge, there are 2 distinct ways of attacking this kind of problem: [1] Stars and Bars [2] Generating Functions. For a mathSE query, where each method was independently used, see this. – user2661923 Mar 04 '21 at 00:17

4 Answers4

2

The combined values of the maximum value for the $x$'s is 25. We can then take four part ordered partitions of $5$ (including zeros) and subtract each of those from the maximum.

The first set of partitions is $(5,0,0,0)$ with the $5$ being in four potential locations. You cannot subtract $5$ from $x_1$ or $x_4$ so there are $2$ ways of doing this.

The second set of partitions is $(4,1,0,0)$. There are $12$ ways of ordering these numbers.

The third set of partitions is $(3,2,0,0)$.There are $12$ ways of ordering these numbers.

The fourth set is $(3,1,1,0)$.There are $12$ ways of ordering these numbers.

The fifth set is $(2,2,1,0)$.There are $12$ ways of ordering these numbers.

Finally the sixth and last set is $(2,1,1,1)$. There are four locations for the $2$. Therefore there are $4$ ways of ordering these numbers.

$2+12+12+12+12+4=54$

There are $54$ solutions to the equation $x_1+x_2+x_3+x_4=20$.

quantus14
  • 2,624
1

With $x_{1}+x_{2}+x_{3}+x_{4}=20$ and the the restrictions: \begin{array}{l} 2 \leq x_{1} \leq 6 \\ 0 \leq x_{2} \leq 5 \\ 2 \leq x_{3} \leq 8 \\ 2 \leq x_{4} \leq 6 \end{array}

You have a good idea to switch to secondary variables to simplify the limits; there are various ways to do this but I would move to zero lower limits with: \begin{array}{l} y_1=x_1-2 & & 0 \leq y_{1} \leq 4 \\ y_2=x_2 & & 0 \leq y_{2} \leq 5 \\ y_3=x_3-2 & & 0 \leq y_{3} \leq 6 \\ y_4=x_3-2 & & 0 \leq y_{4} \leq 4 \end{array} and $x_{1}+x_{2}+x_{3}+x_{4}=20$ then means that $y_{1}+y_{2}+y_{3}+y_{4}=14$.

Now without the upper limits we would have the standard method to determine options at $\binom{14+3}{3}$. However this counts a number of cases when one or more of the variables exceed their limits. So we need to count those cases too by "pre-loading" the smallest illegal value into the each variable in turn in order to remove these. So to formalize this we'll consider a new set of variables: \begin{array}{l} z_1=y_1-5 \\ z_2=y_2-6 \\ z_3=y_3-7 \\ z_4=y_4-5 \end{array} which then means that any $z_i\geq 0$ would imply that the corresponding $y_i$ (and $x_i$) has broken its upper constraint.

So then we consider the cases (with options shown): \begin{array}{l} \color{red}{z_{1}}+y_{2}+y_{3}+y_{4}=14-5 & & \binom{9+3}{3} \\ y_{1}+\color{red}{z_{2}}+y_{3}+y_{4}=14-6 & & \binom{8+3}{3} \\ y_{1}+y_{2}+\color{red}{z_{3}}+y_{4}=14-7 & & \binom{7+3}{3} \\ y_{1}+y_{2}+y_{3}+\color{red}{z_{4}}=14-5 & & \binom{9+3}{3} \end{array} with a total of $C_1 = 2\binom{12}{3}+\binom{11}{3}+\binom{10}{3} = 725$

However then we are into an inclusion-exclusion cycle to avoid double counting the cases when more than one constraint is broken, which will need to be added back in. There are six viable cases of two constraints broken: \begin{array}{l} \color{red}{z_{1}}+\color{red}{z_{2}}+y_{3}+y_{4}=14-5-6 & & \binom{3+3}{3} \\ \color{red}{z_{1}}+y_{2}+\color{red}{z_{3}}+y_{4}=14-5-7 & & \binom{2+3}{3} \\ \color{red}{z_{1}}+y_{2}+y_{3}+\color{red}{z_{4}}=14-5-5 & & \binom{4+3}{3} \\ y_{1}+\color{red}{z_{2}}+\color{red}{z_{3}}+y_{4}=14-6-7 & & \binom{1+3}{3} \\ y_{1}+\color{red}{z_{2}}+y_{3}+\color{red}{z_{4}}=14-6-5 & & \binom{3+3}{3} \\ y_{1}+y_{2}+\color{red}{z_{3}}+\color{red}{z_{4}}=14-7-5 & & \binom{2+3}{3} \end{array} with a total of $C_2 = \binom{7}{3}+2\binom{6}{3}+2\binom{5}{3}+\binom{4}{3}=99$

There is no combination that allows three constraints to be broken simultaneously broken so we can stop there; the total combinations is then $$\binom{17}{3}-C_1+C_2$$


The trick of looking at the inverse space in the answer by @quantus14 provides a very nice shortcut with the same basic approach.

Defining $w_i$ by how far off each $x_i$ is from its top limits, that is \begin{array}{l} w_1=6-x_1 & & w_1 \leq 4 \\ w_2=5-x_2 & & w_2 \leq 5 \\ w_3=8-x_3 & & w_3 \leq 6 \\ w_4=6-x_4 & & w_4 \leq 4 \end{array} we can see that $w_1+w_2+w_3+w_4 = (6+5+8+6) - (x_1+x_2+x_3+x_4) = 25-20 = 5$. Now unconstrained the options for dividing the $5$ amongst the $w_i$ looks like $\binom{5+3}{3} = 56$ but we have two cases that break the value range available, since $w_1$ and $w_4$ have a maximum value of $4$. So the result is $\binom{8}{3}-2$, matching the previous result.

Joffan
  • 39,627
0

Actually there is a trick to do this, to remove inequality introduce a new dummy variable :

$$ y_1 + y_2 + y_3 + y_4 + c =19$$

Now, this represent same as inequaliy if we let $ c$ vary from $[0,19]$, can you think why? [Well I couldn't haha :P, see my question about it here]

After this use generating functions as shown in this post

Comment on your method:

Stars and bars method of finding solutions assumes constraints on each variable is same, in your question each variable has different upper limit , so it doesn't work. See the derivation for formula for understanding why. A modified version however works see here( Thanks to user2661923's comment)

  • "Stars and bars method of finding solutions assumes constraints on each variable is same, in your question each variable has different upper limit , so it doesn't work." Unclear what you are saying. If you are saying that the OP incorrectly implemented Stars and Bars - then okay. If not, if you are instead saying that Stars and Bars (in general) can't handle this type of problem, then please see my comment following the query. – user2661923 Mar 04 '21 at 00:20
  • I meant the standard stars and bars approach for these kind of problems @user2661923 – tryst with freedom Mar 04 '21 at 06:58
  • Then, you are mistaken: see my comment. – user2661923 Mar 04 '21 at 07:00
  • by standard I meant each variable has same constraint, though to be fair I didn't think you could modify it such that it would work here too – tryst with freedom Mar 04 '21 at 07:04
0

You can try the standard generating function approach which I explain first and then apply it to current question.

Consider a simpler equation where $i, j$ are non-negative and $i+j=10$. And next consider the following product $$(1+x+x^2+\dots+x^i+\dots)(1+x+x^2+\dots+x^j+\dots)$$ After multiplying one obtains terms of the form $x^{i+j} $ where $i, j$ are non-negative integers. And all such like terms need to be added together to get the final product. Thus the coefficient of $x^{10}$ in the above product will equal the number of pairs $(i, j) $ such that $i+j=10$.

One can create similar product expressions to deal with equation $i+j+k=12$. And we can get more creative to deal with equations like $2i+j=20$ by forming the product $$(1+x^2+x^4+\dots+x^{2i}+\dots)(1+x+x^2+\dots+x^j+\dots)$$ And if the variables have got constraints like $1\leq i\leq 10$ then we can keep the corresponding factor as $$(x+x^2+\dots+x^{10})$$ Now what do we get out of all this? Multiplying such factors is a challenge if we do it term by term. Luckily we have the formula to sum a geometric progression to simplify each factor. And further we make use of the standard formula $$(1-x)^{-n}=\sum_{r=0}^{\infty} \binom{n+r-1}{r}x^r$$


For the current problem the desired number of solutions is equal to the coefficient of $x^{20}$ in the product $$\sum_{i=2}^{6}x^i\cdot\sum_{i=0}^5 x^i\cdot\sum_{i=2}^{8}x^i\cdot \sum_{i=2}^{6}x^i$$ The above expression equals $$x^6\cdot\frac{1-x^5}{1-x}\cdot\frac{1-x^6}{1-x}\cdot\frac{1-x^7}{1-x}\cdot\frac{1-x^5}{1-x}$$ or $$x^6(1-x^5)^2(1-x^6)(1-x^7)(1-x)^{-4}$$ Thus we need the coefficient of $x^{14}$ in $$(1-x^5)^2(1-x^6)(1-x^7)(1-x)^{-4}$$ The above expression equals $$(1-2x^5+x^{10})(1-x^6-x^7+x^{13})(1-x)^{-4}=(1-2x^5-x^6-x^7+x^{13}+2x^{11}+2x^{12}-2x^{18}+x^{10}-x^{16}-x^{17}+x^{23})(1-x)^{-4}$$ We can get rid of terms with powers higher than $x^{14}$ in first factor and the desired number of solutions is thus equal to the coefficient of $x^{14}$ in $$(1-2x^5-x^6-x^7+x^{10}+2x^{11}+2x^{12}+x^{13})(1-x)^{-4}=(1-2x^5-x^6-x^7+x^{10}+2x^{11}+2x^{12}+x^{13})\sum_{r=0}^{\infty} \binom{4+r-1}{r}x^r$$ This coefficient clearly equals $$\binom{4+14-1}{14}-2\binom{4+9-1}{9}-\binom{4+8-1}{8}-\binom{4+7-1}{7}+\binom{4+4-1}{4}+2\binom{4+3-1}{3}+2\binom{4+2-1}{2}+\binom{4+1-1}{1}$$ The above simplifies to $$\binom{17}{3}-2\binom{12}{3}-\binom{11}{3}-\binom{10}{3}+\binom{7}{3}+2\binom{6}{3}+2\binom{5}{2}+\binom{4}{1}=680-440-165-120+35+40+20+4=54$$ The generating function approach is well suited to such problems and is intuitive and easy to understand. Some care however needs to be taken while performing the computations so that no term is left out.

  • @quantus14: I suggest you read the answer from start to end. I start with coefficient of $x^{20}$. – Paramanand Singh Mar 05 '21 at 15:27
  • @quantus14: this is not about polynomials, but algebra of formal power series. That's what generating functions are. – Paramanand Singh Mar 05 '21 at 15:28
  • @quantus14: well it has powers beyond any number you think. Do you know the binomial formula $(1+x)^m=\sum_{n=0}^{\infty} \binom {m} {n} x^n$? This is an infinite series unless $n$ is a non-negative integer. We have $(1-x)^{-4}=1+4x+10x^2+\dots$ and it has terms with every positive integral power of $x$. – Paramanand Singh Mar 05 '21 at 15:41
  • @quantus14: btw i liked your answer which is very smart, non-obvious and has much less calculation. The benefit of generating functions is that they make the problem routine. You don't need to think too much in this manner. – Paramanand Singh Mar 05 '21 at 15:43
  • @quantus14: no problems! I will add some more explanation in my answer (but not now). – Paramanand Singh Mar 05 '21 at 16:00