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-15

Exercise 1.2.9-15

proved in Lean solution written

RatingM28
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 a closed form for Gn(z)=∑k(n−kk)zkG_n(z)=\sum_k\binom{n-k}kz^k by studying ∑nGn(z)wn\sum_nG_n(z)w^n, and show that it equals ∑k(2k−n−1k)(−z)k\sum_k\binom{2k-n-1}k(-z)^k.

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

Find a recurrence Gn=Gn−1+zGn−2G_n=G_{n-1}+zG_{n-2} with Pascal's rule and sum over kk.

Hint 2

The recurrence gives H(w)=1/(1−w−zw2)H(w)=1/(1-w-zw^2). Factor the denominator.

Hint 3

For the second form, rewrite (2k−n−1k)(−1)k\binom{2k-n-1}k(-1)^k with the rule for negative upper index.

Solution

Show the solution

Pascal's rule gives (n−kk)=(n−1−kk)+(n−1−kk−1)\binom{n-k}k=\binom{n-1-k}k+\binom{n-1-k}{k-1}. Multiply by zkz^k and sum over kk. The first part gives Gn−1(z)G_{n-1}(z). In the second part put j=k−1j=k-1: z∑j((n−2)−jj)zj=zGn−2(z)z\sum_j\binom{(n-2)-j}jz^j=zG_{n-2}(z). So Gn=Gn−1+zGn−2G_n=G_{n-1}+zG_{n-2} for n≥2n\ge2, with G0=1G_0=1 and G1=1G_1=1.

Let H(w)=∑nGnwnH(w)=\sum_nG_nw^n. The recurrence gives H(w)(1−w−zw2)=G0+(G1−G0)w=1H(w)(1-w-zw^2)=G_0+(G_1-G_0)w=1, so H(w)=1/(1−w−zw2)H(w)=1/(1-w-zw^2). Factor 1−w−zw2=(1−ρw)(1−σw)1-w-zw^2=(1-\rho w)(1-\sigma w) with ρ+σ=1\rho+\sigma=1 and ρσ=−z\rho\sigma=-z, so ρ,σ=12(1±s)\rho,\sigma=\frac12(1\pm s) with s=1+4zs=\sqrt{1+4z}. By partial fractions,

H(w)=1ρ−σ(ρ1−ρw−σ1−σw),Gn=ρn+1−σn+1ρ−σ=(1+s)n+1−(1−s)n+12n+1s.H(w)=\frac1{\rho-\sigma}\Bigl(\frac\rho{1-\rho w}-\frac\sigma{1-\sigma w}\Bigr),\qquad G_n=\frac{\rho^{n+1}-\sigma^{n+1}}{\rho-\sigma}=\frac{(1+s)^{n+1}-(1-s)^{n+1}}{2^{n+1}s}.

The right side is a polynomial in zz, because the odd powers of ss cancel in the difference and s2=1+4zs^2=1+4z. If 1+4z=01+4z=0 then ρ=σ=12\rho=\sigma=\frac12 and H(w)=(1−w/2)−2H(w)=(1-w/2)^{-2}, so Gn=(n+1)/2nG_n=(n+1)/2^n.

Second form. For 0≤k≤n0\le k\le n let a=n+1−2ka=n+1-2k. If a>0a>0, the upper index 2k−n−1=−a2k-n-1=-a is a negative integer and (−ak)=(−1)k(a+k−1k)=(−1)k(n−kk)\binom{-a}k=(-1)^k\binom{a+k-1}k=(-1)^k\binom{n-k}k. So (2k−n−1k)(−z)k=(n−kk)zk\binom{2k-n-1}k(-z)^k=\binom{n-k}kz^k. If a≤0a\le0 then 0≤2k−n−1≤k−10\le2k-n-1\le k-1 for n≥1n\ge1, so the binomial coefficient is 00, and (n−kk)=0\binom{n-k}k=0 because n−k<kn-k<k. For n=0n=0 the only term is k=0k=0, equal to 11 in both forms. So the two sums agree term by term.

Check

For n=7n=7, z=3z=3: G7=∑k(7−kk)3k=1+6⋅3+10⋅9+4⋅27=217G_7=\sum_k\binom{7-k}k3^k=1+6\cdot3+10\cdot9+4\cdot27=217. With s=13s=\sqrt{13} the closed form gives ((1+s)8−(1−s)8)/(28s)=217((1+s)^8-(1-s)^8)/(2^8s)=217. For z=−14z=-\frac14 and n=3n=3: G3=(30)−14(21)=12=423G_3=\binom30-\frac14\binom21=\frac12=\frac4{2^3}.

Remarks

At z=1z=1 the sum is the Fibonacci number Fn+1F_{n+1} (Section 1.2.8), and the closed form is Binet's formula. In general Gn(z)G_n(z) is a Fibonacci polynomial.

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.