Volume C1 · Basic concepts · TAOCP Section 1.2.3
Sums and products
Draft. This chapter is written and checked by the tools of the project, and a person has not reviewed it yet. Read it with care.
Read it next to Section 1.2.3 of the book. The nodes and the exercises of the section.
Contents
Sums and products
Overview
Section 1.2.3 of TAOCP sets up the notation for sums and products. A sum runs over all integers that satisfy a relation , so the limits of a sum can be any condition, not only a pair of end points. The section gives four rules for working with such sums: the distributive law, the change of the index variable, the interchange of two sums, and the splitting or merging of the domain. It uses the rules to derive the sum of a geometric progression and of an arithmetic progression, and the identity of eq. 1.2.3(13) for a double sum with . It then introduces the bracket , which is for a true statement and for a false one, and shows that the bracket makes the four rules mechanical. It ends with the Kronecker delta, the product notation, and sums in several indices at once. The section uses induction (Section 1.2.1) only for the remarks on the exercises, and it uses real numbers (Section 1.2.2) for the infinite sums.
The ideas
A sum is a function of a set. The symbol means: find the set of integers for which the relation holds, and add the numbers for these . The order does not matter. The sum of an empty set is . When the set is infinite, the definition uses limits, and then some rules need care.
Four rules do most of the work. To distribute, multiply each term of one sum with each term of the other. To change the index, rename it or replace by . To interchange, add the same array of terms by columns instead of by rows. To change the domain, split a range into parts or merge two ranges, and correct for the terms that lie in both. Each rule is a fact about adding a finite list of numbers in a different order or in groups.
The manipulation is a method of discovery. The book proves the sum of a geometric progression by writing the sum twice in two forms, not by induction, and the same idea gives the sum of an arithmetic progression. The point is that a person who does not know the formula can find it. C1 shows these derivations, and it also shows the check by induction, so that the reader sees both ways.
The bracket turns a range into a factor. If is when is true and when it is false, then , where now runs over all integers. A change in the range of summation becomes a change in a product of brackets, and a statement about brackets is an ordinary statement about numbers that a person can check. This is why the change of variable, the interchange of two sums and the splitting of a domain all follow from rules for sums over all integers.
Infinite sums need a condition. For a finite set the four rules always hold. For an infinite set, the sum of a divergent series is not defined, and an absolutely convergent series (one for which the sum of the absolute values is finite) can be handled by all the rules. The book states this in notes and leaves the proofs to the exercises. C1 proves the cases that are used later: the distributive law and the shift for any convergent sums, and the general change of index and the interchange for absolutely convergent sums. C1 gives a counterexample for the interchange without this condition.
C1 takes one step that the book does not take: it states one fact on finite sums first (the sum over a finite set does not depend on the order or on the grouping) and uses it in each proof. The book's proofs are by the examples and are short.
Definitions, results and proofs
Definition C1.1.2.3.1 (the sum with an index from 1 to , TAOCP eq. 1.2.3(1)). For numbers and an integer , the sum is written . For the sum is empty, and its value is .
Node: TAP5K3XRDB · status: not stated yet
Explanation. The notation with dots has a clear meaning only when or so. The sign with limits gives the meaning for each , including and . The rule for is the one that keeps the later formulas true: for example splits into two sums for each only if the empty sum is the neutral element of the addition. In Lean, this sum is Finset.sum (Finset.Icc 1 n) a, and the empty sum is 0.
Example. . . for each sequence . The sum is , the number of terms.
Definition C1.1.2.3.2 (the sum over a relation, TAOCP eq. 1.2.3(2)). Let be a relation on the integer , and suppose that only finitely many integers satisfy it. Then is the sum of the numbers over all integers with true. If no integer satisfies , the sum is . When two or more conditions stand under the sign, all of them must hold.
Node: TA229MTBV7 · status: not stated yet
Explanation. The relation can be any statement about : , " is even", , or a mix. The sum is the same as when is an integer, and it is still meaningful when is not an integer: for it is . The notation counts each integer once. This means that the sum depends on the set and on the function , not on the way that the set is written. In Lean, this is a sum over a Finset, or finsum when the set is not known to be finite.
Example. . The relation holds for , so . The relation and is satisfied by only.
A fact on finite sums, used in each proof below. Let be a finite set of integers (or of pairs of integers), and let be a function with numbers as values. The sum does not depend on the order of the terms, and it can be formed in groups: if is split into disjoint parts , then . The proof is by induction on the number of elements of . For both sides are . For , remove one element of the last part (or any element). The sum over is the sum over plus , by commutativity of the addition, and the induction hypothesis applies to the smaller set with the same grouping, one part now smaller. The result is the same sum written in a different order, which is equal by the commutative and associative laws of the addition.
Definition C1.1.2.3.3 (an infinite sum, TAOCP eq. 1.2.3(3)). Let be a relation that is true for infinitely many integers. Form the two limits below, one for the indices and one for the indices . When both limits exist, the sum is convergent, and its value is the sum of the two limits. When one of them does not exist, the sum is divergent and has no value.
Node: TA6XKFMSAA · status: not stated yet
Explanation. The definition cuts the integers into the nonnegative part and the negative part and sums each part by its own limit. This avoids the trap that a single limit of symmetric windows would hide: a series like has symmetric partial sums , but it is not convergent in this sense. The definition also fixes the order of the terms in each part, namely the order of the index. The word convergent has the usual meaning for a sum of a sequence indexed by . In Lean, a convergent sum is HasSum, and tsum is its value; the definition of HasSum uses limits over all finite sets, not over the order of , so it is equal to the sum of the book only for absolutely convergent series (see eq. 1.2.3(5)).
Example. is convergent: the partial sums are , and the limit is . The sum over all integers has the nonnegative part and the negative part , so its value is . The sum is divergent: the partial sums grow without bound, because the block of terms from to has terms that are each at least , so it adds at least , and . The value is still small, and the growth is slow. The sum is convergent, with the value .
Theorem C1.1.2.3.4 (the distributive law, TAOCP eq. 1.2.3(4)). For finite sets and of integers,
Node: TAT0EPRN7R · Lean: TAOCP.S1_2_3.eq4 · status: proved
Scope. The same holds for infinite sums when both sums on the left are convergent (exercise 1.2.3-5). Absolute convergence is not needed.
Explanation. The product of two sums is the sum of all products of a term of the first with a term of the second. The right side groups these products by the value of : for each it takes the sum over . It is the rule that a person already uses to expand . In C1, as in the book, a double sum has no parentheses: the inner sum is always the one on the right.
Example. Let with , and with , , . The left side is . The right side groups by : for the inner sum is , for it is , and the total is .
Proof. Finite case. Fix and the numbers , and put . The claim is and . The second part is the repeated distributive law for numbers, which follows from the two-term law by induction on . The first part has the same form: induction on . For both sides are . If , then .
Infinite case. Let and be convergent in the sense of eq. 1.2.3(3). Fix . Each partial sum of the inner sum is times the partial sum of with the same range, by the finite case. A constant factor goes through a limit, so both limits of eq. 1.2.3(3) exist for the inner sum, and its value is . The outer sum is then . By the same argument with the constant , it is convergent and its value is .
Theorem C1.1.2.3.5 (the change of the index, TAOCP eq. 1.2.3(5)). Let be a relation and let be a function from the integers to the integers. Suppose that maps the set one to one onto the set . Then
Node: TARPT5ZEHK · Lean: TAOCP.S1_2_3.eq5, TAOCP.S1_2_3.eq5_book · status: proved
Scope. The first equality only renames the index. The second one is a change of the index by the function . For a finite set it always holds. For an infinite sum it holds for and with any integer , and for each when is finite.
Explanation. The condition on says that matches the set of the values with one to one with the set of the values with . So the right sum has the same terms as the left sum, in another order. The two important cases are the shift and the reflection . They are used in almost each manipulation of a sum, and the book asks the reader to study the shift example of eq. 1.2.3(6) with care. In a convergent series that is not absolutely convergent, a general can change the value: a reordering of the terms of that takes two positive terms for one negative term has the sum in the place of (this is a standard fact of analysis; Riemann proved that the rearrangements of a conditionally convergent series reach every real value). The exercise 1.2.3-8 asks for an example for a related fault of the interchange.
Example. Let , be , and . The left side is . The relation is , that is , and the right side is . For a map that is not a permutation, with the relation takes the values and the sum counts twice. Eq. 1.2.3(18) below gives the exact value in such a case.
Proof. Finite case. By the hypothesis, restricted to is a bijection onto . The sum over of has one term for each , by the match , so it is the sum over of in a different order, which is equal by the fact on finite sums.
The shift and the reflection for a convergent infinite sum. First, a remark on windows. Let and , and let be the value of eq. 1.2.3(3). The sum of the terms with is , so it tends to when and tend to infinity independently. Now let . The terms with of the new sum are the terms of the old sum with . This is a window of the same kind, with the end points and , which both tend to infinity. So the window sums of the new sum tend to in the same independent sense, and in particular both limits of eq. 1.2.3(3) exist for the new sum, and their sum is . The case of is the same: the window of the new sum matches the window of the old sum.
The absolutely convergent case. Let be convergent and let be the value of . For each there is an such that the sum of over the with is less than . Let be finite sets with union . Take such that contains all with for . Then for such both and are at most , so . This shows that the sum is the limit along any sequence of finite sets that grows to . Apply this to , the set of the with : the sums of the absolute values over finite parts of are bounded by the sum of over , so the new sum is absolutely convergent too. Take . These are finite sets that grow to (each is finite, since is a bijection of onto and only finitely many have ). By the finite case, . So the new sum has the value .
Example C1.1.2.3.6 (a shift of the index, TAOCP eq. 1.2.3(6)). For integers :
Node: TABDYK947N · Lean: TAOCP.S1_2_3.eq6 · status: proved
Explanation. This is eq. 1.2.3(5) with . The relation is the same as , by adding to each part. The index moves up by one, and the term moves down by one. Both of these shifts are needed to get a sum into a form where it can be combined with another sum: the derivation of eq. 1.2.3(14) below uses exactly this shift.
Example. Let and . The left side is . The right side is . The same four numbers appear, with the label moved by one.
Theorem C1.1.2.3.7 (the interchange of two sums, TAOCP eq. 1.2.3(7)). For finite sets and ,
Node: TA09P1QYVS · Lean: TAOCP.S1_2_3.eq7 · status: proved
Scope. For infinite sets, the interchange is valid when exists, and also when one of and is finite and each infinite sum that occurs is convergent.
Explanation. The array with and can be summed by rows or by columns. The two results are equal. The interchange is useful because often one of the two inner sums has a closed form and the other does not. For infinite sets, the order matters, as the counterexample below shows.
Example. Take the array with and . By rows: row is and row is , so the total is . By columns: column is , column is , column is , and the total is .
Proof. Finite case: by induction on . For both sides are . If , then , by eq. 1.2.3(8) (proved in the next block, from the commutativity of the addition alone). By the induction hypothesis, the first part is , and the whole is . For the absolutely convergent case, first let all . A sum of nonnegative terms in the sense of eq. 1.2.3(3) is the least upper bound of its finite partial sums. Let run over the finite sets of pairs with and . Each is at most the sum by rows, since the terms are not negative. A finite part of the outer sum by rows is a finite sum of inner sums, and each inner sum is the least upper bound of its own finite parts, so that finite part is the least upper bound of some of the . Hence the sum by rows is the least upper bound of all . The same holds for the sum by columns, so the two iterated sums are equal. For real , write with and . Both are nonnegative and at most , so their iterated sums are finite and do not depend on the order. Subtract them with eq. 1.2.3(8) for convergent sums. For complex , apply this to the real and the imaginary parts. The case with one finite range is the sum of a finite number of convergent sums, which is eq. 1.2.3(8) for infinite sums.
A counterexample without the condition. Let and let , and all other . For fixed , the row has the two nonzero terms and , so the row sum is . Row has only , so its sum is . The sum of the row sums is . For each fixed , the column has and , so each column sum is and the sum of the column sums is . So and . A computer check with agrees: the sum of the first row sums is , and each column sum is . The double sum of the absolute values is infinite here, so the first condition fails.
Theorem C1.1.2.3.8 (the sum of a sum, TAOCP eq. 1.2.3(8)). For a finite set and numbers and ,
Node: TAS2J49EG5 · Lean: TAOCP.S1_2_3.eq8 · status: proved
Scope. The same holds for infinite sums when the two sums on the right are convergent.
Explanation. This is the special case of eq. 1.2.3(7) where has two elements, and . It says that a sum is additive in its terms. Together with the rule , which is the special case of eq. 1.2.3(4), it says that the sum is a linear function of the sequence of terms.
Example. With and over : , and .
Proof. For a finite , induction on . The case is . For , the sum . By the induction hypothesis this is , and by the commutative law of the addition it is . For infinite sums, each of the two limits of eq. 1.2.3(3) is a limit of a sum of two sequences of partial sums, and the limit of a sum is the sum of the limits when both exist.
Theorem C1.1.2.3.9 (the interchange when the inner range depends on the outer index, TAOCP eq. 1.2.3(9)). Let and be relations, with finitely many pairs for which both hold. Define as the relation " and ", and define as the relation " holds for at least one integer ". Then
Node: TAP3JGY2XE · Lean: TAOCP.S1_2_3.eq9 · status: proved
Explanation. Both sides add the number once for each pair that satisfies and . The left side groups the pairs by . The right side groups them by . The relations and are the correct new limits: keeps only the columns that have a term, and keeps in column the rows that have a term. The relation can be hard to write in a simple form, and the example of eq. 1.2.3(10) shows a case where it is easy. Eq. 1.2.3(7) is the special case where does not depend on .
Example. Let be and be " and divides ", with . The condition is needed: without it, the negative divisors of are in the range too. By rows: gives ; gives ; gives ; gives ; the total is . By columns: is . For the terms are for , total . For the rows with are , total . For only , total . For only , total . The sum is .
Proof. Let be the set of pairs with . It is finite by the hypothesis. Group the sum by the first coordinate: the pairs with a given form the set if and are absent otherwise, so the grouped sum is . Group the same sum by the second coordinate: the pairs with a given are those with , and the column is not empty exactly when holds. So the grouped sum is . By the fact on finite sums, the two groupings of have the same value.
Example C1.1.2.3.10 (a triangle of indices, TAOCP eq. 1.2.3(10)). For ,
Node: TA05RYNQEA · Lean: TAOCP.S1_2_3.eq10 · status: proved
Explanation. Here is and is . The relation is "there is an with and ", which means : such an needs , and for the choice works. The relation is and , that is together with . The picture is a triangle of cells: the left side adds it by rows, the right side by columns.
Example. For , written out, the left side is and the right side is . With the two sums are and .
Theorem C1.1.2.3.11 (the sum over a union and an intersection, TAOCP eq. 1.2.3(11)). Let and be relations with finite sums. Then
Node: TAK6H7XXM8 · Lean: TAOCP.S1_2_3.eq11 · status: proved
Scope. For infinite sums the same holds when three of the four sums are convergent, and then the fourth is too.
Explanation. A term that is in both ranges is counted twice on the left, and the right side counts it once in the union and once in the intersection. A term that is in only one of the ranges is counted once on each side. This is the rule of inclusion and exclusion for two sets, with a weight on each element. It is used when two ranges overlap in one or two indices, as in the next block, or when they do not overlap at all, so that the second sum on the right is empty.
Example. Let , be and be . The left side is . The union is with sum , the intersection is with sum , and .
Proof. Finite case. Let and . Split into the disjoint parts and , and into and . By the fact on finite sums, and . Add: , because is the disjoint union of the three parts. Infinite case: the identity holds for each pair of window sums by the finite case, and the limits of the four window sums exist when three of them do, because the fourth is a combination of the three by the identity.
Example C1.1.2.3.12 (two ranges that share one index, TAOCP eq. 1.2.3(12)). For integers ,
Node: TA745K9V0X · Lean: TAOCP.S1_2_3.eq12 · status: proved
Explanation. This is eq. 1.2.3(11) with equal to and equal to . The union is . The intersection is only, so its sum is the single term . A person who sums the first terms and then the terms from to counts twice, and the formula takes it away once.
Example. Let , and . The left side is . The right side is .
Theorem C1.1.2.3.13 (the sum over a triangle of products, TAOCP eq. 1.2.3(13)). For numbers ,
Node: TAQS8MZ2E4 · Lean: TAOCP.S1_2_3.eq13, TAOCP.S1_2_3.eq13_div · status: proved
Explanation. The left side is the sum of the products for all pairs with . The full square sum is the square of the sum, and it has each product with twice (as and as ) and each square once. So the triangle (which has each product once, with the diagonal) is half of the square plus half of the diagonal. This is the first example of how the four rules together give a formula. The generalization to three indices is exercise 1.2.3-29.
Example. For and : the triangle has the products , , , , , , with the sum . The right side is , since and .
Proof. Let be the triangle sum and . By the rename of eq. 1.2.3(5) (swap the names and ) and the equality , . The square is the union of the two triangles and , and their intersection is the diagonal . By eq. 1.2.3(11), . The first sum is by eq. 1.2.3(4), and the second is . Since , this gives .
Theorem C1.1.2.3.14 (the sum of a geometric progression, TAOCP eq. 1.2.3(14)). Let and . Then
Node: TA1ZHGJJ22 · Lean: TAOCP.S1_2_3.eq14 · status: proved
Explanation. The terms each get the factor from the one before. The derivation of the book does not guess the answer. It writes the sum in two ways, one by splitting off the first term and one by pulling out the factor and shifting, and it solves the equation for . For the formula has the form , and the sum is (exercise 1.2.3-11). The case also works if the sum is empty: the formula gives (exercise 1.2.3-9).
Example. For , and : , and the formula gives . For , and : the sum is , and the formula gives .
Proof. Let . Split off the first term by eq. 1.2.3(11), since the range is the union of and and they do not overlap: . In the last sum, pull out by eq. 1.2.3(4): . Shift the index by eq. 1.2.3(6) with : . This is the sum without its last term: by eq. 1.2.3(11) again. So . Then , Since , division by gives eq. 1.2.3(14).
A proof by induction, for comparison. For both sides are . If the formula holds for , then the sum to is . This proof checks a formula that a person must already have. The derivation above finds it.
Theorem C1.1.2.3.15 (the sum of an arithmetic progression, TAOCP eq. 1.2.3(15)). For ,
Node: TA002PWA11 · Lean: TAOCP.S1_2_3.eq15 · status: proved
Explanation. The terms increase by the same step . The first term is and the last term is , so their mean is . The terms are placed symmetrically about this mean, and the sum is copies of it. The proof of the book reverses the order of the terms with the reflection and adds the sum to itself, so that the terms of the sum cancel their dependence on .
Example. For , , the terms are with the sum . The formula gives . With and the formula gives the sum of the first integers, .
Proof. Let . Reflect the index by eq. 1.2.3(5) with : the relation is , so . Add this to the original form of with eq. 1.2.3(8): . The terms do not depend on , and there are of them, so and .
Definition C1.1.2.3.16 (the bracket of a statement, TAOCP eq. 1.2.3(16)). For a statement , the bracket is if is true and if is false.
Node: TA4DR5SCA3 · Lean: TAOCP.S1_2_3.eq16 · status: proved
Explanation. The bracket turns a logical value into a number, so that it can be added and multiplied. Then , , and . The convention is due to K. E. Iverson. In Lean, it is if P then 1 else 0, and Mathlib has the same convention as Set.indicator.
Example. and . The number of primes up to is , since the bracket is for and for the other six values. The sum .
Theorem C1.1.2.3.17 (a sum over a relation as a sum over all integers, TAOCP eq. 1.2.3(17)). Let be defined for each integer , and let only finitely many satisfy . Then the sum over equals a sum with no relation, in which takes every integer value:
Node: TATAK9SZM9 · Lean: TAOCP.S1_2_3.eq17, TAOCP.S1_2_3.eq17_all · status: proved
Explanation. On the right, a term with false is , and a term with true is . So the sum over all integers has only finitely many terms that are not zero, and it is a sum in the sense of the definition. The relation has moved from below the sign into the term, and it can be handled with algebra.
Example. With and equal to : . In the sum over all integers, the terms with or are and the others are , so the total is .
Proof. Split the integers into the set and its complement. On the term is . Outside it is . So the sum over all integers is the sum over of plus a sum of zeros, and a sum of zeros is .
Theorem C1.1.2.3.18 (the bracket form of the change of index, TAOCP eq. 1.2.3(18)). Let be a function on the integers, and let finitely many integers satisfy . Then
Node: TADNS4HBGD · Lean: TAOCP.S1_2_3.eq18 · status: proved
Scope. In particular, if matches the with one to one with the with , the inner sum is whenever holds, and the right side is .
Explanation. The identity proves eq. 1.2.3(5) from eq. 1.2.3(17) and the interchange of two sums. It also gives the true value of the sum when is not a permutation: each value is counted as many times as there are with . This is the reason for the care that the book asks for in a change of the index.
Example. Take , equal to , and . The left side is (the values ). The inner sum is for , is for (since ), and is for the other . So the right side is .
Proof. By eq. 1.2.3(17), . For each , write : in the sum over only the term with is not zero. This gives a double sum over and with only finitely many nonzero terms. Interchange the two sums by eq. 1.2.3(7) (valid, since only finitely many terms are nonzero) to get .
Definition C1.1.2.3.19 (the Kronecker delta, TAOCP eq. 1.2.3(19)). The Kronecker delta of two integers and is , that is if and if .
Node: TAX4BE9YWF · Lean: TAOCP.S1_2_3.eq19 (partial) · status: proved
Explanation. The delta is the bracket of the equality. Its most useful property is that it picks one term out of a sum: when the range of contains , since all the terms except one are zero. It is the entry of the identity matrix. The notation is due to L. Kronecker (1868), and the general bracket is due to Iverson (1962).
Example. and . For and with the range : . The sum over of over the whole range is if is in the range and if not. The identity matrix of order is the array with in row and column , namely on the diagonal and elsewhere.
Definition C1.1.2.3.20 (the product over a relation, TAOCP eq. 1.2.3(20)). For a relation that is true for finitely many integers , the product is the product of the numbers over all with . If no integer satisfies , the product is .
Node: TA1PQTX9YZ · Lean: TAOCP.S1_2_3.eq20 (partial) · status: proved
Explanation. The empty product is , not , for the same reason that the empty sum is : is the neutral element of the multiplication, and with this choice the product of the concatenation of two ranges is still the product of the two products. The rules for sums have the same form for products, with multiplication in the place of addition: the change of the index (eq. 1.2.3(5)), the interchange of two products and the rule for the union and the intersection. For the last rule, , and the proof is the proof of eq. 1.2.3(11) with products. For positive terms, the logarithm turns the product into a sum: (exercise 1.2.3-24), by eq. 1.2.2(11). In Lean, this is Finset.prod.
Example. . . For the product with : , which is at . The same formula is the subject of exercise 1.2.3-28.
Theorem C1.1.2.3.21 (the bracket form of the change of the order of two sums, TAOCP eq. 1.2.3(21)). Let and be relations, and let and be as in eq. 1.2.3(9). Then, for all integers and ,
Node: TA542PET6X · Lean: TAOCP.S1_2_3.eq21 · status: proved
Explanation. The identity is an equality of numbers that are or . It says that "row is in the range and the cell is in the row's range" is the same condition as "column is in the range and the cell is in the column's range". With it, eq. 1.2.3(9) follows by an interchange over all integers: , where only finitely many terms are nonzero. This is the proof that the book gives for the triangle of eq. 1.2.3(10).
Example. The triangle has equal to and equal to . Then . A check of this for over all pairs shows that the two sides are equal for each of the pairs. For the single pair the left side is and the right side is ; for both are .
Proof. The first equality is the rule for brackets: the product is if and only if both factors are . For the second, is the statement " and ", so . It remains to show . If is false, both sides are . If is true, then is an integer with and , so is true, and both sides are .
Example C1.1.2.3.22 (a sum over the partitions of an integer, TAOCP eq. 1.2.3(22)). For an integer , the sum below has one term for each way to write as a sum of positive integers in nonincreasing order, with zeros added at the end to make numbers:
Node: TAMFDQ9WXX · status: not stated yet
Explanation. The relation under the sign has indices, and the sum has one term for each tuple that makes the relation true. Here the relation says that the are in nonincreasing order, are not negative, and add up to . Such a tuple is a partition of with the zero parts added. So the number of terms is the number of partitions of (see Section 1.2.1). The block needs care because the same letter is the number of indices and the number to be partitioned. The reader must not read the relation as "each is at most " and think of terms.
Example. For the tuples are , , , and : five terms, and . For the tuples are , , , , , and , which are seven terms, and . For there are eleven terms.
Proof that the number of terms is . A tuple with and sum has at most positive entries, since each positive entry is at least and the sum is . Remove the zero entries to get a partition of into positive parts in nonincreasing order. Conversely, a partition of has at most parts, and adding zeros at the end gives exactly entries. The two maps are inverse to each other.
Algorithms and programs
Section 1.2.3 has no algorithm, no program and no cost analysis. The manipulations of sums are the method of the section, and each of them is a block of the previous part.
The exercises
The table has the exercises of Section 1.2.3. The kind is the class of spec 06.3 that C1 proposes, and the Lean column names the solved theorem of tamnd/taocp-lean at main, when one exists. The marker ▶ is the book's mark of a recommended exercise.
| Exercise | Rating | Markers | Kind | Lean | Solution |
|---|---|---|---|---|---|
| 1.2.3-1 | 10 | ▶ | K3 | TAOCP.S1_2_3.Ex1.solved |
X1, 1.2.3-1 |
| 1.2.3-2 | 01 | K3 | TAOCP.S1_2_3.Ex2.solved |
X1, 1.2.3-2 | |
| 1.2.3-3 | 13 | ▶ | informal | not yet stated | X1, 1.2.3-3 |
| 1.2.3-4 | 10 | K1 | TAOCP.S1_2_3.Ex4.solved |
X1, 1.2.3-4 | |
| 1.2.3-5 | 20 | ▶ HM | K1 | TAOCP.S1_2_3.Ex5.solved |
X1, 1.2.3-5 |
| 1.2.3-6 | 20 | HM | K1 | TAOCP.S1_2_3.Ex6.solved |
X1, 1.2.3-6 |
| 1.2.3-7 | 23 | HM | K1 | TAOCP.S1_2_3.Ex7.solved |
X1, 1.2.3-7 |
| 1.2.3-8 | 25 | HM | K1 | TAOCP.S1_2_3.Ex8.solved |
X1, 1.2.3-8 |
| 1.2.3-9 | 05 | ▶ | informal | not yet stated | X1, 1.2.3-9 |
| 1.2.3-10 | 05 | informal | not yet stated | X1, 1.2.3-10 | |
| 1.2.3-11 | 03 | K3 | TAOCP.S1_2_3.Ex11.solved |
X1, 1.2.3-11 | |
| 1.2.3-12 | 10 | K3 | TAOCP.S1_2_3.Ex12.solved |
X1, 1.2.3-12 | |
| 1.2.3-13 | 10 | K3 | TAOCP.S1_2_3.Ex13.solved |
X1, 1.2.3-13 | |
| 1.2.3-14 | 11 | K3 | TAOCP.S1_2_3.Ex14.solved |
X1, 1.2.3-14 | |
| 1.2.3-15 | 22 | ▶ M | K3 | TAOCP.S1_2_3.Ex15.solved |
X1, 1.2.3-15 |
| 1.2.3-16 | 22 | M | K1 | TAOCP.S1_2_3.Ex16.solved |
X1, 1.2.3-16 |
| 1.2.3-17 | 00 | ▶ M | K3 | TAOCP.S1_2_3.Ex17.solved |
X1, 1.2.3-17 |
| 1.2.3-18 | 20 | M | informal | not yet stated | X1, 1.2.3-18 |
| 1.2.3-19 | 20 | K3 | TAOCP.S1_2_3.Ex19.solved |
X1, 1.2.3-19 | |
| 1.2.3-20 | 25 | ▶ | K1 | TAOCP.S1_2_3.Ex20.solved |
X1, 1.2.3-20 |
| 1.2.3-21 | 25 | ▶ M | informal | not yet stated | X1, 1.2.3-21 |
| 1.2.3-22 | 20 | ▶ | informal | not yet stated | X1, 1.2.3-22 |
| 1.2.3-23 | 10 | informal | not yet stated | X1, 1.2.3-23 | |
| 1.2.3-24 | 20 | K1 | TAOCP.S1_2_3.Ex24.solved |
X1, 1.2.3-24 | |
| 1.2.3-25 | 15 | ▶ | K2 | TAOCP.S1_2_3.Ex25.solved |
X1, 1.2.3-25 |
| 1.2.3-26 | 25 | informal | not yet stated | X1, 1.2.3-26 | |
| 1.2.3-27 | 20 | M | K1 | TAOCP.S1_2_3.Ex27.solved |
X1, 1.2.3-27 |
| 1.2.3-28 | 22 | M | K3 | TAOCP.S1_2_3.Ex28.solved |
X1, 1.2.3-28 |
| 1.2.3-29 | 30 | ▶ M | informal | not yet stated | X1, 1.2.3-29 |
| 1.2.3-30 | 23 | ▶ M | K1 | TAOCP.S1_2_3.Ex30.solved |
X1, 1.2.3-30 |
| 1.2.3-31 | 20 | M | K3 | TAOCP.S1_2_3.Ex31.solved |
X1, 1.2.3-31 |
| 1.2.3-32 | 20 | M | K1 | TAOCP.S1_2_3.Ex32.solved |
X1, 1.2.3-32 |
| 1.2.3-33 | 30 | ▶ M | K1 | TAOCP.S1_2_3.Ex33.solved |
X1, 1.2.3-33 |
| 1.2.3-34 | 25 | M | K1 | TAOCP.S1_2_3.Ex34.solved |
X1, 1.2.3-34 |
| 1.2.3-35 | 20 | HM | informal | not yet stated | X1, 1.2.3-35 |
| 1.2.3-36 | 23 | M | K1 | TAOCP.S1_2_3.Ex36.solved |
X1, 1.2.3-36 |
| 1.2.3-37 | 24 | ▶ M | K1 | TAOCP.S1_2_3.Ex37.solved |
X1, 1.2.3-37 |
| 1.2.3-38 | 25 | ▶ M | K1 | TAOCP.S1_2_3.Ex38.solved |
X1, 1.2.3-38 |
| 1.2.3-39 | 23 | M | K1 | TAOCP.S1_2_3.Ex39.solved |
X1, 1.2.3-39 |
| 1.2.3-40 | 24 | M | informal | not yet stated | X1, 1.2.3-40 |
| 1.2.3-41 | 26 | M | informal | not yet stated | X1, 1.2.3-41 |
| 1.2.3-42 | 18 | M | K3 | TAOCP.S1_2_3.Ex42.solved |
X1, 1.2.3-42 |
| 1.2.3-43 | 24 | M | informal | not yet stated | X1, 1.2.3-43 |
| 1.2.3-44 | 26 | ▶ M | informal | not yet stated | X1, 1.2.3-44 |
| 1.2.3-45 | 25 | ▶ M | informal | not yet stated | X1, 1.2.3-45 |
| 1.2.3-46 | 30 | ▶ M | informal | not yet stated | X1, 1.2.3-46 |
The order to do them. Start with the exercises of rating 10 or lower, which test the meaning of the notation: the empty range, a range with a bound that is not an integer, and the difference between a change of the index and a change of the relation. Then do the short M-rated exercises on the geometric and arithmetic progressions, which use the manipulation of the section in place of induction. The HM-rated exercises are about infinite sums and need the limits of Section 1.2.2. The exercises with a rating of 25 or more are the harder uses of the rules, and the last ones need the determinant of a matrix as well as the product notation. Do the recommended exercises (marked ▶) first, and leave the rest for a second reading.
Lean
The Lean code of tamnd/taocp-lean at main has the file TAOCP/V1/S1_2_3.lean, in the namespace TAOCP.S1_2_3. It states eqs. (4) to (21) and the product forms of rules (b), (c) and (d). The Node lines name the declarations. Where the Lean statement is weaker, the Node line says "partial".
Not yet stated: the sum with an index from 1 to (eq. (1)), the sum over a relation (eq. (2)), the infinite sum (eq. (3)) and the sum over the partitions of an integer (eq. (22)). The infinite sums of eq. (3) have no Lean statement of the rules of the section.
The points where Lean differs from the book are these.
- The statements sum over a
Finset ℤ, and the relation of the book becomes the finite set of its solutions. Eq. (9) writes the relation asj ∈ t i. The values are in an additive commutative monoid, a semiring or a field, as each statement needs, and not only in the real numbers. - Eq. (5):
TAOCP.S1_2_3.eq5takes a finite settthatpmaps one to one ontos.TAOCP.S1_2_3.eq5_bookhas the condition of the book, that eachiinshas exactly onejwithp j = i, and it sums over the set of all suchjwith afinsum. - Eq. (10) is stated for natural numbers, so it includes , which the handbook leaves out.
- Eq. (13):
TAOCP.S1_2_3.eq13has no division, and says that twice the triangle sum is the square of the sum plus the sum of the squares.TAOCP.S1_2_3.eq13_divhas the factor in a field of characteristic zero, which is the form of the handbook. - Eqs. (14) and (15) sum over
Finset.range (n + 1)in a field. Eq. (14) has the hypothesis , as the book does. - Eq. (17):
TAOCP.S1_2_3.eq17sums the brackets over the finite sets, andTAOCP.S1_2_3.eq17_allsums over all integers, as the book does. - Eq. (18) in Lean needs no condition on . It holds for each finite set of indices, and it gives eq. (5) when takes each value of
sonce. - Eq. (19) is stated by its main use, a sum against picks out one term. It is not a definition of . The bracket is
TAOCP.iverson. - Eq. (20) states only that the empty product is . It does not define the product over a relation.
- The Lean file has also
TAOCP.S1_2_3.example1, which splits a sum into the even and the odd indices, and the products of rules (b), (c) and (d):TAOCP.S1_2_3.eq5_prod,TAOCP.S1_2_3.eq7_prodandTAOCP.S1_2_3.eq11_prod.
A sum of Mathlib is Finset.sum, and tsum is the sum of an infinite series. Mathlib's tsum is defined by unconditional convergence. It agrees with the book's sum, defined with the order of the index, exactly for absolutely convergent series. For a series that converges but not absolutely, HasSum can be false while the book's sum exists. A faithful Lean statement of a rule of this section for an infinite series needs Summable of the absolute values, or a direct definition of the limit of eq. (3).
The exercises of the table with a name in the Lean column have statements in TAOCP/Problems/S1_2_3/ and solutions in TAOCP/Solutions/S1_2_3/. The name in the table is the theorem solved of the solution file. The other exercises are not yet stated.
Notes and history
The notation for a sum is due to Leonhard Euler (1755). The notation with limits above and below the sign was introduced by J. Fourier (1820). The convention that a relation can stand under the sign, with no limit above, is common in the work of the author of the book on the analysis of algorithms, and it is the form that makes eqs. 1.2.3(9) and 1.2.3(11) usable. The bracket was proposed by K. E. Iverson in 1962 in a notation for programming, and the bracket form was spread by the book on concrete mathematics. The Kronecker delta is from 1868. A history and a defense of the bracket notation is in the article of D. E. Knuth in the American Mathematical Monthly, volume 99 (1992), pages 403 to 422.
The warnings about infinite sums are theorems of analysis. The independence of the sum from the order of the terms, for absolutely convergent series, is due to P. G. L. Dirichlet (1837), and B. Riemann (1854) proved that a conditionally convergent series can be rearranged to have any sum. The interchange of the order of summation for double series with absolutely convergent terms is the theorem often called after Fubini (for the integral) and after Tonelli (for nonnegative terms). The reference in the book for the infinite case is a textbook of analysis of the time, and any modern analysis text proves the same results.
The identity of Binet of exercise 1.2.3-30 was found by J. Binet in 1812 and has the inequality of Cauchy and Schwarz as a consequence. The matrices of the last exercises are classical. The determinants of the Vandermonde and of the Cauchy matrix are in many books on linear algebra, and the Hilbert matrix of exercise 1.2.3-45 is used as a test for the numerical methods that invert a matrix.
The project has no errata of Section 1.2.3 to report.
Section 1.2.3 of TAOCP gives the notation for sums and products that the rest of the book uses in each analysis. It defines the sum over all integers that satisfy a relation, states four rules for changing a sum (distributing, changing the index, interchanging two sums and splitting the domain), and shows how to derive the sum of a geometric and of an arithmetic progression with these rules and not by induction. It adds the bracket notation of Iverson, the Kronecker delta and the product notation. This chapter of C1 explains each item of the section, proves each rule in full for finite sums, states exactly when the rules hold for infinite sums, and checks the examples by computation.
The source of this page. Something is wrong? Report it.