10

How many set of positive integers $\{a,b,c,d\}$ are there such that $ a\leq b\leq c\leq d\leq 50$ and $a+b+c+d=100$?

I was thinking about using stars and bars, and it seems to work if there were only three variables: If $a\leq b\leq c\leq 50$ and $a+b+c=100$, then we can define $x=50-a,y=50-b,z=50-c$ such that $x,y,z\leq 50$ and $x+y+z=3\times 50-(a+b+c)=50$. Then we can simply use stars and bars to find the number of triples of $\{x,y,z\}$, each of which corresponds to a unique $\{a,b,c\}$.

If $x\neq y,y\neq z$, and $z\neq x$, then only one out of the six sets consisting of $x,y,$ and $z$ is listed from the smallest to the largest. Since $50$ is not a multiple of $3$, $x=y=z$ is not possible. If two of the three elements are the same, then this element can be any integer between $1$ and $24$, inclusive. Since it can be either $x=y\neq z$, $x=z\neq y$, or $y=z\neq x$, each case appears three times. Thus, the total number of ordered triples $\{a,b,c\}$ is $\dfrac{C_{49}^2-24\times 3}{6}+24$.

However, when there's a fourth variable $d$, this method doesn't seem to work. Are there any other ways to circumvent it? Sorry for my poor English.

N. F. Taussig
  • 76,571
Skorpion
  • 448
  • 3
  • 12
  • 5
    Something missing in front of $\leq b\leq c\leq d\leq 50$, maybe $1\leq a\leq b\leq c\leq d\leq 50$? – Déjà vu Dec 27 '19 at 12:43
  • 1
    How do you keep the order in your three variable solution idea? The $x,y,z$ must be decreasing. So it's not a simple stars and bars for $x,y,z$. – Henno Brandsma Dec 27 '19 at 12:58
  • 2
    Equivalently: In how many ways can 100 be partitioned into 4 positive integers,none of which exceed 50? Such restricted partitions can be enumerated in Mathematica using the command IntegerPartitions[100, {4}, Range[50]]. This yields 3789 different partitions. (This is obviously not a solution, but it does allow us to check any answers we get.) – Semiclassical Dec 27 '19 at 13:43
  • @John - I wrote a simple 4-level nested loop to brute-force this. it ran in <1 second and the answer is 3789. are you perhaps forgetting the $a \le b \le c \le d$ constraint? – antkam Dec 27 '19 at 15:49
  • @antkam, thanks for cross checking ! Do I need to impose the constraint ? Here is what I am doing : dividing 100 into 4 parts and deleting any partition containing at least 1 number >50. What I am thinking is {a,b,c,d} = {d,c,b,a}(i.e in any oder) so I think constraint doesn't matter in my case, any help is appreciated ! – John Paul Dec 27 '19 at 16:08
  • @john - if your "partition" is a set, then order does not matter, but are you sure your "partition" is a set? i.e. are you sure in your loops you did not double-count ${20,22,28,30}$ and ${30,20,28,22}$ as two separate successes? – antkam Dec 27 '19 at 16:22
  • @antkam, yes I am pretty sure I didn't count it twice. I did the same process for relatively similar problem stating the sum as 13 and having the same constraint with max number as 6, the answer I got is 220 and is same as what has been mentioned in the book. – John Paul Dec 27 '19 at 16:25
  • @john - without seeing your code, i can't help you debug further. sorry. :) but just to convince yourself, maybe you can write the quad-loop and see if you get 3789? i.e. "FOR d in (1,50): FOR c in (1,d): FOR b in (1,c): FOR a in (1,b): if a+b+c+d == 100 then count += 1" – antkam Dec 27 '19 at 16:39
  • @RingØ - i had e.g. "FOR c in (1,d)", so the inequality is included already. – antkam Dec 29 '19 at 17:15
  • @antkam oh... didn't see that initially. bolding it makes it obvious :-) – Déjà vu Dec 29 '19 at 17:48

3 Answers3

6

In the following answer (which was slightly more cumbersome than I had expected) we use the coefficient of operator $[z^n]$ to denote the coefficient of $z^n$ in a series. This way we can formulate the problem as finding the coefficient of $z^{100}$ in the sum below and doing somewhat coefficient extraction. \begin{align*} [z^{100}]\sum_{1\leq a\leq b\leq c\leq d\leq 50}z^{a+b+c+d}\tag{1} \end{align*}

We obtain \begin{align*} \color{blue}{[z^{100}]}&\color{blue}{\sum_{1\leq a\leq b\leq c\leq d\leq 50}z^{a+b+c+d}}\\ &=[z^{100}]\sum_{a=1}^{50}\,\sum_{b=a}^{50}\,\sum_{c=b}^{50}\,\sum_{d=c}^{50}z^{a+b+c+d}\tag{2}\\ &=[z^{100}]\sum_{a=0}^{49}\,\sum_{b=0}^{49-a}\,\sum_{c=0}^{49-a-b}\,\sum_{d=0}^{49-a-b-c}z^{4a+3b+2c+d+4}\tag{3}\\ &=[z^{96}]\sum_{a=0}^{49}\,\sum_{b=0}^{49-a}\,\sum_{c=0}^{49-a-b}z^{4a+3b+2c}\,\frac{1-z^{50-a-b-c}}{1-z}\tag{4}\\ &=[z^{96}]\frac{1}{1-z}\sum_{a=0}^{49}\,\sum_{b=0}^{49-a}z^{4a+3b}\,\sum_{c=0}^{49-a-b}z^{2c}\\ &\qquad-[z^{46}]\frac{1}{1-z}\sum_{a=0}^{49}\,\sum_{b=0}^{49-a}z^{3a+2b}\,\sum_{c=0}^{49-a-b}z^{c}\tag{5}\\ &=[z^{96}]\frac{1}{1-z}\sum_{a=0}^{49}\,\sum_{b=0}^{49-a}z^{4a+3b}\,\frac{1-z^{100-2a-2b}}{1-z^2}\\ &\qquad-[z^{46}]\frac{1}{1-z}\sum_{a=0}^{49}\,\sum_{b=0}^{49-a}z^{3a+2b}\,\frac{1-z^{50-a-b}}{1-z}\tag{6}\\ &=[z^{96}]\frac{1}{(1-z)(1-z^2)}\sum_{a=0}^{49}z^{4a}\,\sum_{b=0}^{49-a}z^{3b}\\ &\qquad-[z^{46}]\frac{1}{(1-z)^2}\sum_{a=0}^{49}z^{3a}\,\sum_{b=0}^{49-a}z^{2b}\tag{7}\\ &=[z^{96}]\frac{1}{(1-z)(1-z^2)}\sum_{a=0}^{49}z^{4a}\,\frac{1-z^{150-3a}}{1-z^3}\\ &\qquad-[z^{46}]\frac{1}{(1-z)^2}\sum_{a=0}^{49}z^{3a}\,\frac{1-z^{100-2a}}{1-z^2}\tag{8}\\ &=[z^{96}]\frac{1}{(1-z)(1-z^2)(1-z^3)}\,\frac{1-z^{200}}{1-z^4}\\ &\qquad-[z^{46}]\frac{1}{(1-z)^2(1-z^2)}\,\frac{1-z^{150}}{1-z^3}\tag{9}\\ &\,\,\color{blue}{=[z^{96}]\frac{1}{(1-z)(1-z^2)(1-z^3)(1-z^4)}}\\ &\qquad\color{blue}{-[z^{46}]\frac{1}{(1-z)^2(1-z^2)(1-z^3)}}\tag{10}\\ \end{align*} \begin{align*} &=[z^{96}]\left(\frac{1-z^2}{9(1-z^3)}+\frac{1}{8(1+z^2)}+\frac{4z+5}{32(1+z)^2}\right.\\ &\qquad\qquad\qquad\left.-\frac{68z^3-263z^2+358z-175}{288(1-z)^4}\right)\\ &\qquad-[z^{46}]\left(\frac{1-z^2}{9(1-z^3)}+\frac{1}{16(1+z)}\right.\\ &\qquad\qquad\left.-\frac{25z^3-109z^2+179z-119}{144(1-z)^4}\right)\tag{11}\\ &=\frac{1}{9}[z^{96}](1-z^2)\sum_{j=0}^{\infty}z^{3j}+\frac{1}{8}[z^{96}]\sum_{j=0}^{\infty} (-1)^jz^{2j}\\ &\qquad+\frac{1}{32}[z^{96}](4z+5)\sum_{j=0}^{\infty} (j+1)(-1)^jz^j\\ &\qquad-\frac{1}{288}[z^{96}]\left(68z^3-263z^2+358z-175\right)\sum_{j=0}^{\infty}\binom{j+3}{3}z^j\\ &\qquad+\frac{1}{9}[z^{46}](1-z^2)\sum_{j=0}^{\infty}z^{3j}-\frac{1}{16}[z^{46}]\sum_{j=0}^{\infty}(-1)^jz^j\\ &\qquad+\frac{1}{144}[z^{46}]\left(25z^3-109z^2+179z-119\right)\sum_{j=0}^{\infty}\binom{j+3}{3}z^j\tag{12}\\ &=\frac{1}{9}+\frac{1}{8}+\frac{1}{32}\left(-4\cdot 96+5\cdot 97\right)\\ &\qquad-\frac{1}{288}\left(68\binom{96}{3}-263\binom{97}{3}+358\binom{98}{3}-175\binom{99}{3}\right)\\ &\qquad+0-\frac{1}{16}\\ &\qquad\qquad+\frac{1}{144}\left(25\binom{47}{4}-109\binom{48}{4} +179\binom{49}{4}-119\binom{50}{4}\right)\tag{13}\\ &=\left(\frac{1}{9}+\frac{1}{8}+\frac{101}{32}+\frac{2\,059\,087}{288}\right)-\left(\frac{1}{16}+\frac{484\,407}{144}\right)\\ &=7\,153-3\,364\\ &\,\,\color{blue}{=3\,789} \end{align*}

in accordance with the result stated by @antkam.

Comment:

  • In (2) we write the sums more conveniently as preparation for the following transformations.

  • In (3) we transform the indices so that they start from $0$. This is done by \begin{align*} a\to a+1,\quad b\to b-a-1,\quad c\to c-b-a-1,\quad d\to d-c-b-a-1 \end{align*}

  • In (4) we factor out $z^4$, apply the rule $[z^p]z^qA(z)=[z^{p-q}]A(z)$ and use the finite geometric summation formula for the inner most sum.

  • In (5) we split the sums and do some rearrangements as preparation for the next appliction of the finite geometric summation formula.

  • In (6) we apply the geometric summation formula as we did in (4).

  • In (7) we skip the terms containing the factor $z^{100}$ and $z^{50}$ as they do not contribute to the wanted coefficients.

  • In (8) to (10) we work similarly as we did before.

  • In (11) we do a partial fraction expansion (admittedly with some help of Wolfram Alpha) which helps to extract the coefficients easily.

  • In (12) we do geometric and binomial series expansions.

  • In (13) we select the coefficients accordingly.

Markus Scheuer
  • 108,315
  • +1 As always a super impressive & fully explained answer from you. :) BTW did you do all the algebra by hand??? Or did you have symbolic solver to help you instead (I hope)? – antkam Dec 28 '19 at 16:27
  • 1
    @antkam: Many thanks for your nice comment and the credit. Besides step (11) I did all the calculations manually. I consider them as funny finger exercises. :-) Additionally, I often do some scripting or use Wolfram Alpha for cross-checking. – Markus Scheuer Dec 28 '19 at 16:36
  • 1
    Out of curiosity, how long does it take to correctly mathjax all of that :-) – Déjà vu Dec 29 '19 at 17:05
  • @RingØ: Less than 30 minutes. Is this the effort you did expect? :-) – Markus Scheuer Dec 29 '19 at 19:31
  • @MarkusScheuer Markus , you are continuing to suprise me :)) I loved this method , can you say what is the name of it and where can i learn it ? – Not a Salmon Fish Aug 19 '21 at 06:31
  • @Bulbasaur: You might find this answer a useful starting point. Here is a somewhat more demanding application. Regards, – Markus Scheuer Aug 19 '21 at 19:34
3

As far as I can tell, there are several theoretical ways to solve this, but all of them involve some sort of enumerating / recurrence / looping, and there is no closed form solution. Since your problem is so small ($4$ numbers, max size $50$, total $100$), a simple quadruply-nested loop might take the least amount of total coding + running time. In fact I just did it: it took $< 1$ minute to code and $< 1$ second to run, and the answer is $3789$, as @Semiclassical already pointed out using Mathematica.

Anyway, the exact form of your problem is a number partition with both restricted part size (max part size $=50$) and restricted number of parts (exactly $4$ parts). This is described in this section of wikipedia. The solution is given in terms of a recurrence with $3$ parameters - the total, the max part size, and the number of parts - so if you want to use that solution you'd still have to write the equivalent of a triple-loop. Since you have only $4$ parts (variables), a brute-force quad-loop is easier.

Note that the wikipedia section quoted above answers the question for "at most $M$ parts" whereas you have "exactly $M$ parts". However, you can transform between them by the change of variables $a' = a - 1, b' = b-1$ etc and allowing the $a', b', c', d'$ to be zero (hence at most $4$ parts, since zeros don't count as parts) and changing the sum to $96$ and the max part size to $49$.

antkam
  • 15,363
  • 1
    Congratz you made it past 10k with... $\longrightarrow, (+1) $ :D – Mr Pie Dec 28 '19 at 15:15
  • @MrPie - haha, thanks! I was staying up late last night, hoping to see the transition, but I couldn't hold on and had to sleep before it happened. Maybe I will try to stay up again when I cross 16384 - IMHO a more special number than 10000! ;) – antkam Dec 28 '19 at 15:46
  • What is IMHO .. ? – nonuser Dec 28 '19 at 16:36
  • @Aqua - IMHO = In my humble opinion, or, in my honest opinion. next time you have this kind of question, lemme introduce you to a great resource: urban dictionary! – antkam Dec 28 '19 at 17:43
  • Indeed, $16384$ is a special number. $16834=\color{red}{1}\times \color{blue}{2}^{\color{green}{1}\color{orange}{4}}$ and $$1+6+8+3+4= \color{red}{1}^2+\color{blue}{2}^2+\color{green}{1}^2+\color{orange}{4}^2$$ :) – Mr Pie Dec 29 '19 at 11:51
  • @MrPie - lovely! even though the nitpicker in me wants to point out that (a) including "$1 \times$" to give you a free "$1^2$" is a little bit of cheating, and (b) the equation is decimal-centric i.e. anthropocentric! ;) – antkam Dec 29 '19 at 16:10
0

My approach would be to list the values of a, b, c, and d, setting a, b, and c at their minimum value $1$, and d at its maximum value $50$. I would decrement d by 1, and find that only c could be incremented by 1 to compensate. Then would decrement d by 2 and find that either c or d could be incremented by 1 to compensate. I would run through all such increment/decrement sets, keeping $a = 1$. Then I would repeat, beginning with the first possible increment of $a$.

It's a tedious method, but after the first few cycles it establishes a pattern that could be represented as a series sum.

S. McGrew
  • 269
  • 1
  • 8