[Math] Difference between number of positive integer solution and nonnegative integer solution

combinationsdiscrete mathematics

This question may rather be simple to others but I'm struggling to understand it.

So for example, in the book it says, if I want to count the number of compositions for number "$7$" (e.g $6+1,3+1+2+1$, etc..),

i) For one summand, there is only 1 composition, which is $7$ (I understand this part)

ii) For two(positive) summands, we want to count the number of integer solutions for $a_1+a_2=7$, where $a_1,a_2 > 0$ ( I understand this part because I want to count two numbers that add up to $7$ so it's $a_1+a_2=7$.)

This is equal to the number of integer solutions for $x_1+x_2=5$, where $x1,x2 \ge 0$. (I don't understand this part. How can $a_1+a_2=7$, where $a1,a2 >0$, equal to $x_1+x_2=5$, where $x1,x2 \ge 0$?? Maybe I assume the 2nd statement excludes $7$ and $0$, so it equals to $5$??)

iii) Also for three summands, we want to count the number of positive integer solutions for $y_1+y_2+y_3=7$ (I understand this part. I want to count three numbers that add up to $7$)

This is equal to the number of nonnegative integer solutions for $x_1+x_2+x_3=4$ (I don't understand how 1st and 2nd statement can be equal and why the 2nd statement add up to $4$ instead of $7$)

An easy explanation would be very much appreciated. Thank you.

Best Answer

I have $7$ identical candies. I want to distribute these among $3$ (distinct) kids so that each kid gets at least one candy.

Let $x_1$ be the number of candies Kid1 will get, let $x_2$ be the number of candies Kid2 will get, and let $x_3$ be the number of candies Kid3 will get. The number of ways to do the job is the number of solutions of $x_1+x_2+x_3=7$ in positive integers (remember, each kid gets at least $1$ candy).

Now let us think about the problem another way. Since each kid will get at least $1$ candy, give $1$ to each. There are $4$ candies left. Let $y_1$ be the number of extra candies Kid1 will get, and define $y_2$ and $y_3$ similarly. Then the $y_i$ are all $\ge 0$, but one or more may be $0$. The number of ways to distribute the $4$ extra candies is the number of solutions of $y_1+y_2+y_3=4$ in non-negative integers.

Thus the number of solutions of $x_1+x_2+x_3$ in positive integers is the same as the number of solutions of $y_1+y_2+y_3=4$ in non-negative integers.


Since formulas don't cause tooth decay, you may like formulas better than candies. Suppose that $x_1+x_2+x_3=7$, where the $x_i$ are positive integers. Let $y_i=x_i-1$. Then $y_1+y_2+y_3=(x_1-1)+(x_2-1)+(x_3-1)=7-3=4$. Moreover, all solutions of $y_1+y_2+y_3=4$ in non-negative integers are obtained from a unique solution of $x_1+x_2+x_3=7$ in positive integers by setting $y_i=x_i-1$.

Related Question