0

How would I go about solving this question. How many solutions are there to:

$$x_1 + x_2 + x_3+...+ x_7 =18$$

in the case where $x_i \in \left\{2,3 \right\}, i =1,2,3,4,5,6,7$.

I understand this is a bars and stars problem. However I have only done ones where the total is equal to highest number of the set and that just uses combination by repetition. Any guidance on where to go would be greatly appreciated.

  • 2
    You could if you insist do this by stars-and-bars by modifying it with change of variables and inclusion-exclusion. This however seems incredibly overkill and tedious. Notice... since every $x_i$ must be either $2$ or $3$... you know exactly how many $2$'s are needed and exactly how many $3$'s are needed. Pick which are the twos... the rest must be threes. – JMoravitz Mar 17 '18 at 19:01
  • @JMoravitz so in that case there must be 3 2's and 4'3. Where would I go from here? – Safder Aree Mar 17 '18 at 19:05
  • 1
    Pick which specific indexes correspond to the $x_i$ values which are twos. Count how many different ways you could make such a selection. (Think about it as picking a subset of ${1,2,3,4,5,6,7}$ to correspond to the $x_i$ values being $2$'s) – JMoravitz Mar 17 '18 at 19:06
  • Would $({7}\choose{1}) + {6}\choose{1} + {5}\choose{1}$ be the right way of approaching it? Because I could choose 1 of the 7 unknowns place a variable then choose continue to do so till I exhaust the 3 2's? – Safder Aree Mar 17 '18 at 19:14
  • No, for several reasons. Firstly, we multiply when conducting multiple steps in sequence, not add. Secondly, if we choose $x_3$ to have the value $2$ and then we choose $x_2$ to have the value of $2$ followed by $x_1$ to have the value of $2$, this is the same result as if we had chosen them in another order such as $x_1,x_2,x_3$ instead so you have overcounted considerably. – JMoravitz Mar 17 '18 at 19:16
  • @JMoravitz Okay I understand that. – Safder Aree Mar 17 '18 at 19:23

2 Answers2

4

Hint:

Since every $x_i$ must be either a $2$ or a $3$, we can figure out exactly how many $2$'s are needed and exactly how many $3$'s are needed. The only missing information then is which of the $x_i$ are specifically the twos and which are the threes.


You could do this by stars-and-bars modified with a change of variables and inclusion-exclusion, however this seems incredibly overkill and tedious. You could also choose to do this by generating functions (which will highlight the same property you are being led to above if you remember your binomial theorem).

More detail on generating function approach:

As the first value is either $2$ or $3$, we begin building the generating function with the piece $(x^2+x^3)$. Similarly as the second follows the same, we multiply this again by $(x^2+x^3)$. Continuing in this fashion, we get the generating function $(x^2+x^3)^7$. If we factor out a common factor of $x^2$, this leaves us with $x^{14}(1+x)^7$. The question is then "What is the coefficient of $x^{18}$ in the expansion of $x^{14}(1+x)^7$?" which can be recognized via the binomial theorem.

JMoravitz
  • 79,518
  • Using the generating function method. I got 35 as the coefficient of $x^{18}$. I am just covering generating functions method but this makes sense to me. – Safder Aree Mar 17 '18 at 19:21
  • @SafderAree $35=\binom{7}{3}$ is indeed the correct answer. I strongly encourage you to try to understand the first method as well as I consider that to be the more useful method in development of thinking. – JMoravitz Mar 17 '18 at 19:23
  • I will go back understand the other method. Thank you for helping me out. – Safder Aree Mar 17 '18 at 19:28
1

Note that it suffices to count only the number of solutions where $x_1 \leq x_2 \leq \ldots \leq x_7$.

Then the solutions to $x_1 +x_2 + \ldots + x_7=18$ will just be the permutations corresponding to each solution found in the previous line.

Since $2 \cdot 4+ 3 \times 3=17 < 18$ , we must have at least $4$ threes.

Also, $2 \cdot 2+ 3 \times 5=19 > 18$ , so we must have at most $4$ threes.

It follows that we exactly $4$ threes and thus exactly $3$ twos (i.e. $x_1=x_2=x_3=2$ and $x_4=x_5=x_6=x_7=3$).

Now, to generate a permutation, we may choose any of the $4$ variables to take the value three and the other variables are automatically fixed to take the value two.

Note that this can be done in $\binom{7}{4}$ ways.

Roby5
  • 4,287