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.1-7

Exercise 1.2.1-7

proved in Lean solution written

Rating23
KindK3, find a value: compute a number, a set or a closed form from the written solution
SectionSection 1.2.1 of Volume 1. Companion chapter: Mathematical induction

The task

Find a closed form for the alternating sums 121^2, 22−122^2 - 1^2, 32−22+123^2 - 2^2 + 1^2, …\ldots and prove it by induction.

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 the first five sums and look at them.

Hint 2

Let SnS_n be the nnth sum. Write SnS_n in terms of Sn−1S_{n-1}.

Solution

Show the solution

The first sums are 1,3,6,10,151, 3, 6, 10, 15. These are the triangular numbers, so the rule is Sn=n2−(n−1)2+(n−2)2−⋯+(−1)n−112=n(n+1)2.S_n = n^2 - (n-1)^2 + (n-2)^2 - \cdots + (-1)^{n-1} 1^2 = \frac{n(n+1)}{2}. The rule is a guess from five cases, so it needs a proof.

Recurrence. Taking out the first term, Sn=n2−Sn−1S_n = n^2 - S_{n-1} for n≥2n \ge 2, since the remaining terms are the sum Sn−1S_{n-1} with all signs changed.

Induction. For n=1n = 1, S1=1=1⋅2/2S_1 = 1 = 1 \cdot 2/2. Assume Sn=n(n+1)/2S_n = n(n+1)/2. Then Sn+1=(n+1)2−Sn=(n+1)2−n(n+1)2=(n+1)(2n+2−n)2=(n+1)(n+2)2.S_{n+1} = (n+1)^2 - S_n = (n+1)^2 - \frac{n(n+1)}{2} = \frac{(n+1)(2n + 2 - n)}{2} = \frac{(n+1)(n+2)}{2}. This is the rule for n+1n + 1. □\square

Check

42−32+22−12=16−9+4−1=10=4⋅5/24^2 - 3^2 + 2^2 - 1^2 = 16 - 9 + 4 - 1 = 10 = 4 \cdot 5/2, and 52−42+32−22+12=15=5⋅6/25^2 - 4^2 + 3^2 - 2^2 + 1^2 = 15 = 5 \cdot 6/2. A python3 run gave Sn=n(n+1)/2S_n = n(n+1)/2 for n=1,…,7n = 1, \ldots, 7 and more.

Remarks

The recurrence says Sn+Sn−1=n2S_n + S_{n-1} = n^2, with S0=0S_0 = 0. The triangular numbers Tn=n(n+1)/2T_n = n(n+1)/2 satisfy Tn+Tn−1=n2T_n + T_{n-1} = n^2 as well, and S0=T0=0S_0 = T_0 = 0, so the two sequences are equal. This is the same proof in other words.

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.