You are on page 1of 20

Basic Structures We l e a d

Week 1:
Monday, 17th October 2022
Tuesday, 18th October 2022
Reference:
R1: Ch.2
R2: Ch.1 & 3
© 2019 McGraw-Hill Education. All rights reserved. Authorized only for instructor use in the classroom. No reproduction or further distribution permitted without
the prior written consent of McGraw-Hill Education.
Section Summary We lead

1.1 Sets
• The Language of Sets
• Set Operations
• Set Identities

1.2 Functions
• Types of Functions
• Operations on Functions
• Computability

1.3 Sequences and Summations


• Types of Sequences
• Summation Formulae

1.4 Set Cardinality


• Countable Sets

1.5 Matrices
• Matrix Arithmetic

© 2019 McGraw-Hill Education


Section 1.3

Sequences and Summations

© 2019 McGraw-Hill Education


Section 1.3
Section Summary We lead

✓ Sequences
• Examples: Geometric Progression, Arithmetic Progression
✓ Recurrence Relations
• Example: Fibonacci Sequence
✓ Summations

© 2019 McGraw-Hill Education


Section 1.3
Introduction We lead

Sequences are ordered lists of elements.


• 1, 2, 3, 5, 8 (sequence with five terms)
• 1, 3, 9, 27, 81, …….,3n , … (infinite)
Sequences arise throughout mathematics, computer science,
and in many other disciplines, ranging from botany to music.
We will introduce the terminology to represent sequences and
sums of the terms in the sequences.

© 2019 McGraw-Hill Education


Section 1.3
Sequences We lead

Definition: A sequence is a function from a subset of the integers


(usually either the set {0, 1, 2, 3, 4, …..} or {1, 2, 3, 4, ….}) to a set S.

The notation an is used to denote the image of the integer n. We


can think of an as the equivalent of f(n) where f is a function from
{0,1,2,…..} to S. We call an a term of the sequence.

© 2019 McGraw-Hill Education


Section 1.3
Sequences We lead

Example: Consider the sequence an where;

1
an = an  = a1 , a2 , a3 ...
n
1 1 1
1, , ,
2 3 4

© 2019 McGraw-Hill Education


Section 1.3
Geometric Progression We lead

Definition: A geometric progression is a sequence of the form:

where the initial term a and the common ratio r are real numbers.
Examples :
1. Let a = 1and r = −1. Then :
bn  = b0 , b1 , b2 , b3 , b4 ,... = 1, − 1, 1, − 1, 1,...
2. Let a = 2 and r = 5. Then :
cn  = c0 , c1 , c2 , c3 , c4 ,... = 2, 10, 50, 250, 1250,...
3. Let a = 6 and r = 1/ 3. Then :
 2 2 2 
d n  = d0 , d1 , d 2 , d3 , d 4 ,... = 6, 2, , , ,...
 3 9 27 
© 2019 McGraw-Hill Education
Section 1.3
Arithmetic Progression We lead

Definition: A 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. Examples :
1. Let a = −1and d = 4 :
sn  = s0 , s1 , s2 , s3 , s4 ,... = 1, −{-1, 1, 1,...
1,7,−11,..}
1, 3,
2. Let a = 7 and d = −3 :
tn  = t0 , t1 , t2 , t3 , t4 ,... = 7, 4, 1, − 2, − 5,...
3. Let a = 1and d = 2 :
un  = u0 , u1 , u2 , u3 , u4 ,... = 1, 3, 5, 7, 9,...
© 2019 McGraw-Hill Education
Section 1.3
Strings We lead

Definition: A string is a finite sequence of characters from a


finite set (an alphabet).
Sequences of characters or bits are important in computer
science.
The empty string is represented by λ (is the string that has no
terms, empty string has length zero).
The string abcde has length 5.

© 2019 McGraw-Hill Education


Section 1.3
Recurrence Relations We lead

Definition: A recurrence relation for the sequence {an} is an equation


that expresses an in terms of one or more of the previous terms of
the sequence, namely, a0, a1, …, an−1, for all integers n with n ≥ n0,
where n0 is a nonnegative integer.
A sequence is called a solution of a recurrence relation if its terms
satisfy the recurrence relation.
The initial conditions for a sequence specify the terms that precede
the first term where the recurrence relation takes effect.

© 2019 McGraw-Hill Education


Section 1.3
Recurrence Relations We lead

Example 1:
Let {an} be a sequence that satisfies the recurrence relation
𝑎 n= 𝑎 n-1 + 3 for n = 1,2,3,4,…. and suppose that 𝑎0 = 2.
What are a1 , a2 and a3? [Here a0 = 2 is the initial condition.]

Solution: We see from the recurrence relation that;


a1 = a0 + 3 = 2 + 3 = 5
a2 = 5 + 3 = 8
a3 = 8 + 3 = 11

© 2019 McGraw-Hill Education


Section 1.3
Recurrence Relations We lead

Example 2:
Let {an} be a sequence that satisfies the recurrence relation an =
an-1 – an-2 for n = 2,3,4,…. and suppose that a0 = 3 and a1 = 5.
What are a2 and a3?
[Here the initial conditions are a0 = 3 and a1 = 5. ]

Solution: We see from the recurrence relation that;

a2 = a1 − a0 = 5 − 3 = 2
a3 = a2 − a1 = 2 − 5 = −3

© 2019 McGraw-Hill Education


Section 1.3
Fibonacci Sequence We lead

Definition: Define the Fibonacci sequence, f0 ,f1 ,f2,…, by:


• Initial Conditions: f0 = 0, f1 = 1
• Recurrence Relation: fn = fn−1 + fn−2 The Fibonacci sequence, also known
as Fibonacci numbers, is defined as
the sequence of numbers in which
Example: Find f2 , f3 , f4 , f5 and f6 . each number in the sequence is equal
to the sum of two numbers before it.

© 2019 McGraw-Hill Education


Section 1.3
Solving Recurrence Relations We lead

Finding a formula for the nth term of the sequence generated by


a recurrence relation is called solving the recurrence relation.

Such a formula is called a closed formula.

Various methods for solving recurrence


relations will be covered in Chapter 8
where recurrence relations will be
studied in greater depth.

© 2019 McGraw-Hill Education


Section 1.3
Solving Recurrence Relations We lead

Method 1: Working upward, forward substitution. Let {an} be a sequence


that satisfies the recurrence relation an = an−1 + 3 for n = 2, 3, 4, ….
and suppose that a1 = 2.
Solution:
a2 = 2 + 3

Answer: 𝟐 + 𝟑(𝒏 − 𝟏)
© 2019 McGraw-Hill Education
Section 1.3
Solving Recurrence Relations We lead

Method 1: Working downward, backward substitution. Let {an} be a


sequence that satisfies the recurrence relation an = an−1 + 3 for n = 2, 3, 4, ….
and suppose that a1 = 2.
Solution:
an = an−1 + 3 Final term
an-1 = an−2 + 3 + 3
an-2 = an−3 + 3 + 3 + 3

a3 = a2 + 3

Answer: 𝟐 + 𝟑(𝒏 − 𝟏)
© 2019 McGraw-Hill Education
Section 1.3
Summations We lead

Sum of the terms am , am + 1,..., an


from the sequence an 
The notation:
n

a  
n
j j =m
aj m  j n
aj
j =m

represents
am + am +1 +  + an

The variable j is called the index of summation. It runs


through all the integers starting with its lower limit m
and ending with its upper limit n.
© 2019 McGraw-Hill Education
Section 1.3
Summations We lead

More generally for a set S :


 js
aj
Examples:
n
r + r + r + r +  + r =  r
0 1 2 3 n j

0

1 1 1 1
1 + + + +  = 
2 3 4 1 i

If S = 2,5, 7,10 then a


js
j = a2 + a5 + a7 + a10

© 2019 McGraw-Hill Education


Some Useful Summation Formulae
TABLE 2 Some Useful Summation Formulae.
Sum Closed Form Geometric Series:
n
ar n +1 − a We just proved this.
 ar ( r  0 )
k =0
k

r −1
, r 1
n
n ( n + 1)
k
k =1 2
Later we will
n
n ( n + 1)( 2n + 1)
prove some
k2
k =1 6
of these by
induction.
n 2 ( n + 1)
n 2

k 3

k =1 4

1
 ,| x |< 1
x k

1− x
k =0
Proof in text

1
 kx
k =0
k −1
,| x |< 1
(1 − x )
2
(requires calculus)

© 2019 McGraw-Hill Education

You might also like