16

Sequences

Embed Size (px)

Citation preview

Page 1: Sequences
Page 2: Sequences

Sequences

o Sequences represent ordered lists of elements.o OR a list of elements usually written in a row.

• 1, 2, 3, 4, 5, … 1, 1/2, 1/3, 1/4, 1/5, …o A sequence is defined as a function from a

subset of N to a set S. We use the notation an to denote the image of the integer n. We call an a term of the sequence.– N={1, 2, 3, …} /whole numbers {0, 1, 2, 3, …}.– S: { 2 4 6 8 10 …}– {an} =a1, a2, a3, a4 …, an, …

Page 3: Sequences

Explicit Formulao It is convenient to describe a sequence with a formula.

o S: { 2 4 6 8 10 …}o an = 2no 1, 3, 5, 7, 9, … an = 2n – 1o 2, 5, 10, 17, 26, … an = n2 + 1

o Find formula for

o

1 1 1 1 1 1 11 , , , ,2 2 3 3 4 4 5

1 1 for all integers 1

1kb nk k

Page 4: Sequences

ARITHMETIC SEQUENCE

o Every term after the first is obtained from the preceding term by adding a constant numbero The difference of any two consecutive terms is

called the common difference do 5, 9, 13, 17, … d= 4

Page 5: Sequences

ARITHMETIC SEQUENCEo Let a be the first term and d be the common difference of an

arithmetic sequence. Then the sequence is a, a+d, a+2d, …a1 = first term = a = a + (1-1) da2 = second term = a + d = a + (2-1) dBy symmetryan = nth term = a + (n - 1)d for all integers n 1.

• 3, 9, 15, 21, …Here a = 3d = 9 - 3 = 6n = 20a20 = ?Since an = a + (n - 1) d;a20 = 3 + (20 - 1) 6 = 3 + 114 = 117

Page 6: Sequences

GEOMETRIC SEQUENCE

o Every term after the first is obtained from the preceding term by multiplying it with a constant number (called the common ratio “r”)is called a geometric sequence or geometric progression (G.P.).

1, 2, 4, 8, 16, … (common ratio = 2)an = nth term = arn-1; for all integers n 1a, ar, ar2, ar3, …

Page 7: Sequences

SEQUENCES IN COMPUTER PROGRAMMING

o An important data type in computer programming consists of finite sequences known as one-dimensional arrays;

o The names of k students in a class may be represented by an array of k elements “name” as:

name [0], name[1], name[2], …, name[k-1]

Page 8: Sequences

SERIESo The sum of the terms of a sequence forms a series.

– If a1, a2, a3, … represent a sequence of numbers, then the corresponding series is

– a1 + a2 + a3 + …

o Summations• =am + am+1 + am+2 + … + an.

• j is called the index of summation, running from its lower limit m to its upper limit n.

o Compute 1+4+9+16=30o =1+3+5=9

Page 9: Sequences

Summation Notation to Expanded Form

o Write expanded form of

1 ( 1) 1 ( 1) ( 1)1 2 3 4 1

1 1 1 ( 1)12 3 4 1

n

n

n

n

0 1 2 3

0

( 1) ( 1) ( 1) ( 1) ( 1) ( 1)1 0 1 1 1 2 1 3 1 1

i nn

i i n

Page 10: Sequences

Induction

o The principle of mathematical induction is a useful tool for proving that a certain predicate is true for all natural numbers.

Page 11: Sequences

Inductiono If we have a propositional function P(n), and we want

to prove that P(n) is true for any natural number n, we do the following:

1. Show that P(1) is true. (basis step)

2. Show that if P(n) then P(n + 1) for any n N. (inductive step)

3. Then P(n) must be true for any n N. (conclusion)

Page 12: Sequences

Induction

1. Basis Step: P(1) is true.For n = 1, left hand side of P(1) is the sum of all the successive integers starting at 1 and ending at 1, so LHS = 1 and RHS is

1(1 1) 2. . 12 2

R H S

( 1)( ) :1 2 32

n nP n n

Page 13: Sequences

Induction

2. Inductive Step: Suppose P(k) is true for, some integers k 1

I.

To prove P(k + 1) is true. That is,II.

( 1)1 2 32

k kk

( 1)( 2)1 2 3 ( 1)2

k kk

Page 14: Sequences

InductionConsider L.H.S. of (2)

Hence by principle of Mathematical Induction the given result true for all integers greater or equal to 1

1 2 3 ( 1) 1 2 3 ( 1)( 1) ( 1) using (1)

2

( 1) 12

2( 1)2

( 1)( 2) RHS of (2)2

k k kk k k

kk

kk

k k

Page 15: Sequences

Induction

o 1+3+5+…+(2n -1) = n2 for all integers n ≥1.o Let P(n) be the equation 1+3+5+…+(2n -1) = n2

o Show that P(1) is true.(basis step)

For n = 1, L.H.S of P(1) = 1 and R.H.S =2(1)-1 = 1 Hence the equation is true for n = 1

Page 16: Sequences

Induction

o Suppose P(k) is true for some integer k ≥ 1. (inductive step)

1 + 3 + 5 + … + (2k - 1) = k2 …………………(1)To prove P(k+1) is true; i.e.,1 + 3 + 5 + … +[2(k+1)-1] = (k+1) 2 ………….……(2)

Consider L.H.S. of (2)

Thus P(k+1) is also true. Hence by mathematical induction, the givenequation is true for all integers n ≥ 1

2

2

1 3 5 [2( 1) 1] 1 3 5 (2 1)1 3 5 (2 1) (2 1)

(2 1) using (1)

( 1)R.H.S. of (2)

k kk k

k k

k