[Math] Finding number of restricted integer solutions to equation using multinomial theorem

combinatorics

How can I solve the diophantine equation

$$x_1 +x_2 + x_3 + x_4 + x_5 + x_6 + x_7 = 30,$$

where $x_1, x_2, x_3, x_4, x_5, x_6, x_7$ can take the values $0,2,3,4,5$?

I am having problems in solving this one.
The expansion is getting very big.

I need the number of solutions of this equation.

Thanks

Best Answer

By setting $x_i=5-y_i$, we can instead solve $$(5-y_1)+(5-y_2)+\cdots+(5-y_7)=30$$ for $y_1,\ldots,y_7 \in \{0,1,2,3,5\}$. This is equivalent to $$y_1+y_2+\cdots+y_7=5.$$

From here, the possible multisets of $y$-values are:

  • $\{5,0,0,0,0,0,0\}$, enumerated by $\binom{7}{1,6}=7$,
  • $\{3,2,0,0,0,0,0\}$, enumerated by $\binom{7}{1,1,5}=42$,
  • $\{3,1,1,0,0,0,0\}$, enumerated by $\binom{7}{1,2,4}=105$,
  • $\{2,2,1,0,0,0,0\}$, enumerated by $\binom{7}{2,1,4}=105$,
  • $\{2,1,1,1,0,0,0\}$, enumerated by $\binom{7}{1,3,3}=140$,
  • $\{1,1,1,1,1,0,0\}$, enumerated by $\binom{7}{5,2}=21$.

This gives $420$ possibilities.