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.6-60

Exercise 1.2.6-60

proved in Lean solution written

RatingM23
MarkersM (mathematical)
KindK3, find a value: compute a number, a set or a closed form from the written solution
SectionSection 1.2.6 of Volume 1. Companion chapter: Binomial coefficients

The task

Count the kk-element combinations of nn kinds of objects when repetition is allowed.

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

List the chosen objects in order, c1≤c2≤⋯≤ckc_1 \le c_2 \le \cdots \le c_k.

Hint 2

Shift cic_i by i−1i - 1 to make the sequence strictly increasing.

Solution

Show the solution

A combination with repetition is a sequence 1≤c1≤c2≤⋯≤ck≤n1 \le c_1 \le c_2 \le \cdots \le c_k \le n (this needs n≥1n \ge 1 when k≥1k \ge 1). Put di=ci+i−1d_i = c_i + i - 1. Then d1<d2<⋯<dkd_1 < d_2 < \cdots < d_k, since di+1−di=ci+1−ci+1≥1d_{i+1} - d_i = c_{i+1} - c_i + 1 \ge 1. Also 1≤d11 \le d_1 and dk=ck+k−1≤n+k−1d_k = c_k + k - 1 \le n + k - 1. Conversely, every strictly increasing sequence in {1,…,n+k−1}\{1, \ldots, n+k-1\} gives ci=di−i+1c_i = d_i - i + 1, a weakly increasing sequence in {1,…,n}\{1, \ldots, n\}. This is a bijection onto the kk-element subsets of an (n+k−1)(n+k-1)-set, so the count is (n+k−1k)\binom{n+k-1}{k}.

For n=0n = 0: there is one combination of size 00 (the empty one) and none of size k≥1k \ge 1. The formula gives (k−1k)\binom{k-1}{k}, which is (−10)=1\binom{-1}{0} = 1 for k=0k = 0 and 00 for k≥1k \ge 1.

Check

For n=3n = 3, k=2k = 2 the multisets are 11,12,13,22,23,3311, 12, 13, 22, 23, 33, that is 6=(42)6 = \binom{4}{2}. For n=2n = 2, k=3k = 3: 111,112,122,222111, 112, 122, 222, that is 4=(43)4 = \binom{4}{3}.

Remarks

The same count is the number of solutions of y1+⋯+yn=ky_1 + \cdots + y_n = k in natural numbers. It is the coefficient of xkx^k in (1−x)−n(1-x)^{-n}, by eq. 1.2.6(16) and eq. 1.2.6(17).

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.