taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Exercise · Volume 1 · 1.2.9-16

Exercise 1.2.9-16

proved in Lean solution written

RatingM22
MarkersM (mathematical)
KindK3, find a value: compute a number, a set or a closed form from the written solution
SectionSection 1.2.9 of Volume 1. Companion chapter: Generating functions

The task

Find the generating function of the numbers ankra_{nkr} of ways to choose kk out of nn objects, each object at most rr times.

The exact wording is in your copy of the book.

Hints

Open one hint at a time. Try the exercise again after each.

Hint 1

Each object gets a number in 0,1,…,r0,1,\ldots,r of choices. Look at one object first.

Hint 2

The choices for different objects are independent, so multiply.

Solution

Show the solution

A choice is a list (c1,…,cn)(c_1,\ldots,c_n) with 0≤ci≤r0\le c_i\le r and c1+⋯+cn=kc_1+\cdots+c_n=k. Object ii contributes 1+z+⋯+zr1+z+\cdots+z^r, and zciz^{c_i} marks its number of copies. A product of nn such factors has the monomial zc1+⋯+cnz^{c_1+\cdots+c_n} once for each list, so

Gn(r)(z)=(1+z+⋯+zr)n=(1−zr+11−z)n.G_n^{(r)}(z)=(1+z+\cdots+z^r)^n=\Bigl(\frac{1-z^{r+1}}{1-z}\Bigr)^n.

Expand the numerator with the binomial theorem and the denominator with (20):

ankr=∑j≥0(−1)j(nj)(n+k−j(r+1)−1n−1),a_{nkr}=\sum_{j\ge0}(-1)^j\binom nj\binom{n+k-j(r+1)-1}{n-1},

where the sum runs over jj with j(r+1)≤kj(r+1)\le k. For r=1r=1 the series is (1+z)n(1+z)^n and ank1=(nk)a_{nk1}=\binom nk. For r≥kr\ge k the factor 1−zr+11-z^{r+1} does not matter for the coefficient of zkz^k, and ankr=(n+k−1k)a_{nkr}=\binom{n+k-1}k.

Check

For n=4n=4, r=2r=2 the coefficients of (1+z+z2)4(1+z+z^2)^4 are 1,4,10,16,19,16,10,4,11,4,10,16,19,16,10,4,1. The sum above for k=4k=4 is (73)−4(43)=35−16=19\binom73-4\binom43=35-16=19.

Remarks

For r=2r=2 the coefficients are the trinomial coefficients. They satisfy ankr=an,rn−k,ra_{nkr}=a_{n,rn-k,r} because the polynomial is palindromic.

This solution is drafted, and a person has not reviewed it yet. The source.

In Lean

proved The statement and its proof are in Lean. The kernel accepts the proof, and it uses the standard axioms only.

The status is computed from the Lean build. The node of the map.

Something is wrong? Report it.