Page 295 - HOW TO PROVE IT: A Structured Approach, Second Edition
P. 295

P1: Oyk/
                   0521861241c06  CB996/Velleman  October 20, 2005  1:8  0 521 86124 1  Char Count= 0






                                                       Recursion                       281
                                                                   1
                                                                                n
                                                               0
                                                                       2
                              For another example, consider the sum 2 + 2 + 2 +· · · + 2 , which ap-
                            peared in the first example of this chapter. The ellipsis suggests that we might
                                                                                        n
                                                                               2
                                                                       0
                                                                           1
                            be able to use a recursive definition. If we let f (n) = 2 + 2 + 2 + ··· + 2 ,
                                                                     0    1   2        n
                            then notice that for every n ∈ N, f (n + 1) = 2 + 2 + 2 +· · · + 2 +
                            2 n+1  = f (n) + 2 n+1 . Thus, we could define f recursively as follows:
                                                  0
                                           f (0) = 2 = 1;
                                           for every n ∈ N, f (n + 1) = f (n) + 2 n+1 .
                            As a check that this definition is right, let’s try it out in the case n = 3:
                                                f (3) = f (2) + 2 3
                                                             2
                                                    = f (1) + 2 + 2 3
                                                             1   2    3
                                                    = f (0) + 2 + 2 + 2
                                                           1
                                                       0
                                                               2
                                                    = 2 + 2 + 2 + 2 3
                                                    = 15.
                              Sums such as the one in the last example come up often enough that there
                            is a special notation for them. If a 0 , a 1 ,..., a n is a list of numbers, then the
                                                        n
                            sum of these numbers is written  a i . This is read “the sum as i goes from
                                                        i=0
                            0to n of a i .” For example, we can use this notation to write the sum in the last
                            example:
                                              n
                                                 i    0   1   2        n
                                                2 = 2 + 2 + 2 + ··· + 2 .
                                             i=0
                            More generally, if n ≥ m, then
                                            n

                                              a i = a m + a m+1 + a m+2 +· · · + a n .
                                           i=m
                            For example,
                                              6
                                                 2    2   2   2    2
                                                 i = 3 + 4 + 5 + 6
                                              i=3
                                                   = 9 + 16 + 25 + 36 = 86.

                            The letted i in these formulas is a bound variable and therefore can be replaced
                            by a new variable without changing the meaning of the formula.
                              Now let’s try giving a recursive definition for this notation. We let m be an
                            arbitrary integer, and then proceed by recursion on n. Just as the base case for
                            an induction proof need not be n = 0, the base for a recursive definition can
                            also be a number other than 0. In this case we are only interested in n ≥ m,so
   290   291   292   293   294   295   296   297   298   299   300