This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Chapter 3 Sequences § 3.1 Summation Nested loops, whileloops with compound termination criteria § 3.2 Recursions Oneterm recursion, searching for a first occurrence, twoterm recursion. In Chapter 2 we played with the sequence of regular ngon areas { a n } where A n = n 2 sin 2 π n . We numerically “discovered” that lim n →∞ A n = π , a fact that is consistent with our geometric intuition. In this chapter we build our “ nth term expertise” by exploring sequences that are specified in various ways. At the top of our agenda are sequences of sums like S n = 1 + 1 4 + 1 9 + ··· + 1 n 2 . Many important functions can be approximated by very simple summations, e.g., exp( x ) ≈ 1 + x + x 2 2! + ··· + x n n ! . The quality of the approximation depends upon the value of x and the integer n . Sometimes a sequence is defined recursively . The nterm may be specified as a function of previous terms, e.g., f n = 1 if n = 1 or 2 f n 1 + f n 2 if n ≥ 3 Sequence problems of this variety give us the opportunity to practice some difficult formulato program transitions. 75 76 Chapter 3. Sequences 3.1 Summation The summation of a sequence of “regularly scheduled” numbers is such a common enterprise that a special notation is used. This is the “sigma” notation and here is an example: n X k =0 x k k ! = 1 + x + x 2 2! + ··· + x n n ! . The value of many regular summations is known. For example, the sum of the first n positive integers is given by n X k =1 k = n ( n + 1) 2 . (3.1.1) It is interesting to write programs that check rules like this. The program Example4 1 confirms that the sum of the first n integers is given by the above rule for n = 1 to 20. % Example3 1: Check the rule for the summation of the first n integers nmax= 20; % The no. of nvalues used in the rule checking s= 0; % The sum of the sequence so far % Print the column headings fprintf(’ \ n’); fprintf(’ \ n n \ t Sum \ t n(n+1)/2 \ n’); fprintf(’ \ n’); % Compute summation of first n integers for n= 1:nmax s= s+n; rhs= n*(n+1)/2; fprintf(’%3d \ t %3d \ t %8d \ n’, n, s, rhs); end Output: n Sum n(n+1)/2 1 1 1 2 3 3 3 6 6 . . . 19 190 190 20 210 210 The program uses a forloop to actually compute the summation. The result is then printed sidebyside with the value of the summation formula. The program is not a proof of Equation 3.1. Summation 77 (3.1.1); it merely checks its correctness for a small set of possible n . Problem 3.1. Modify Example3 1 so that it confirms the following for n = 1 .. 20: n X k =1 k 2 = n ( n + 1)(2 n + 1) 6 . Problem 3.2. It is possible to find real numbers a, b, c, d, and e so that n X k =1 k 3 = an 4 + bn 3 + cn 2 + dn + e for all n . Note that if n is large enough, then n X k =1 k 3 ≈ an 4 ....
View
Full Document
 Spring '07
 FAN/CHEW
 matlab, Recursion, Tn, Fibonacci number, RK, builtin function, ak−1

Click to edit the document details