CISC 1400 Discrete Structures Chapter 2 Sequences What is Sequence? A sequence is an ordered list of objects or elements. For example, 1, 2, 3, 4, 5, 6, 7, 8 Each object/element is called a term. 1 st term in a sequence : a 1 k th term in a sequence : a k A sequence can be infinite or finite A length is associated with a finite sequence. in the sequence indicates that the sequence continues. a 1, a 2,, a k,.
Describing Patterns in Sequences What number comes next? 1, 2, 3, 4, 5, 2, 6, 10, 14, 18, 1, 2, 4, 8, 16, 2, 4, 6, 8, 10 What is a 1? What is a 3? What is a 5? What is a k if k = 4? What is a k-1 if k = 4?
2, 4, 6, 8, 10 Can we relate a term to previous terms? The first term a 1 is 2. Second term a 2 is 2 more than the first term a 1. Third term a 3 is 2 more than the second term a 2.. In fact, each subsequent term a k is just two more than the previous one a k-1. a 1 = 2 a k = a k-1 +2 2, 4, 6, 8, 10 Can we describe each item in relation to its position in the sequence? The term at position 1 is 2 The term at position 2 is 4 The term at position 3 is 6 The term at position k is 2 * k a k = 2*k
2, 4, 6, 8, 10 We have found two ways to describe the sequence Recursive method: each subsequent term a k is two more than the previous one a k-1 Closed method: the term at position k is 2 * k It s also the sequence of all even numbers Describing Patterns in Sequences Recursive Method The pattern could be that each term is somehow related to previous terms Closed Method The pattern could be described by its relationship to its position in the sequence (1 st, 2 nd, 3 rd etc )
1, 2, 3, 4, 5, Recursive method: a 1 = 1 a 2 = 2 = 1 + a 1 a 3 = 3 = 1 + a 2 a 4 = 4 = 1 + a 3 a k = 1+ a k-1 Closed method: a 1 = 1 a 2 = 2 = 1*2 a 3 = 3 = 1*3 a 4 = 4 = 1*4 a k = 1*k = k 1, 3, 5, 7, 9, Recursive method: a 1 = 1 a 2 = 3 = 2 + a 1 a 3 = 5 = 2 + a 2 a 4 = 7 = 2 + a 3 a k = 2+a k-1 Closed method: a 1 = 1 = 1+2*0 a 2 = 3 = 1+2*1 a 3 = 5 = 1+2*2 a 4 = 7 = 1+2*3 a k = 1+2*(k-1)
1, 2, 6, 24, 120, Recursive method: a 1 = 1 a 2 = 2 = 2 * a 1 a 3 = 6 = 3 * a 2 a 4 = 24 = 4 * a 3 a k = k*a k-1 Closed method: a 1 = 1 a 2 = 2 = 1*2 a 3 = 6 = 1*2*3 a 4 = 24 = 1*2*3*4 a k = 1*2*3* *k Recursive Method vs. Closed Method Recursive Method Given the sequence, easier to find recursive formula Harder for evaluating a given term Closed Method Given the sequence, harder to find closed formula Easier for evaluating a given term
Exercises: find out recursive formula 1, 4, 7,10,13, a 1 =1, a k = a k-1 +3 1, 2, 4, 8, 16, 32, a 1 =1, a k = a k-1 *2 1, 1, 2, 3, 5, 8, 13, a 1 =1, a 2 =1, a k = a k-1 +a k-2 Exercises: find out closed formula 3, 5, 7, 9, a k = 1+k*2 3, 6, 9, 12, a k = k*3 1, 4, 7, 10, 13, a k = (k-1)*3+1
What comes next? 2, 5, 10, 17, 26, 37, a 1 =2, a k =a k-1 +2k-1 2, 3, 5, 8, 12, 17, a 1 =2, a k = a k-1 +k-1 Closed Formula => Recursive Formula By observations: write out a number of initial terms, and then determine how each value relates to previous term(s) a k 7k 6 k 1 2 3 4 5 a k 1 8 15 22 29 a 1 1 a k a k 1 7
Closed formula => Recursive formula: algebraic manipulation a k 7k 6 Try to describe a k in terms of a k-1 a k 7k 6 a k 1 7( k 1) 6 7k 13 We see that a k 13 7k a 13 k 1 7 k 1 7 k 1 k 1 ak k 6 a 13 6 a So the recursive formula is a 7*1 6 a 7 k a k 1 1 1 7 Exercise Given the closed formula, find the recursive formula: a k =3k+5
Summation A summation is just the sum of some terms in a sequence. For example 1+2+3+4+5+6 is the summation of first 6 terms of sequence: 1, 2, 3, 4, 5, 6, 7,. 1+4+9+16+25 is the summation of the first 5 terms of sequence 1, 4, 9, 16, 25, 49, Summation is a very common Idea Because it is so common, mathematicians have developed a shorthand to represent summations (some people call this sigma notation) n i1 a i This is what the shorthand looks like, on the next few slides we will dissect it a bit.
Sigma Notation n i1 a i The giant Sigma just means that this represents a summation Sigma Notation n i1 a i The i=1 at the bottom just states where is the sequence we want to start. If the value was 5 then we would start the sequence at the 5 th position
Sigma Notation n i1 a i The n at the top just says to what element in the sequence we want to get to. In this case we want to go up through the nth item. Sigma Notation n i1 a i The portion to the right of the sigma is the closed formula for the sequence you want to sum over.
Sigma Notation n i1 a i So this states that we want to compute the closed formula for each element from 1 to n. Sigma Notation n i1 i Thus our summation is 1 + 2 + 3 + + n If I told you that n had the value of 5, then the summation would be 1 + 2 + 3 + 4 + 5 = 15
Examples 5 1 2) ( i i 7 1 2 1) ( i i 25 7 6 5 4 3 147 50 37 26 17 10 5 2 Sums using sigma notation 5+10+15+20+25+30+35+40 1+8+27+64+125+216 8 1 ) (5 i i 6 1 3 ) ( i i
Decimal Numeral System Base-10 Decimal numbers uses digits from 0..9. These are the regular numbers that we use. It is based on the decimal sequence 10, 100, 1000, Example: 2538 10 = 2 1000 + 5 100 + 3 10+8 1 = 2 10 3 +5 10 2 +3 10 1 +8 10 0 Numeral System b - numeral system base d n - the n-th digit n - can start from negative number if the number has a fraction part. N+1 - the number of digits
Binary Numeral System - Base-2 It is easier that computer hardware represents only the binary digits - 0/1. It is based on the binary sequence 2, 4, 8, 16, 32,. Since the closed form of binary sequence is a k = 2 k, the binary sequence is written as 2 1, 2 2,2 3, 2 4, Binary Numeral System - Base-2 Binary number 10101 2 1 0 1 0 1 4 3 2 1 0 n: position of digits 1 2 4 +0 2 3 +1 2 2 +0 2 1 +1 2 0 = 16+4+1= 21
Binary Numeral System - Base-2 1 0 1 1 1 4 3 2 1 0 10111 2 = 1 2 4 +0 2 3 +1 2 2 +1 2 1 +1 2 0 = 16+4+2+1= 23 1 0 0 0 1 1 5 4 3 2 1 0 100011 2 = 1 2 5 +0 2 4 +0 2 3 +0 2 2 +1 2 1 +1 2 0 =32+2+1= 35 From Decimal to Binary Short Division by Two with Remainder
Octal Numeral System - Base-8 Octal numbers uses digits from 0..7. 27 8 = 2 8 1 +7 8 0 = 16+7 = 23 30 8 = 3 8 1 +0 8 0 = 24 4307 8 = 4 8 3 +3 8 2 +0 8 1 +7 8 0 = 2247 Hexadecimal Numeral System - Base-16 Hex numbers uses digits from 0..9 and A..F 28 16 = 2 16 1 +8 16 0 = 40 2F 16 = 2 16 1 +15 16 0 = 47 BC12 16 = 11 16 3 +12 16 2 +1 16 1 +2 16 0 = 48146
2016/9/8