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

Exercise 1.2.3-15

proved in Lean solution written

RatingM22
MarkersM (mathematical), recommended
KindK3, find a value: compute a number, a set or a closed form from the written solution
SectionSection 1.2.3 of Volume 1. Companion chapter: Sums and products

The task

Find a closed form for Sn=∑j=1nj 2jS_n = \sum_{j=1}^n j\,2^j. Compute small cases first, then derive the form by manipulations like those for Eq. (14).

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

Compute S1,…,S6S_1, \ldots, S_6 and compare with powers of 22. The differences from a multiple of 2n+12^{n+1} show a pattern.

Hint 2

Compare SnS_n with 2Sn2S_n. Shift the index of 2Sn2S_n by one so that the powers of 22 line up.

Hint 3

After the subtraction, most terms cancel and a geometric sum is left.

Solution

Show the solution

Small cases. S1=2S_1 = 2, S2=2+8=10S_2 = 2 + 8 = 10, S3=10+24=34S_3 = 10 + 24 = 34, S4=34+64=98S_4 = 34 + 64 = 98, S5=98+160=258S_5 = 98 + 160 = 258, S6=258+384=642S_6 = 258 + 384 = 642. Next to 2n+12^{n+1} the values 2,10,34,98,258,6422, 10, 34, 98, 258, 642 are 2=0⋅4+22 = 0 \cdot 4 + 2, 10=1⋅8+210 = 1 \cdot 8 + 2, 34=2⋅16+234 = 2 \cdot 16 + 2, 98=3⋅32+298 = 3 \cdot 32 + 2, 258=4⋅64+2258 = 4 \cdot 64 + 2, 642=5⋅128+2642 = 5 \cdot 128 + 2. The pattern is Sn=(n−1)2n+1+2S_n = (n-1)2^{n+1} + 2.

Derivation. Let n≥1n \ge 1. By rule (a) and rule (b) with j→j−1j \to j - 1, 2Sn=∑1≤j≤nj 2j+1=∑2≤j≤n+1(j−1) 2j.2S_n = \sum_{1 \le j \le n} j\,2^{j+1} = \sum_{2 \le j \le n+1} (j - 1)\,2^{j}. Subtract Sn=∑1≤j≤nj 2jS_n = \sum_{1 \le j \le n} j\,2^j. Both sums have the terms with 2≤j≤n2 \le j \le n. Split off the term j=n+1j = n+1 of the first and the term j=1j = 1 of the second (rule (d), valid for n≥1n \ge 1): Sn=2Sn−Sn=n 2n+1+∑2≤j≤n((j−1)−j)2j−1⋅2=n 2n+1−∑2≤j≤n2j−2.S_n = 2S_n - S_n = n\,2^{n+1} + \sum_{2 \le j \le n} \bigl((j-1) - j\bigr)2^j - 1 \cdot 2 = n\,2^{n+1} - \sum_{2 \le j \le n} 2^j - 2. The geometric sum is ∑2≤j≤n2j=2n+1−4\sum_{2 \le j \le n} 2^j = 2^{n+1} - 4 (this is Eq. (14) with the term j=0,1j = 0, 1 removed: ∑0≤j≤n2j=2n+1−1\sum_{0 \le j \le n} 2^j = 2^{n+1} - 1, minus 1+21 + 2). Hence Sn=n 2n+1−2n+1+4−2=(n−1) 2n+1+2.S_n = n\,2^{n+1} - 2^{n+1} + 4 - 2 = (n-1)\,2^{n+1} + 2.

Check

The formula gives S1=0+2=2S_1 = 0 + 2 = 2, S2=8+2=10S_2 = 8 + 2 = 10, S3=2⋅16+2=34S_3 = 2 \cdot 16 + 2 = 34, and S6=5⋅128+2=642S_6 = 5 \cdot 128 + 2 = 642, in agreement with the table. For n=0n = 0 it gives −2+2=0-2 + 2 = 0, the empty sum.

Remarks

Exercise 1.2.3-16 does the same for a general xx, and the present sum is the case x=2x = 2 of it.

This solution is checked, 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.