4
The problem I'm trying to solve:

Determine the number of integer solutions to the equation
$x_1 + x_2 + x_3 + x_4 = 7$, where $x_i \ge 0\,\,\,\forall i = 1,2,3,4$.

Solution using the formula mentioned in my text book:

$={n+r-1 \choose r},$ where $n=4,\,r=7;$

$={4+7-1 \choose 7} = {10 \choose 7} = \boldsymbol{120}$

Now everything was fine till here until, I checked for examples on Youtube and Google. The problem there, is that most of the problems are being solved using a different formula and weirdly it gives the same result. I'm completely confused and there's no mention of the below formula in my textbook

Solution using formula NOT mentioned in my text book:

$={n+r-1 \choose r-1}$ where $n=7,\,r=4;$

$={7+4-1 \choose 4-1} ={10 \choose 3}=\boldsymbol{120}$

My question to the Math community is:

What is this formula that is being used instead of my textbook version? Why are the values of n and r just being interchanged like that? Is there any correlation between the formula that I'm using and the one that's being used over the other mediums? Is the formula used over the other mediums correct?

  • 2
    Are you aware that ${ n\choose k}={n\choose n-k}$? – Hagen von Eitzen Sep 25 '22 at 13:55
  • Yes, the numbers of ways in which you select, is equal to saying the number of ways in which you reject. correct? But how does that relate to my problem? – Salvino D'sa Sep 25 '22 at 13:57
  • If you change the variables to $y_i=x_i+1$ the equation becomes $y_1+y_2+y_3+y_4=7+4$. Now imagine $7+4$ starts in a row, and you select, from the $7+4-1$ spaces in between them, $4-1$ of them to put bars that separate the starts into $4$ groups. The amounts in each group you interpret as the values of each $y_i$. This is the stars and bars argument. It is one way to interpret your counting of solutions as numbers of ways to make some selections. As you said, one formula selects bars, the other rejects bars. – plop Sep 25 '22 at 14:10
  • This is a dupe of this canonical question. I am out of votes for the day. – Parcly Taxel Sep 25 '22 at 14:17
  • 1
    No it's not. I'm trying to compare the two formulae here and how the second formula is derived. – Salvino D'sa Sep 25 '22 at 14:18
  • As you said, one formula selects bars, the other rejects bars. but why is it (r-1)? that's the question. How does this 1 come into the picture? I only know of (n-r) Can somebody post an elaborated answer. It will be useful to many other students using the same textbook as mine. – Salvino D'sa Sep 25 '22 at 14:20
  • 3
    To separate $r$ groups, you only need to place $r-1$ bars in between them. – plop Sep 25 '22 at 14:22
  • Well I was going to find a duplicate for $\binom nk=\binom n{n-k}$, but I couldn't find one. Huh. – Parcly Taxel Sep 25 '22 at 14:30
  • @user85667 you're awesome! I understand that method used over other mediums as depicted in my question is a direct implementation of the stars and bars approach i.e $={total,objects+total,bars \choose total,bars}$. Then the question what is the formula that's shown in my textbook. Also, could you post this explanation as an answer brother? – Salvino D'sa Sep 25 '22 at 14:33
  • I got it. https://math.stackexchange.com/q/3069349/357390 – Parcly Taxel Sep 25 '22 at 14:36
  • If somebody can just post an answer that's along the lines of @user85667 comment explaining how the two formulae are different from each other, and why the values of n & r need to be interchanged to apply them, it would be great! – Salvino D'sa Sep 25 '22 at 14:42

1 Answers1

4

The two forms of the stars and bars formula, $\binom{n+r-1}n$ and $\binom{n+r-1}{r-1}$, represent "stars-first" and "bars-first" approaches respectively. They are equivalent by binomial symmetry: $\binom{a+b}a=\binom{a+b}b$.

With $n$ as the bottom argument you are placing $n$ stars among $n+r-1$ stars and bars. But you can also place the $r-1$ bars first, and the remaining slots are then filled with stars. I personally prefer the $\binom{n+r-1}{r-1}$ form since $r$ is usually much smaller than $n$ in the problems I encounter.


(Added by OP)

The problem in the textbook has just switched the values for r & n and taken r at the bottom, which is just a slight deviation from the original formula, but yields the same result because the equation is balanced with the switch of n to r in the bottom i.e $\boldsymbol{\binom{n+r-1}{r}}$,

Parcly Taxel
  • 103,344
  • So the solution from my textbook is a "star-first" approach? because in that formula we have r at the bottom. – Salvino D'sa Sep 25 '22 at 15:04
  • To use your "stars-first" formula I would have to interchange the values of r and n I guess? If you could attach a solution to my problem using your formulae with the assumed values of n and r, it would complete your answer. Also, could you attach a reference where it's proved that both formula are equal? – Salvino D'sa Sep 25 '22 at 15:06
  • Please check this and this. – Salvino D'sa Sep 25 '22 at 15:28
  • ah you meant switching/interchanging the variables. You mentioned swapping variable names in your previous comment, which obviously means the values will change. I got you, maybe in my textbook the values for n and r are interchanged. But it gives the same result because r is taken at the bottom rather than n. – Salvino D'sa Sep 25 '22 at 15:55
  • Okay, but do you agree with my previous comment or not? i.e $\binom{10}{7} = \binom{10}{3}$ when values of r and n are interchanged? – Salvino D'sa Sep 25 '22 at 16:03
  • @SalvinoD'sa Yes. – Parcly Taxel Sep 25 '22 at 16:07