MSU/CSE 260 Fall Sequences and Summations
MSU/CSE 260 Fall 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. a n, is called a term of the sequence and denotes the image of the integer n. {a n } denotes the sequence. Do not confuse the above notation with set notation. This is a “misuse” of the set notation.
MSU/CSE 260 Fall 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 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 Example
MSU/CSE 260 Fall Example
MSU/CSE 260 Fall Geometric Progression A geometric progression is a sequence of the form: a, ar, ar 2, …, ar n 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) = ar x.
MSU/CSE 260 Fall Examples The sequence {b n }, where b n = (-1) n for n = 1, 2, 3… starts with: -1, 1, -1, 1, … The sequence {c n }, where c n = 2 n 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 {d n }, where d n = 6 · (1/3) n for n = 1, 2, 3… starts with: 2, 2/3, 2/9, 2/27, …
MSU/CSE 260 Fall 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 Examples The sequence {s n }, where s n = – 1 + 4n for n =1,2,3… starts with: 3, 7, 11, … The sequence {t n }, where t n = 7 – 3n for n =1, 2, 3… starts with: 4, 1, -2, …
MSU/CSE 260 Fall Strings Strings are sequences of the form a 1 a 2 …a n, 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 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 Examples Consider the sequence 5, 11, 17, 23, 29, 35, 41, 47, 53, 59… Describe {a n } {a n } = 5 +6n n = 0, 1, 2,… 666
MSU/CSE 260 Fall Examples Consider the sequence 1, 7, 25, 79, 241, 727, 2185, 6559, 19681, Describe {a n } Answer: A n = 3 n
MSU/CSE 260 Fall Useful Sequences nth TermFirst 10 Terms n2n2 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, … n3n3 1, 8, 27, 64, 125, 216, 343, 512, 729, 1000, … n4n4 1, 16, 81,256,625,1296,2401,4096,6561,10000,… 2n2n 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, … n!n!1,2,6,24,120,720,5040,40320,362880, ,…
MSU/CSE 260 Fall Summations Consider the sequence {a k }. We define the following summation: Terminology: j is called the index of summation, m is the lower limit, n is the upper limit.
MSU/CSE 260 Fall Summations…
MSU/CSE 260 Fall Worksheet problem: P 103 *35 Given two sequences (sets?) of positive reals {X j } and {Y j } Define the function F(k) = j=1, 2, … k (X j * Y j ) 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 Summations…