Summations Denis TRYSTRAM Lecture notes Maths for Computer Science – MOSIG 1 – 2015 1 Simple proofs for counting Many situations in Computer Science involve positive natural numbers (integers). A nice way for proving related results is to represent them by sets of items (bullets, squares) and to use the following principle: Represent the numbers by bullets and count them in two different ways. Obviously, the answer is the same, and thus, it provides the value we are looking for. This is referred as Fubini’s principle in [1]. There is a variant which consists in establishing a one-to-one correspondence between the two sets of items, one being straightforward to compute. Another way to prove results is to restrict to ad hoc geometrical figures where the counting is done by computing basic surfaces [2]. Some specific summations are very useful in Computer Science, for instance in the analysis of algorithms analysis when we are determining their costs. Let us present in this chapter some remarkable ones. They will serve as a basis for introducing various mathematical techniques. 2 2.1 Triangular numbers Analysis of the problem TriangularPnumbers are defined as the sum of the n first integers: ∆n = nk=1 k. There exist many proofs for this result, the simplest one is obtained in writing this sum forward and backward and gathering the terms two by two as follows: 2.Δn = 1 + 2 + … + n + n + n-1 + … + 1 = (n+1) + (n+1) + … + (n+1) ! . Another way of looking at this process is to use Thus, ∆n = (n+1).n 2 the Fubini’s principle as depicted in Figure 1. The number of bullets of two copies of ∆n is given by the n by n + 1 rectangle. Figure 2 shows the same result by using directly a geometric argument. The sum is represented by a series of boxes of size 1 by 1. The global result n" 1" n&1" n&2" 2" 2" 3" 1" n" Figure 1: Applying Fubini’s principle for computing triangular numbers. We consider two copies where the first is represented by blue bullets while the second corresponds to the red bullets. is determined by the surface of the large triangle – which is obviously half a 2 square ( n2 ) – plus n times half of the surface of a basic box in the diagonal. 2 Thus, n2 + n. 12 = (n+1).n 2 n! 1! 2! 3! n! n! Figure 2: Geometric proof for computing triangular numbers. There are several interesting properties on ∆n . Let us study one typical example. 2.2 Sum of two consecutive triangular numbers An interesting question is to compute ∆n + ∆n−1 . Computing the first ranks leads us to an evidence: ∆1 + ∆0 = 1, then, 4, 9, 16, 25, 36, ... We guess n2 , which is easy provable by induction. However, this result can be directly obtained using the same scheme as for computing ∆n : 2 Δn + Δn-1 = 1 + 2 + 3 + … + n + 1 + 2 + … + n-1 = 1 + 3 + 5 + … + (2n-1) ! An alternative geometric proof in Figure 3 allows also to obtain the result. n$ Δn$ n"1$ Figure 3: Geometric argument used for computing ∆n + ∆n−1 which is equal to the surface of the square. 3 Sum of odd numbers The question addressed in this section is to determine the sum of the first P odd integers Sn = n−1 q=0 2q + 1. This result may also be established by using Fubini’s principle as shown in Figure 4. Blue and red bullets depict alternatively the consecutive odd numbers. The arrangement of the bullets gives two ways for counting (by the sum of odd numbers in the left and by the surface of the square in the right). We can also imagine an alternative construction which uses four copies of Sn that exactly correspond to an 2n by 2n square as depicted in Figure 5. This leads to 4.Sn = (2n)2 , thus Sn = n2 . 1! +3! +5! n! +7! +9! n! Figure 4: Sum of odd numbers obtained by Fubini’s principle. 3 2n#1% 2n#1% Figure 5: Another construction for computing the sum of odd numbers with four copies of triangular numbers arranged as a square. 3.1 Generalization Both previous examples of triangular and sum of odd numbers are special cases of arithmetic progressions: starting at p1 = a, pn = pn−1 + b for n > 2. A more general result can be achieved. Figure 6 shows that the sum of the n first elements of an arithmetic progression is equal to n.a + ∆n−1 .b. For instance, a = 1 and b = 2 for the sum of the first n odd numbers. We have Sn = n + 2.∆n−1 = n + n(n − 1) = n2 . 4 Sum of cubes P The sum of n first cubes Cn = nk=1 k 3 is not obvious to determine. First, we should derive an expression and prove it. A straightforward upper bound is n4 since each of the n terms of the sum is less than n3 . This bound may be refined using the analogy of integrals and Riemann’s sum, which leads to 4 a value of order n4 . Let us determine it precisely. A good starting point to give us an idea is to compute the first ranks: C1 = 1, C2 = 9 = 32 , C3 = 36 = 62 , C4 = 100 = 102 , ... All these values are perfect squares. A more attentive observation evidence their link with triangular numbers: we guess Cn = ∆2n . A way to prove this result is to solve the problem using an intermediate one. Figure 7 shows an organization of the odd numbers (left side) where each row corresponds to a cube of the number of elements in the row (right side). This operation is not magical: just compute the closed form of the sum of P consecutive elements of an arithmetic progression... Thus, we obtain: S∆n = nk=1 k 3 (because there are k elements in row k and n rows). As S∆n = ∆2n , the expression is proven. 4 b" a" 1" 2" 3" 4" 5" Figure 6: Sum of an arithmetic progression pn = pn−1 + b. 3" 7" 13" 15" 3" 5" 9" 13" 23" 33" 43" 1" 1" 11" 17" 19" 7" 13" 5" 9" 15" 17" 11" 19" Figure 7: Summing the odd numbers leads to the sum of cubes. We can determine this result directly by using the multiplicative table of Figure 8 (each row/column is multiplied by the next integer), we remark that the sum of all the elements in row k of this matrix is equal to k times the triangular number ∆n . Thus, the global sum is: 1.∆n + 2.∆n + ... + n.∆n = (1 + 2 + ... + n).∆n = ∆2n . Now, using Fubini’s principle again, it is easy to remark that the same global sum can also be obtained by summing the n quadrant (like in the right of Figure 8). Each of these partial sums at rank k is ascending/descending triangular numbers: k.(1 + 2 + ... + (k − 1) + k + (k − 1) + ... + 2 + 1) whose values are equal to the cube of its rank1 . Thus, the global sum is equal to P n 3 k=1 k . 5 Sum of squares Let us now compute the sum of squares: n = 1 This is k.(∆k + ∆k−1 ) = k.k2 = k3 5 Pn k=1 k 2. 1" 2" 3" 4" 5" 2" 4" 6" 8" 10" 3" 6" 9" 12" 15" 4" 8" 12" 16" 20" 1" 2" " 4" 5" 5" 10" 15" 20" 25" 2" 4" " 8" 10" " " " 12" 15" 4" 8" 12" 16" 20" 5" 10" 15" 20" 25" Figure 8: Another way of determining the sum of cubes by triangular numbers. There are so many ways to compute this number! See the dedicated presentation on the slides where seven ways are detailed2 . n = n(n+1)(2n+1) 6 6 Tetrahedral numbers The sum of Pthe ∆n is denoted by Θn and it is called a tetrahedral numbers: Θn = nk=1 ∆k . We can show that: Θn = n.(n+1).(n+2) 6 A way to prove this expression is to write it as 31 . n.(n+1) .(n + 2). This 2 way, it could be interesting to consider three copies of Θn and organize them in order to obtain the expected result. Remember, the way we established the closed formula for triangular numbers was based on 2 copies arranged in the right form... 7 Summary and other problems We proved some results in this chapter, in particular: • Idn = 1 + 1 + ... + 1 = n • ∆n = 1 + 2 + 3 + ... + n = 12 .Idn .(n + 1) • Θn = ∆1 + ∆2 + ... + ∆n = 31 .∆n .(n + 2) An natural P question is if we can go further following the same pattern for computing nk=1 Θk , and so on. P Compute the alternate sum of squares: nk=1 (−1)(k+1) k 2 Compute ∆2n = 3.∆n + ∆n−1 Compute 8∆n + 1 = (2n + 1)2 Show that the sum of consecutive powers of 9 is a triangular number. 2 available on my personal web page 6 References [1] C. Alsina and R. Nelsen. Math made visual. The Mathematical Association of America, 2006. [2] J. Conway and R. Guy. The book of Numbers. Copernicus, Springer Verlag, 1995. [3] R. Graham and D. Knuth and O. Patashnik. Cconcrete Mathematics, a foundation for Computer Science. Addison-Wesley, 1989. 7
© Copyright 2026 Paperzz