cpcs 222 discrete structures ikau.cazalas.com/courses/cpcs222/notes/sequences...11 example find...

26
Dr. Eng. Farag Elnagahy [email protected] Office Phone: 67967 King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222 Discrete Structures I Sequences and Summations

Upload: dangkhanh

Post on 07-Mar-2018

215 views

Category:

Documents


1 download

TRANSCRIPT

Dr. Eng. Farag [email protected]

Office Phone: 67967

King ABDUL AZIZ UniversityFaculty Of Computing and Information Technology

CPCS 222Discrete Structures I

Sequences and Summations

2

Introduction

Sequences are ordered lists of elements.

Sequences are used in discrete mathematicsin many ways.

They can be used to represent solutions tocertain counting problems.

They are also an important data structurein computer science.

3

Sequences

A sequence is a discrete structure used torepresent an ordered list.

For example

1, 2, 3, 5, 8 is a sequence with five terms

1, 3, 9, 27, 81 , . . . , 30, . . . is aninfinite sequence.

4

DEFINITION

A sequence is a function from a subset of the set of integers (usually either the set {0, 1, 2, . . .} or the set {1, 2, 3, . . .}) to a set S.

the notation an is used to denote the image of the integer n. We call an a term of the sequence.

Note that an represents an individual term of the sequence {an}.

5

EXAMPLE

Consider the sequence {an}, where

The list of the terms of this sequence, beginning with a1, namely, a1, a2, a3, a4,...

starts with

6

Geometric Progression

A geometric progression is a sequence of the form

where the initial term a and the common ratior are real numbers.

A geometric progression is a discrete analogue of the exponential function f(x) = arx .

7

EXAMPLE

The sequences {bn} with bn = (-1)n, {cn } with cn= 2.5n , and {dn} with dn = 6·(1/3)n are geometricprogressions with initial term and common ratioequal to 1 and -1; 2 and 5; and 6 and 1/3,respectively, if we start at n=0.The list of termsb0, b1, b2, b3, b4,... begins with

1,-1,1,-1,1,...; c0 , c1, c2, c3, c4,... begins with

2,10,50,250,1250,...; d0 , d1, d2, d3, d4,... begins with

6, 2, 2/3, 2/9, 2/27, ….

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.

An arithmetic progression is a discrete analogue of the linear function f(x) = dx + a.

9

EXAMPLE

The sequences {sn} with sn = -1 + 4n and {tn} with tn = 7-3n are both arithmetic progressions with initial terms and common differences equal to -1and 4, and 7 and -3, respectively, if we start at n=0.

The list of terms s0, s1, s2, s3, s4,... begins with -1,3,7,11,...,

the list of terms t0, t1, t2, t3, t4,... begins with 7, 4, 1, -2, . . . .

10

Special Integer Sequences A common problem in discrete mathematics is findinga formula or a general rule for constructing the termsof a sequence.• Sometimes only a few terms of a sequence solving a problem are known; the goal is to identify the sequence. •You might also see whether you can determine how a term might have been produced from those preceding it. •Are there runs of the same value? That is, does the same value occur many times in a row? •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? etc.

11

EXAMPLE Find formulae for the sequences with the following first five terms: (a) 1, 1/2, 1/4, 1/8, 1/16 (b) 1, 3, 5, 7, 9 (c) 1, - 1, 1, - 1, 1.(a) Note that the denominators are powers of 2. The sequence with an = 1/2n , n = 0, 1, 2, . . . is a possible match. It is geometric progression with a=1 and r=1/2.(b) each term is obtained by adding 2 to the previous term. The sequence with an = 2n + 1, n = 0, 1, 2, . . . is a possible match. It is an arithmetic progression with a=1 and d=2. (c) The terms alternate between 1 and -1. The sequence with an= (-1)n, n = 0, 1, 2 . . . is a possible match. It is a geometric progression with a=1 and r=-1.

12

EXAMPLEHow can we produce the terms of a sequence if the first 10 terms are 1, 2, 2, 3, 3, 3, 4, 4, 4, 4?

Note that theinteger 1 appears once,integer 2 appears twice,integer 3 appears three times,integer 4 appears four times.

A reasonable rule for generating this sequence is thatthe integer n appears exactly n times,

so the next five terms of the sequence would all be 5,the following six terms would all be 6, and so on.

13

EXAMPLEHow can we produce the terms of a sequence if the first 10 terms are 5, 11, 17, 23, 29, 35, 41, 47, 53, 59?

Note that each of the first 10 terms of this sequence after the first is obtained by adding 6 to the previous term.

(the difference between consecutive terms is 6.)

Consequently, the nth term could be produced by starting with 5 and adding 6 a total of n-1 times; that is, a reasonable guess is that the nth term is 5+6(n-1)=6n-1.

(it is an arithmetic progression with a=5 and d=6.)

14

Some Useful Sequences Another useful technique for finding a rule for generating the terms of a sequence is to compare the terms of a sequence of interest with the terms of a well-known integer sequence, such as terms of an arithmetic progression, terms of a geometric progression, perfect squares, perfect cubes, and so on.

The first 10 terms of some sequences you may want to keep in mind are displayed below.

15

EXAMPLEConjecture a simple formula for an if the first 10 terms of thesequence {an} are 1, 7, 25, 79, 241, 727 ,2185, 6559,19681, 59047.

To attack this problem, we begin by looking at the differenceof consecutive terms, but we do not see a pattern.

When we form the ratio of consecutive terms to see whethereach term is a multiple of the previous term, we find that thisratio, although not a constant, is close to 3.

So it is reasonable to suspect that the terms of this sequenceare generated by a formula involving 3n . Comparing theseterms with the corresponding terms of the sequence {3n}, wenotice that the nth term is 2 less than the correspondingpower of 3. We see that an=3n–2 for 1≤n≤10 and conjecturethat this formula holds for all n.

16

Summations

summation notationthe notation used to express the sum of the terms

am, am+1, …, an

from the sequence {an} is:

the variable j is called the index of summation, and the choice of the letter j as the variable is arbitrary.

17

Summationswe can use any other letter, such as i or k.

the index of summation runs through all integers starting with its lower limit m and ending with its upper limit n.

A large uppercase Greek letter sigma, , is used to denote summation.

18

EXAMPLEExpress the sum of the first 100 terms ofthe sequence {an}, where an = 1/n for n=1, 2,3, ....

The lower limit for the index of summation is 1, and the upper limit is 100. We write this sum as:

19

EXAMPLE

What is the value of

What is the value of

20

Shifting an index of summation

Sometimes it is useful to shift the index ofsummation in a sum.

This is often done when two sums need to beadded but their indices of summation do notmatch.

When shifting an index of summation, it isimportant to make the appropriate changes inthe corresponding summand.

21

Shifting an index of summation

Suppose we have the sum

but want the index of summation to run between 0 and 4 rather than from 1 to 5.

To do this, we let k=j-1. Then the new summation index runs from 0 to 4, and the term j2 becomes (k + 1)2. Hence,

It is easily checked that both sums are 1 + 4 + 9 + 16 + 25 = 55

22

THEOREM If a and r are real numbers and r ≠ 0, then

Proof: Let

To compute S, first multiply both sides of the equality by r and then manipulate the resulting sum as follows:

23

THEOREMsubstituting summation formula for S

by the distributive property

shifting the index of summation, with k = j + 1

removing k = n + 1 term and adding k = 0 term

substituting S for summation formula

24

Double summationsDouble summations arise in many contexts (as in the analysis of nested loops in computer programs).

To evaluate the double sum, first expand the inner summation and then continue by computing the outer summation:

25

Some Useful Summation Formulae.

26

Examples