0

So let's say we have x+y+z=9 and I know this has been asked a lot and I know how to solve it but I can't find the rule to , let's say that x,y,z can't be more than 4 . How can I find the number possible values that satisfy the equation? I thought it should be (9-(4×3)+2)! / (9-(4×3)! × 2! , but it isn't giving me right answers so i'm obviously missing something here , please enlighten me.I know it's probably duplicate but I can't find the answer or can't understand it, so please help then I will delete it asap , thank you very much.

N. F. Taussig
  • 76,571
you7
  • 3
  • 1
    Here's a general method, though you'll see it isn't simple. Of course, with extremely small numbers, as in your case, it's easy to solve the problem directly. – lulu Dec 12 '22 at 11:52
  • Indeed, there must be three threes, or a four, a three, and a two, or two fours and a one. But the general question has surely been asked and answered on this site many many times. – Gerry Myerson Dec 12 '22 at 12:06
  • @lulu yes you're right, it's much easier if I have smaller numbers but I could be asked to solve for upper limit is 1000 and x+y+z=10k and that's hard . Not to mention I need that rule to apply it in a code but the linked solutions are difficult for me to understand, I tried reading them multiple times but I just can't get it. So I was hoping to know if there are any videos on YouTube that show how to solve these type of equations? And thank you for your help – you7 Dec 12 '22 at 12:50
  • I suggest trying to implement the solution as presented. Then run it on small numbers, where you can confidently check by hand. – lulu Dec 12 '22 at 13:01
  • Should say: three variables is still very small, even if the cap is high. For that, I'd be tempted to just set the first variable to each allowed value in turn...it then being easy to set the other two. – lulu Dec 12 '22 at 13:03
  • I'm tempted but I truly don't understand the solutions @lulu – you7 Dec 12 '22 at 22:14
  • I have posted an answer. Please DON'T delete your question, now that I've put the work into posting that answer. – Gerry Myerson Dec 13 '22 at 02:25
  • Any thoughts about my answer? – Gerry Myerson Dec 14 '22 at 13:12
  • 1
    @GerryMyerson thank you so much your answer is alot easier to read and understand , sorry I didn't read it earlier because of my exams but I truly thank you and yes I won't delete it . – you7 Dec 15 '22 at 07:40

1 Answers1

2

Let's do an example. Let's find the number of solutions of $$ a+b+c+d+e=100 $$ where the variables are non-negative integers restricted by $$ a\le10,\quad b\le20,\quad c\le30,\quad d\le40,\quad e\le50 $$ The answer is the coefficient of $x^{100}$ when you multiply out $$ (1+x+\cdots+x^{10})(1+x+\cdots+x^{20})(1+x+\cdots+x^{30})(1+x+\cdots+x^{40})(1+x+\cdots+x^{50}) $$ It's nice if you understand why that's true, but strictly speaking you don't have to understand it to use it.

Now the formula for the sum of a geometric sequence tells you that $$ 1+x+\cdots+x^r={1-x^{r+1}\over1-x} $$ so we're looking for the coefficient of $x^{100}$ in $$ {1-x^{11}\over1-x}{1-x^{21}\over1-x}{1-x^{31}\over1-x}{1-x^{41}\over1-x}{1-x^{51}\over1-x} $$ which is the coefficient of $x^{100}$ in $$ (1-x^{11})(1-x^{21})(1-x^{31})(1-x^{41})(1-x^{51})(1-x)^{-5} $$ Multiplying stuff out, we find $$ (1-x^{11})(1-x^{21})(1-x^{31})(1-x^{41})(1-x^{51})=1-x^{11}-x^{21}-x^{31}+x^{32}-x^{41}+x^{42}-x^{51}+2x^{52}+2x^{62}-x^{63}+2x^{72}-x^{73}+x^{82}-2x^{83}+x^{92}-2x^{93}+\cdots $$ where the $\cdots$ indicates terms we can ignore because they have exponents greater than $100$ so they can't contribute to the coefficient of $x^{100}$.

OK, but what about the $(1-x)^{-5}$? Well, we use the generalized form of the Binomial Theorem (you may need to look that up) to get $$ (1-x)^{-5}=\sum_{n=0}^{\infty}{n+4\choose n}x^n=1+{5\choose1}x+{6\choose2}x^2+{7\choose3}x^3+\dots $$ So now we have to multiply that polynomial that starts with $1-x^{11}-x^{21}-x^{31}$ times that series for $(1-x)^{-5}$ – BUT we only have to look for terms in the product that involve $x^{100}$. So, the $1$ in the polynomial gets matched with ${104\choose100}x^{100}$ in the series; the $-x^{11}$ in the polynomial gets matched with the ${93\choose89}x^{89}$, and so on. When all is said and done, our answer is, $$ {104\choose100}-{93\choose89}-{83\choose79}-{73\choose69}+{72\choose68}-{63\choose59}+{62\choose58}-{53\choose49}+2{52\choose48}+2{42\choose38}-{41\choose37}+2{32\choose28}-{31\choose27}+{22\choose18}-2{21\choose17}+{12\choose8}-2{11\choose7} $$ It looks a little nicer if you use ${n+4\choose n}={n+4\choose4}$; it starts ${104\choose4}-{93\choose4}-{83\choose4}\cdots$.

Gerry Myerson
  • 179,216