2

Find all possible solutions for $x_1+x_2+x_3=25$. Numbers have to fulfill the following conditions: $0 \leq x_1 \leq 5, 2 < x_2 \leq 10$ and $5 \leq x_3 \leq 15$. Solutions $(a,b,c)$ and $(b,a,c)$ are considered different. $x_1, x_2$ and $x_3$ are natural numbers.

I've tried it this way: I put $x_1$ as fixed $(0)$ then I put $x_2$ as fixed $(3)$ now I have $25-3=22$ which means that no matter what I put as $x_3$ I cannot get $22$. So, I see that $x_2$ can be min $(22-15-0=7)$ therefore I see that when $x_1=0, x_2$ can be min $7$ so the number of possible combinations for $x_1=0$ is $4$. Going up by one from $x_1 = 0 .. 5$, I can also increase number of $x_2$ that fits so all together there are $4+5+6+7+8+9= 39$ combinations. I've done the same for the $x_2$ and $x_3$: Fix one of them and calculate the number of possibilities, but apparently the number that I get is incorrect. I do not have the correct number to check whether I'm just making a numerical mistake or whether my logic is flawed. Any help is appreciated.

EDIT: $x_1, x_2$ and $x_3$ are natural numbers.

N. F. Taussig
  • 76,571
Maria
  • 157

4 Answers4

2

The standard way to solve such problems is to use generating functions.

We "encode" the conditions as coefficients of polynomials, so $0 \le x_1 \le 5$, becomes $(1+x+x^2+x^3+x^4+x^5)$ ,$2 < x_2 \le 10$ becomes $(x^3 + x^4 + x^5 +x^6+ x^7+ x^8+x^9 + x^{10})$, while the final condition becomes $5 \le x_3 \le 15$ becomes $(x^5 +x^6 + \ldots x^{14} + x^{15})$. If we multiply these 3 together and look at the coefficinet of $x^{25}$, we see that we get a sum of $1$'s, one for each combination of choices of $x^i$ from these 3 polynomials: solution $(a,b,c)$ corresponds to the product of $x^a$ from the first, $x^b$ from the second and $x^c$ from the last polynomial. This contributes $1$ to the coefficient of $x^{21}$ precisely when $a+b+c= 25$.

This coefficient can be lazily obtained by using a computer algebra solution, e.g. wolfram alpha and read off the coefficient (here $21$).

It's also possible to do it purely analytically, using binomial formulas and geometric series; there are plenty of examples on this site alone.

Henno Brandsma
  • 242,131
1

With $x_1=0$ there is $1$ possibility. ( $(x_2,x_3)=(10,15)$)

With $x_1=1$ there are $2$ possibility.

With $x_1=2$ there are $3$ possibility.

With $x_1=3$ there are $4$ possibility.

With $x_1=4$ there are $5$ possibility.

With $x_1=5$ there are $6$ possibility.

So there are $\color{blue}{21}$ possibilities in toto.

Donald Splutterwit
  • 36,613
  • 2
  • 26
  • 73
1

i would start with $$0\le x_1\le 5$$ then you will get $$x_1=0$$ $$x_2=1$$ $$x_3=2$$ $$x_4=3$$ $$x_5=4$$ $$x_6=5$$ then you have only to solve $$x_2+x_3=25-x_1$$ for each case and so on

1

Method 1: We want to find the number of integer solutions of the equation $$x_1 + x_2 + x_3 = 25 \tag{1}$$ subject to the restrictions $0 \leq x_1 \leq 5$, $2 < x_2 \leq 10$, $5 \leq x_3 \leq 15$. Since $x_2$ is an integer, the restriction $2 < x_2 \leq 10$ is equivalent to the statement $3 \leq x_2 \leq 10$.

As a first step, we will convert the problem into the equivalent problem in the nonnegative integers. Following the suggestion that @JMoravitz made in the comments, we let $x_2' = x_2 - 3$ and $x_3' = x_3 - 5$. Then $x_2'$ and $x_3'$ are nonnegative integers satisfying the inequalities $0 \leq x_2' \leq 7$ and $0 \leq x_3' \leq 10$. Substituting $x_2' + 3$ for $x_2$ and $x_3' + 5$ for $x_3$ in equation 1 yields \begin{align*} x_1 + x_2' + 3 + x_3' + 5 & = 25\\ x_1 + x_2' + x_3' & = 17 \tag{2} \end{align*} Equation 2 is an equation in the nonnegative integers. A particular solution of equation 2 corresponds to the insertion of two addition signs in a row of $17$ ones. For instance, $$+ 1 1 1 1 1 1 1 1 + 1 1 1 1 1 1 1 1 1$$ corresponds to the solution $x_1 = 0$, $x_2' = 8$, and $x_3' = 9$. The number of solutions of equation 2 is $$\binom{17 + 2}{2} = \binom{19}{2}$$ since we must choose which two of the nineteen positions required for seventeen ones and two addition signs will be filled with addition signs.

The number of solutions of the equation $$x_1 + x_2 + x_3 + \ldots + x_k = n$$ in the nonnegative integers is $$\binom{n + k - 1}{k - 1}$$ since we must choose which $k - 1$ of the $n + k - 1$ positions required for $n$ ones and $k - 1$ addition signs will be filled with addition signs.

However, we must remove those solutions of equation 2 that violate the restrictions that $x_1 \leq 5$, $x_2' \leq 7$, or $x_3' \leq 10$. Notice that we cannot violate the restrictions on $x_2'$ and $x_3'$ simultaneously since $8 + 11 = 19 > 17$. However, it is possible to simultaneously violate the restrictions on $x_1$ and $x_2'$ and on $x_1$ and $x_3'$.

Suppose $x_1 > 5$. Since $x_1$ is an integer, $x_1 \geq 6$, so $x_1' = x_1 - 6$ is a nonnegative integer. Substituting $x_1' + 6$ for $x_1$ in equation 2 yields \begin{align*} x_1' + 6 + x_2' + x_3' & = 17\\ x_1' + x_2' + x_3' & = 11 \tag{3} \end{align*} Equation 3 is an equation in the nonnegative integers with $$\binom{11 + 2}{2} = \binom{13}{2}$$ solutions. By similar reasoning, you can show that there are

$$\binom{9 + 2}{2} = \binom{11}{2}$$

cases in which the restriction $x_2' \leq 7$ is violated and

$$\binom{6 + 2}{2} = \binom{8}{2}$$

cases in which the restriction $x_3' \leq 10$ is violated.

However, if we subtract these from the total, we will have subtracted cases in which two of the restrictions are violated simultaneously twice, once for each way we could designate one of the restrictions as the one that is being violated. Since we only want to subtract them once, we must add them back.

Suppose $x_1 > 5$ and $x_2' > 7$. Let $x_1' = x_1 - 6$; let $x_2'' = x_2' - 8$. Then $x_1'$ and $x_2'$ are nonnegative integers. Substituting $x_1' + 6$ for $x_1$ and $x_2'' + 8$ for $x_2'$ in equation 2 yields \begin{align*} x_1' + 6 + x_2'' + 8 + x_3' & = 17\\ x_1' + x_2'' + x_3' & = 3 \tag{4} \end{align*} Equation 4 is an equation in the nonnegative integers with

$$\binom{3 + 2}{2} = \binom{5}{2}$$

solutions. By similar reasoning, you can show that there are

$$\binom{0 + 2}{2} = \binom{2}{2}$$

cases in which the restrictions on $x_1$ and $x_3'$ are simultaneously violated.

By the Inclusion-Exclusion Principle, the number of admissible solutions of equation 2 is

$$\binom{19}{2} - \binom{13}{2} - \binom{11}{2} - \binom{8}{2} + \binom{5}{2} + \binom{2}{2}$$

Method 2: Since $0 \leq x_1 + x_2' + x_3' \leq 5 + 7 + 10 = 22$ and $17$ is closer to $22$ than $0$, we can reduce the number of steps needed to solve equation 2 by making the following substitutions. \begin{align*} y_1 & = 5 - x_1\\ y_2 & = 7 - x_2'\\ y_3 & = 10 - x_3' \end{align*} Observe that $y_1, y_2, y_3$ are nonnegative integers satisfying $y_1 \leq 5$, $y_2 \leq 7$, and $y_3 \leq 10$. Substituting $5 - y_1$ for $x_1$, $7 - y_2$ for $x_2'$, and $10 - y_3$ for $x_3'$ in equation 2 yields \begin{align*} 5 - y_1 + 7 - y_2 + 10 - y_3 & = 17\\ -y_1 - y_2 - y_3 & = -5\\ y_1 + y_2 + y_3 & = 5 \tag{5} \end{align*} Equation 5 is an equation in the nonnegative integers with

$$\binom{5 + 2}{2} = \binom{7}{2}$$

solutions.

N. F. Taussig
  • 76,571