How many solutions to $x_1 + x_2 + x_3 + x_4 + x_5 = 21$ given the following restrictions …

How many solutions to $x_1 + x_2 + x_3 + x_4 + x_5 = 21$ where $x_i$, $i = 1, 2, 3, 4, 5$ is a nonnegative integer such that $0 \le x_1 \le 3$, $1 \le x_2 \lt 4$ and $x_3 \ge 15$,

My Approach

My idea is to find the total number of solutions without restrictions and from that subtract the solutions with restrictions to arrive at the answer.

Number of solutions without restrictions: $C(5-1 + 21, 21) = 12650$

Restriction 1: $x_3 \ge 15$ Number of solutions: $C(5-1+6,6)$ = 210

Restriction 2: $0 \le x_1 \le 3$ We can change the restriction to $x_1 \ge 4$ and subtract the number of solutions with this restriction from the total.

$C(5-1 + 21, 21) - C(5-1 + 17, 17) = 6665$

Restriction 3: $1 \le x_2 \lt 4$ We can break this restriction down into two parts: when $x \ge 1$ and when $x \ge 5$. Then subtract case $2$ from case $1$.

Case 1: $x \ge 1$. $C(5-1 + 20, 20) = 10626$

Case 2: $x \ge 5$. $C(5-1 + 21, 21) - C(5-1 + 16, 16) = 7805$.

Case $1$ - Case $2$ is: $2851$.

Now we can sum the restrictions and remove them from the total.

$$12650 - (2851 + 210 + 6665) = 2924$$

However, the answer in the textbook is: $106$.

Where is my reasoning incorrect?

Thanks for your time!

P.S. I know that there is this question however, I'm not looking for the answer per se. I am more interested in why my reasoning is flawed.

• Do any of these cases overlap? e.g. maybe both $x_3 \ge 15$ and $x_1 \le 3,$ such as in $3+3+15=21 – coffeemath Dec 9 '16 at 16:49 • You've subtracted the solutions with$x_3\geq 15$. That doesn't make sense. The solutions with$x_3\geq 15$and$x_2\geq 1$and no other conditions should be your base solution. – Thomas Andrews Dec 9 '16 at 16:52 2 Answers Always begin by taking care of the lower bounds, because they can be handled automatically just by changing the variables. Let$y_1=x_1$,$y_2=x_2-1$,$y_3=x_3-15$,$y_4=x_4$, and$y_5=x_5$; these new variables are non-negative if and only if the original ones satisfy their lower bound restrictions, and $$x_1+x_2+x_3+x_4+x_5=21$$ if and only if $$y_1+y_2+y_3+y_4+y_5=21-1-15=5\;.\tag{1}$$ The number of solutions to$(1)$in non-negative integers is $$\binom{5+5-1}{5-1}=\binom94=126\;,$$ but we need to eliminate the solutions with$y_1=x_1>3$and those with$y_2=x_2-1\ge 4-1=3$. In other words, you have to eliminate all solutions that have$y_1\ge 4$or$y_2\ge 3$. How many solutions to$(1)$have$y_1\ge 4$? That’s just another lower bound problem. You could solve it by setting$z_1=y_1-4$,$z_2=y_2$,$z_3=y_3$,$z_4=y_4$, and$z_5=y_5$and calculating the number of solutions of $$z_1+z_2+z_3+z_4+z_5=5-4=1$$ in non-negative integers by the usual formula, or you could notice that if$y_2=4$there are exactly$4$solutions, each with one of the other variables equal to$1$and the rest$0$, if$y_2=5$there is just one solution, with the other variables all$0$, so there are$5$solutions with$y_1\ge 4$. How many solutions to$(1)$have$y_2\ge 3$? Set$z_1=y_1$,$z_2=y_2-3$,$z_3=y_3$,$z_4=y_4$, and$z_5=y_5$, and calculate the number of solutions to $$z_1+z_2+z_3+z_4+z_5=5-3=2\;,$$ getting$\binom{2+5-1}{5-1}=\binom64=15$. Note that no solution to$(1)$violates both of the upper bound conditions, so there is no overlap between the$5$solutions with$y_1\ge 4$and the$15$with$y_2\ge 3$. Thus, exactly$5+15=20$of the$126$unrestricted solutions to$(1)$violate the upper bounds, leaving$106$solutions that meet the conditions of the problem. • @BrianMScott: Instructive and nicely written! (+1) – Markus Scheuer Dec 10 '16 at 7:29 • Thanks for the clean and intuitive explanation! – Jeel Shah Dec 11 '16 at 19:06 • @JeelShah: You’re welcome! – Brian M. Scott Dec 11 '16 at 20:26$\newcommand{\bbx}{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,} \newcommand{\braces}{\left\lbrace\,{#1}\,\right\rbrace} \newcommand{\bracks}{\left\lbrack\,{#1}\,\right\rbrack} \newcommand{\dd}{\mathrm{d}} \newcommand{\ds}{\displaystyle{#1}} \newcommand{\expo}{\,\mathrm{e}^{#1}\,} \newcommand{\ic}{\mathrm{i}} \newcommand{\mc}{\mathcal{#1}} \newcommand{\mrm}{\mathrm{#1}} \newcommand{\pars}{\left(\,{#1}\,\right)} \newcommand{\partiald}[]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\root}[]{\,\sqrt[#1]{\,{#2}\,}\,} \newcommand{\totald}[]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}} \newcommand{\verts}{\left\vert\,{#1}\,\right\vert}$How many solutions to$\ds{x_{1} + x_{2} + x_{3} + x_{4} + x_{5} = 21}$where$\ds{x_{i}}\ds{\pars{~i = 1, 2, 3, 4, 5~}}$is a nonnegative integer such that$\quad\ds{\left\{\begin{array}{rcccl} \ds{0} & \ds{\leq} & \ds{x_{1}} & \ds{\le} & \ds{3} \\ \ds{1} & \ds{\leq} & \ds{x_{2}} & \ds{\lt} & \ds{4} \\ \ds{x_{3}} & \ds{\ge} & \ds{15}&& \end{array}\right.}\$ $$\bbx{\ds{\mbox{" However, the answer in the textbook is:}\ \color{#f00}{\large 106} "}}$$

The answer is given by: \begin{align} &\bracks{z^{21}}\bracks{\sum_{x_{1} = 0}^{3}z^{x_{1}} \sum_{x_{2} = 1}^{3}z^{x_{2}}\sum_{x_{3} = 15}^{\infty}z^{x_{3}} \sum_{x_{4} = 0}^{\infty}z^{x_{4}}\sum_{x_{5} = 0}^{\infty}z^{x_{5}}} \\[5mm] = &\ \bracks{z^{\color{#f00}{21}}}\bracks{\pars{z^{4} - 1 \over z - 1} \pars{z^{\color{#f00}{1}}\,{z^{3} - 1 \over z - 1}} \pars{z^{\color{#f00}{15}} \over 1 - z}\pars{1 \over 1 - z}\pars{1 \over 1 - z}} \\[5mm] = &\ \bracks{z^{5}}\bracks{\pars{1 - z^{4}}\pars{1 - z^{3}} \over \pars{1 - z}^{5}} = \bracks{z^{5}}\bracks{1 - z^{3} - z^{4} + z^{7} \over \pars{1 - z}^{5}} \\[5mm] = &\ \bracks{z^{5}}\bracks{1 \over \pars{1 - z}^{5}} - \bracks{z^{2}}\bracks{1 \over \pars{1 - z}^{5}} - \bracks{z}\bracks{1 \over \pars{1 - z}^{5}} \\[5mm] = &\ {-5 \choose 5}\pars{-1}^{5} - {-5 \choose 2}\pars{-1}^{2} - {-5 \choose 1}\pars{-1}^{1} = {9 \choose 5} - {6 \choose 2} - {5 \choose 1} \\[5mm] = & 126 - 15 - 5 = \bbox[15px,#ffe,border:2px dotted navy]{\ds{106}} \end{align}