Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Sequences and Summations MSU/CSE 260 Fall 2009 1 Sequences Definition: A sequence is a function whose domain D is a subset of N ={0, 1, 2, …} of the form: D = { k, k+1, k+2, … }, for some k N, or D = { k, k+1, k+2, …, k + m }, for some k, m N Typically, k { 0, 1 }. Terminology: In the first case, the sequence is said to be infinite; in the second, it is said to be finite, and of length m. an, is called a term of the sequence and denotes the image of the integer n. {an} denotes the sequence. Do not confuse the above notation with set notation. This is a “misuse” of the set notation. MSU/CSE 260 Fall 2009 2 A function that generates pseudo random integers. Choose some prime P, say 11 Choose some starting value S, say 5. Choose a “generator”G, say 7. F(1) = 5 (= S) F(k) = F(k-1) * 7 modulo 11 (F(k-1)*G mod P)) Worksheet: Run the sequence for 11, 7, 5 MSU/CSE 260 Fall 2009 3 What are random numbers for? Assigning probabilities for events in games or simulations. Generating unbiased test data. Creating novel graphics, etc. Typical random number generator generates random bits or maps integers into the “reals” in the interval [0, 1). (See MATLAB or C rand.) MSU/CSE 260 Fall 2009 4 Example 1 Consider sequence {an }, where an . n 1 1 1 Few terms are: a1 1, a2 , a3 , a4 , 2 3 4 MSU/CSE 260 Fall 2009 5 Example Consider the sequence { f n }, where n 1 1 5 1 1 5 fn 5 2 5 2 Find terms: f 0 , f1 , f 2 , f 3 , f 4 , f 5 , f 6 , MSU/CSE 260 Fall 2009 n 6 Geometric Progression A geometric progression is a sequence of the form: a, ar, ar2, …, arn where the initial term, a, and common ratio, r, are real numbers. A geometric progression is a discrete analogous of the exponential function f (x) = arx. MSU/CSE 260 Fall 2009 7 Examples The sequence {bn}, where bn= (-1)n for n = 1, 2, 3… starts with: -1, 1, -1, 1, … The sequence {cn}, where cn= 2n for n = 0, 1, 2, 3… starts with: 1, 2, 4, 8, 16, … (Consider the number of nodes in a perfect binary tree.) The sequence {dn}, where dn= 6·(1/3)n for n = 1, 2, 3… starts with: 2, 2/3, 2/9, 2/27, … MSU/CSE 260 Fall 2009 8 Arithmetic Progression An arithmetic progression is a sequence of the form a, a+d, a+2d, …, a+nd where the initial term, a, and the common difference, d, are real numbers. A arithmetic progression is a discrete analogous of the linear function f (x) = dx + a. MSU/CSE 260 Fall 2009 9 Examples The sequence {sn}, where sn= – 1 + 4n for n =1,2,3… starts with: 3, 7, 11, … The sequence {tn}, where tn= 7 – 3n for n =1, 2, 3… starts with: 4, 1, -2, … MSU/CSE 260 Fall 2009 10 Strings Strings are sequences of the form a1a2…an, where the codomain is the set of characters The length of the string is the number of its terms The empty string is the string that has no terms MSU/CSE 260 Fall 2009 11 Special Integer Sequences To deduce a possible formula/rule for the terms of a sequence from initial terms, ask the following: Are there runs of the same value? Are terms obtained from previous terms by adding the same amount or an amount that depends on the position in the sequence? Are terms obtained from previous terms by multiplying by a particular amount? Are terms obtained by combining previous terms in a certain way? Are there cycles among the terms? MSU/CSE 260 Fall 2009 12 Examples Consider the sequence 5, 11, 17, 23, 29, 35, 41, 47, 53, 59… Describe {an} 6 6 6 {an} = 5 +6n n = 0, 1, 2,… MSU/CSE 260 Fall 2009 13 Examples Consider the sequence 1, 7, 25, 79, 241, 727, 2185, 6559, 19681, Describe {an} 6 18 54 Answer: An = 3n - 2 MSU/CSE 260 Fall 2009 14 Useful Sequences nth Term First 10 Terms n2 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, … n3 1, 8, 27, 64, 125, 216, 343, 512, 729, 1000, … n4 1, 16, 81,256,625,1296,2401,4096,6561,10000,… 2n 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, … n! 1,2,6,24,120,720,5040,40320,362880,3628800,… MSU/CSE 260 Fall 2009 15 Summations Consider the sequence {ak}. We define the following summation: n a j m j am am1 am2 an Terminology: j is called the index of summation, m is the lower limit, n is the upper limit. MSU/CSE 260 Fall 2009 16 Summations… Note that the following are all the same: n n n a a a j m j i m i k m k m j n MSU/CSE 260 Fall 2009 aj 17 Worksheet problem: P 103 *35 Given two sequences (sets?) of positive reals {Xj} and {Yj} Define the function F(k) = j=1, 2, … k(Xj * Yj) Show that this function is maximized when both sets are sorted into ascending order. (Note here that we are changing the order in the sequences.) Consider the “student credit default swap” problem/solution! MSU/CSE 260 Fall 2009 18 Summations… 1. Distributive Law: c a kA k c ak k A 2. Associative Law: (ak bk ) ak bk kA k A k A 3. Commutative Law: kA ak ( k )A a ( k ) where ( k ) is any permutation of the set of natural numbers. Example: (a b k ) 0 k n ( a b ( n k )) 0 n k n MSU/CSE 260 Fall 2009 19