<<

CSCE 222 Discrete Structures for Computing

Sequences, Sums, and Products

Dr. Philip C. Ritchey

• A is a function from a subset of the integers to a set 푆. • A discrete structure used to represent an ordered list • 푎푛 denotes the sequence 푎0, 푎1, 푎2, … • Sometimes the sequence will start at 푎1 • 푎푛 is a term of the sequence

• Example • 1, 2, 3, 5, 8 is a sequence with five terms • 1, 3, 9, 27, … , 3푛, … is an infinite sequence • What is the function which generates the terms of the sequence 5, 7, 9, 11, … ? • If 푎0 = 5 • 푎푛 = 5 + 2푛 • If if 푎1 = 5 • 푎푛 = 3 + 2푛

Geometric Progression

• A is a sequence of the form 푎, 푎푟, 푎푟2, 푎푟3, … where the initial term 푎 and the common ratio 푟 are real .

• Example 1 1 1 • 1, , , , … 2 4 8 • What is the initial term 푎 and common ratio 푟? • 푎 = 1 1 • 푟 = 2 푛 • 푎푛 = 푎푟 1 푛 • 푎 = 푛 2 Progression

• An is a sequence of the form 푎, 푎 + 푑, 푎 + 2푑, … where the initial term 푎 and the common difference 푑 are real numbers.

• Example • −1, 3, 7, 11, … • What is the initial term 푎 and common difference 푑? • 푎 = −1 • 푑 = 4 • 푎푛 = 푎 + 푑푛 • 푎푛 = −1 + 4푛 Exercises

List the first several terms of these sequences: 푛+1 • the sequence 푎푛 , where 푎푛 = 푛 + 1 . • 1, 4, 27, 256, 3125,… • the sequence that begins with 2 and in which each successive term is 3 more than the preceding term. • 2, 5, 8, 11, 14, … • 푎푛 = 2 + 3푛 • the sequence that begins with 3, where each succeeding term is twice the preceding term. • 3, 6, 12 ,24, 48, … 푛 • 푎푛 = 3 ⋅ 2 • the sequence where the 푛th term is the of letters in the English word for the index n. • 4, 3, 3, 5, 4, 4, 3, 5, 5, 4, 3, 6, … Recurrence Relations

• A recurrence relation for the sequence 푎푛 is an equation that expresses 푎푛in terms of one or more of the previous terms of the sequence. 푛 • Geometric progression: 푎푛 = 푎푟 • Recurrence relation: 푎푛 = 푟푎푛−1, 푎0 = 푎 (푎0 is the initial condition) • Arthmetic progression: 푎푛 = 푎 + 푑푛 • Recurrence relation: 푎푛 = 푎푛−1 + 푑, 푎0 = 푎 • Fibonacci Sequence: 푓푛 = 0, 1, 1, 2, 3, 5, 8, 13, … • 푓푛 = 푓푛−1 + 푓푛−2, 푓0 = 0, 푓1 = 1 • : 1, 1, 2, 6, 24, 120, 720, 5040, … • 푛! = 푛 푛 − 1 푛 − 2 ⋯ 2 ⋅ 1 • 푎푛 = 푛푎푛−1, 푎0 = 1

Solving Recurrence Relations

• A sequence is called a solution of a recurrence relation if its terms satisfy the recurrence relation. • To solve a recurrence relation, find a closed formula (explicit formula) for the terms of the sequence. • Closed formulae do not involve previous terms of the sequence.

• Example • Relations of the form 푎푛 = 푟푎푛−1 • Geometric progression 푛 • Closed form: 푎푛 = 푎푟 • Relations of the form 푎푛 = 푎푛−1 + 푑 • Arithmetic progression • Closed form: 푎푛 = 푎 + 푑푛 Technique for Solving Recurrence Relations

• Iteration • Forward: work forward from the initial term until a pattern emerges. Then guess the form of the solution. • Backward: work backward from an toward 푎0 until a pattern emerges. The guess the form of the solution. • Example: 푎푛 = 푎푛−1 + 3, 푎0 = 2 • Forward • Backward • 푎1 = 2 + 3 • 푎푛 = 푎푛−2 + 3 + 3 = 푎푛−2 + 2 ⋅ 3 • 푎2 = 2 + 3 + 3 = 2 + 2 ⋅ 3 • 푎푛 = 푎푛−3 + 3 + 2 ⋅ 3 = 푎푛−3 + 3 ⋅ 3 • 푎3 = 2 + 2 ⋅ 3 + 3 = 2 + 3 ⋅ 3 • 푎푛 = 푎푛−4 + 3 + 3 ⋅ 3 = 푎푛−4 + 4 ⋅ 3 • … • … • • 푎푛 = 2 + 3푛 푎푛 = 푎푛−푛 + 푛 ⋅ 3 = 푎0 + 3푛 = 2 + 3푛 Exercises

• Find the first few terms of a solution to the recurrence relation 푎푛 = 푎푛−1 + 2푛 + 3, 푎0 = 4 • 푎1 = 4 + 2 1 + 3 = 9 • 푎2 = 9 + 2 2 + 3 = 16 • 푎3 = 16 + 2 3 + 3 = 25 • ... • Solve the recurrence relation above. 2 • From the first few terms, the pattern seems to be 푎푛 = 푛 + 2 • This can be proved, but we need techniques we haven’t learned yet. Exercises Continued

• Find and solve a recurrence relation for the sequence 0, 1, 3, 6, 10, 15,… • Take differences: 1 - 0 = 1, 3 - 1 = 2, 6 – 3 = 3, 10 – 6 = 4, 15 – 10 = 5, … • Write down the relation: 푎푛 = 푎푛−1 + 푛, 푎0 = 0 • Use backwards iteration • 푎푛 = 푎푛−1 + 푛 • = 푎푛−2 + 푛 − 1 + 푛 • = 푎푛−3 + 푛 − 2 + 푛 − 1 + 푛 • … • = 푎0 + 1 + 2 + ⋯ + 푛 • = 0 + 1 + 2 + ⋯ + 푛 푛 푛+1 • The sum of the integers from 1 to 푛 is 2 푛 푛+1 • 푎 = 푛 2

• The sum of the 푚 through 푛-th terms of sequence 푎푘 푎푚 + 푎푚+1 + ⋯ + 푎푛 is denoted as 푛

푎푖 푖=푚 where 푖 is the index of , 푚 is the lower limit, and 푛 is the upper limit. Examples

1 • Use summation notation to express the sum from 1 to 100 of : 100 푥 1

푖 푖=1 3 • Evaluate 푖=0 2푖 + 1

3 2푖 + 1 = 2 ⋅ 0 + 1 + 2 ⋅ 1 + 1 + 2 ⋅ 2 + 1 + 2 ⋅ 3 + 1 푖=0 = 1 + 3 + 5 + 7 = 16 Manipulations of Summation Notation

푛 푙 푛

푐푎푖 = 푐 푎푖 푎푖 = 푎푖 + 푎푖 푖 푖 푖=푚 푖=푚 푖=푙+1

푛 푛 푛 푛 푛−푚 푛−푚

푎푖 + 푏푖 = 푎푖 + 푏푖 푎푖 = 푎푗+푚 = 푎푛−푘 푖=푚 푖=푚 푖=푚 푖=푚 푗=0 푘=0

푛 푛 푛 푛 푚−1

푎푖 + 푐 = 푎푖 + 푐 푛 − 푚 + 1 푎푖 = 푎푖 − 푎푖 푖=푚 푖=푚 푖=푚 푖=0 푖=0 Exercises

• Evaluate 10 3 푖=1 • 3+3+3+3+3+3+3+3+3+3 = 30 • Let 푆 = 1,3,5,7 . Evaluate 푗2 푗∈푆 • 1+9+25+49 = 84 • Evaluate 8 3 ⋅ 2푖 푖=0 8 푖 • 3 푖=0 2 = 3 1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 = 1533 Summation Identities

• There are MANY, but here are two you should know: • Geometric 푛−1 푛 푟 = 1 푛 푟푖 = 푟 − 1 푖=0 푟 − 1 푟 ≠ 1

• Arithmetic Series 푛−1 푛 푛 − 1 푖 = 2 푖=0 Geometric Series Identity Proof 푟 ≠ 1

푛−1 푛−1 Let S = 푟푖 = 푟푗 + 푟푛 − 푟0 푖=0 푗=0

푛−1 푛 푟S = 푟 푟푖 푟푆 = 푆 + 푟 − 1 푖=0 푆 푟 − 1 = 푟푛 − 1 푛−1 푖+1 = 푟 푟푛 − 1 푖=0 푆 = 푟 − 1 푛 = 푟푗 □ 푗=1

Products

• The product of the 푚 through 푛-th terms of sequence 푎푘 푎푚 ⋅ 푎푚+1 ⋅ ⋯ ⋅ 푎푛 is denoted as 푛

푎푖 푖=푚

Example: 푛 푛! = 푖 푖=1 A Product Identity

푛 푛 푛 푛−푚+1 푐푎푖 = 푐 푎푖 푐푎푖 = 푐푎푚 푐푎푚+1 ⋯ 푐푎푛 푖=푚 푖=푚 푖=푚

= 푐 푐 ⋯ 푐 ⋅ 푎푚 푎푚+1 ⋯ 푎푛

푛 푛 1 = 푐 푖=푚 푎푖 푖=푚

푛 푛−푚+1 = 푐 푎푖 푖=푚