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

Exercise 1.2.3-13

proved in Lean solution written

Rating10
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

Evaluate ∑j=mnj\sum_{j=m}^n j for integers m≤nm \le n, using Eq. (15).

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

Shift the index so that the sum starts at 00: put j=m+kj = m + k.

Hint 2

Then the sum is an arithmetic progression with first term a=ma = m and step b=1b = 1.

Solution

Show the solution

By rule (b) with j=m+kj = m + k, the relation m≤j≤nm \le j \le n becomes 0≤k≤n−m0 \le k \le n - m, so ∑m≤j≤nj=∑0≤k≤n−m(m+k).\sum_{m \le j \le n} j = \sum_{0 \le k \le n-m} (m + k). Eq. (15) with a=ma = m, b=1b = 1 and n−m≥0n - m \ge 0 in place of nn gives m(n−m+1)+12(n−m)(n−m+1)=12(n−m+1)(2m+n−m)=12(n−m+1)(n+m).m(n - m + 1) + \tfrac12 (n - m)(n - m + 1) = \tfrac12 (n - m + 1)(2m + n - m) = \tfrac12 (n - m + 1)(n + m). Expand: (n−m+1)(n+m)=n2−m2+n+m=n(n+1)−m(m−1)(n - m + 1)(n + m) = n^2 - m^2 + n + m = n(n+1) - m(m-1). So ∑j=mnj=12(n(n+1)−m(m−1)).\sum_{j=m}^n j = \tfrac12\bigl(n(n+1) - m(m-1)\bigr).

The value is the number of terms times the mean of the first and last term.

Check

For m=3m = 3, n=7n = 7: the sum is 3+4+5+6+7=253 + 4 + 5 + 6 + 7 = 25, and the formula gives 12(56−6)=25\frac12(56 - 6) = 25. For m=−3m = -3, n=4n = 4 the sum is 44 (the terms from −3-3 to 33 cancel), and the formula gives 12(20−12)=4\frac12(20 - 12) = 4. For m=nm = n the formula gives 12(n2+n−n2+n)=n\frac12(n^2 + n - n^2 + n) = n.

Remarks

The result is used in Exercise 1.2.3-14. The case m=1m = 1 gives 12n(n+1)\frac12 n(n+1), the familiar triangular number.

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.