You are on page 1of 60

Department Of Computer Science, CUI

Lahore Campus

CSC102 - Discrete Structures


By
Mahwish Waqas
01/07/2022 CSC102 - Discrete Structures 2

Lecture Outline

• Sequences and Summations


• What is a sequence?
• Arithmetic Sequence and Geometric Sequence
• How to determine a sequence formula?
• What is Summation?
• How to evaluate a summation?
• Shifting the index of summation
• Double Summation
01/07/2022 CSC102 - Discrete Structures 3

Sequences

• A sequence is a discrete structure used to represent


an ordered list of elements e.g. 1, 2, 3, 4, 5 and 1, 3,
9, 27, 81, ….
01/07/2022 CSC102 - Discrete Structures 4

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

• The notation denotes the image of the integer .


• : a term of the sequence
• {} : entire sequence
• Same notation as sets!
Z S

n an
01/07/2022 CSC102 - Discrete Structures 5

Sequences

• Consider the sequence {an}, where an = 1/n.


• The list of the terms of this sequence beginning with a1:
a1, a2, a3, a4, …
{1, 1/2, 1/3, 1/4 , … }

• Consider the sequence {an}, where an = 3n.


• The list of the terms of this sequence beginning with a1:
{3, 6, 9, 12 , …}
01/07/2022 CSC102 - Discrete Structures 6

Geometric Progression
•  A geometric progression is a sequence of the form

Where the initial term a and the common ratio r are


real numbers.
01/07/2022 CSC102 - Discrete Structures 7

General Term of Geometric Progression


•  Let a be the first term and r be the common ratio of a
geometric sequence. Then the sequence is

• If , for , represents the terms of the sequence then


first term
second term
third term
By symmetry
nth term for all integers .
01/07/2022 CSC102 - Discrete Structures 8

Geometric Progression (Example)


• 
• Is {} geometric progression?

• Is {} geometric progression?
01/07/2022 CSC102 - Discrete Structures 9

Geometric Progression (Example)


• 
• Is {} geometric progression?
2,10,50,250,…
Yes, a=2 and r=5

• Is {} geometric progression?
6,2,2/3,2/9,…
Yes, a=6 and r=1/3
01/07/2022 CSC102 - Discrete Structures 10

Geometric Progression (Example


•  Find the 8th term of the following geometric sequence
01/07/2022 CSC102 - Discrete Structures 11

Arithmetic Progression
• 
• An arithmetic progression is a sequence of the form

• Where the initial term a and the common difference d


are real numbers.
01/07/2022 CSC102 - Discrete Structures 12

General Term of Arithmetic Progression


•  Let a be the first term and d be the common difference of
an arithmetic sequence. Then the sequence is

• If , for , represents the terms of the sequence then


first term
second term
third term
By symmetry
nth termfor all integers .
01/07/2022 CSC102 - Discrete Structures 13

Arithmetic Progression (Example)


• 
• Is Arithmetic progression?

• Is Arithmetic progression?
01/07/2022 CSC102 - Discrete Structures 14

Arithmetic Progression (Example)


• 
• Is Arithmetic progression?
-1,3,7,11,…
Yes, a=-1 and d=4

• Is Arithmetic progression?
7,4,1,-2,…
Yes, a=7 and d=-3
01/07/2022 CSC102 - Discrete Structures 15

Arithmetic Progression (Example)


•  Find the 20th term of the arithmetic sequence
01/07/2022 CSC102 - Discrete Structures 16

Arithmetic Progression (Example)


•  Which term of the arithmetic sequence
01/07/2022 CSC102 - Discrete Structures 17

Determining the Sequence Formula


• Given values in a sequence, how do you determine the
formula?
• Steps to consider:
• Is it an arithmetic progression (each term a constant
amount from the last)?
• Is it a geometric progression (each term a factor of the
previous term)?
• Does the sequence repeat itself (or cycle)?
• Does the sequence combine previous terms?
• Are there runs of the same value?
01/07/2022 CSC102 - Discrete Structures 18

Sequences (Example)
• 
• Find a formula for the following sequence.
01/07/2022 CSC102 - Discrete Structures 19

Sequences (Example)
• 
• Find a formula for the following sequence.

Solution:

The sequence alternates 1’s and 0’s, increasing the


number of 1’s and 0’s each time.
01/07/2022 CSC102 - Discrete Structures 20

Sequences (Example)
• 
• Find a formula for the following sequence.
01/07/2022 CSC102 - Discrete Structures 21

Sequences (Example)
• 
• Find a formula for the following sequence.

Solution:

It is a geometric progression.
a=1 and r=1/2
01/07/2022 CSC102 - Discrete Structures 22

Sequences (Example)
•  Find formula for the following sequence.
01/07/2022 CSC102 - Discrete Structures 23

Sequences (Example)
•  Find formula for the following sequence.

Solution:

It is a arithmetic progression.
a=1 and d=2
01/07/2022 CSC102 - Discrete Structures 24

Sequences (Example)
•  Find formula for the following sequence.
01/07/2022 CSC102 - Discrete Structures 25

Sequences (Example)
•  Find formula for the following sequence.

Solution:

It is a geometric progression.
a=1 and r=-1
01/07/2022 CSC102 - Discrete Structures 26

Sequences (Example)
• 
• How can you produce the terms of the following
sequence?
01/07/2022 CSC102 - Discrete Structures 27

Sequences (Example)
• 
• How can you produce the terms of the following
sequence?

Solution:

A rule for generating this sequence is that integer n


appears exactly n times.
01/07/2022 CSC102 - Discrete Structures 28

Sequences (Example)
• 
• How can you produce the terms of the following
sequence?
01/07/2022 CSC102 - Discrete Structures 29

Sequences (Example)
• 
• How can you produce the terms of the following
sequence?

Solution:

A rule for generating this sequence is .


It is an arithmetic progression.
a=5 and d=6
01/07/2022 CSC102 - Discrete Structures 30

Sequences (Example)
• 
• Find a formula for the following sequence.
01/07/2022 CSC102 - Discrete Structures 31

Sequences (Example)
• 
• Find a formula for the following sequence.

Solution:

Each term is less than the previous term.


01/07/2022 CSC102 - Discrete Structures 32

Useful Sequences
01/07/2022 CSC102 - Discrete Structures 33

Sequences (Example)
• 
• Find a formula for the following sequence?
01/07/2022 CSC102 - Discrete Structures 34

Sequences (Example)
• 
• Find a formula for the following sequence?

Solution:

Each term is twice the cube of .


01/07/2022 CSC102 - Discrete Structures 35

Sequences (Example)
•  Find formula for the following sequence.
01/07/2022 CSC102 - Discrete Structures 36

Sequences (Example)
•  Find formula for the following sequence.

Solution:

Compare it to .
01/07/2022 CSC102 - Discrete Structures 37

Summations
01/07/2022 CSC102 - Discrete Structures 38

Summations
•  The sum of the terms from the sequence {} is:

• where donates summation and j is the index of


summation.

• m is lower limit and n is upper limit.


01/07/2022 CSC102 - Discrete Structures 39

Summations
•  A summation:

is like a for loop:

int sum = 0;
for ( int j = m; j <= n; j++ )
sum += a(j);
01/07/2022 CSC102 - Discrete Structures 40

Summations (Example)

Express the sum of the first 100 terms of the sequence


{1/n} for n=1,2,3,… .
01/07/2022 CSC102 - Discrete Structures 41

Summations (Example)
• 
Express the sum of the first 100 terms of the sequence
{1/n} for n=1,2,3,… .

Solution:
01/07/2022 CSC102 - Discrete Structures 42

Summations (Example)
• 
What is the value of ?
01/07/2022 CSC102 - Discrete Structures 43

Summations (Example)
• 
What is the value of ?

Solution:
01/07/2022 CSC102 - Discrete Structures 44

More Summations (Example)


• 
01/07/2022 CSC102 - Discrete Structures 45

More Summations (Example)


•Evaluate
 
01/07/2022 CSC102 - Discrete Structures 46

More Summations (Example)


 
•Evaluate

Solution:
01/07/2022 CSC102 - Discrete Structures 47

Shifting the Index of Summation


•  Useful in case of sum.

• shift the index of summation from 0 to 4 rather than from


1 to 5.
01/07/2022 CSC102 - Discrete Structures 48

Shifting the Index of Summation


•  shift the index of summation from 0 to 4 rather than from
1 to 5. to do this,
01/07/2022 CSC102 - Discrete Structures 49

Properties of Summations
01/07/2022 CSC102 - Discrete Structures 50

Example
• 
01/07/2022 CSC102 - Discrete Structures 51

Example
01/07/2022 CSC102 - Discrete Structures 52

Double Summations
•  Like a nested for loop

Is equivalent to:
int sum = 0;
for ( int i = 1; i <= 4; i++ )
for ( int j = 1; j <= 3; j++ )
sum += i*j;
01/07/2022 CSC102 - Discrete Structures 53

Double Summations
• 
01/07/2022 CSC102 - Discrete Structures 54

Double Summations
• 
• Solution:
01/07/2022 CSC102 - Discrete Structures 55

Example
•.  
01/07/2022 CSC102 - Discrete Structures 56

Some Useful Summations


01/07/2022 CSC102 - Discrete Structures 57

Example

 
Find
01/07/2022 CSC102 - Discrete Structures 58

Example

 
Find
01/07/2022 CSC102 - Discrete Structures 59

Example
 
Find .
 
Find .
01/07/2022 CSC102 - Discrete Structures 60

Exercise Questions

Chapter # 2
Topic # 2.4
Questions 1, 2, 4, 25, 26, 29, 30,31, 32, 33, 34, 39, 40

You might also like