69
ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & King Fahd University of Petroleum & Minerals Minerals Information & Computer Science Department Information & Computer Science Department

ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Embed Size (px)

Citation preview

Page 1: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

ICS 253: Discrete Structures I

Basic Structures: Sets, Functions, Sequences and Sums

King Fahd University of Petroleum & MineralsKing Fahd University of Petroleum & Minerals

Information & Computer Science DepartmentInformation & Computer Science Department

Page 2: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Reading Assignment• K. H. Rosen,

Discrete Mathematics and Its Applications, 6th Ed., McGraw-Hill, 2006. • Chapter 2

2

Page 3: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Introduction• Many important discrete structures are built using sets.

• For example: combinations used extensively in counting, relations, graphs and finite state machines.

• Functions play important roles throughout discrete mathematics. • For example, they are used to represent the computational complexity

of algorithms, to study the size of sets, to count objects, etc.• Sequences and strings are special types of functions.

• We will introduce some important types of sequences, and will address the problem of identifying a pattern for the terms of a sequence from its first few terms.

• Using the notion of a sequence, we will define what it means for a set to be countable.

• Adding consecutive terms of a sequence, making a sum, will prove to be helpful in many discrete structures applications.

3

Page 4: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Section 2.1: Sets

• A Set is an unordered collection of “objects”.• Defined by Cantor 1895• Objects in a set are also called elements or members of a

set.• Example: A set of vowels, V= {a, e, i, o, u}• Bertrand Russel in 1902 showed that this definition may

lead to paradoxes.• A paradox means a logical inconsistency.• Paradoxes occur if no “restriction” is made on the

objects of a set• Q38 pp. 121: Russel’s Paradox: Let S contain all sets x

where x does not belong to itself, i.e. S = { x | x x}. Show that S is not well-defined by showing that both SS and SS lead to a contradiction

4

Page 5: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Examples

• Q1(a) pp 119: List the members of these sets.

a) {x | x is a real number such that x2 = 1}

• Q2 (b,c) pp 119: Use set builder notation to give a description of each of these sets.

b) {-3, -2, -1,0,1,2, 3}

c) {m,n,o,p}

5

Page 6: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Some Notations and Preliminaries

• ℕ = {0,1,2,…} set of natural numbers• ℤ = {…, -2, -1, 0, 1, 2, …} set of integers• ℝ: set of real numbers• ℚ: set of rational numbers• Two sets are equal if and only if they have the

same elements.• i.e. order and repetitions are irrelevant.

• The set A is a subset of B if and only if every element of A is also an element of B, denoted by A B.• i.e. x(xA xB)• Prove that S for all sets S

6

Page 7: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Venn Diagrams

• Used to graphically represent sets

• Universal set is represented by a rectangle, all other subsets are represented by circles and/or other geometric shapes.

• Q#12 pp.120: Use a Venn diagram to illustrate the relationship A B and B C.

7

Page 8: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

More Preliminaries

• Theorem 1: For every set S S• S S

Proof:

• Proper Subset

8

Page 9: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Examples

• Q5 pp 119: For each of the following sets, determine whether 2 is an element of that set.a) {xℝ | x is an integer greater than 1}

b) {xℝ | x is the square of an integer}

c) {2,{2}}

d) {{2},{{2}}}

e) {{2},{2,{2}}}

f) {{{2}}}

9

Page 10: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

More Preliminaries• Definition: Let S be a set. If there are exactly

n distinct elements in S, where n is a non-negative integer, we say that S is a finite set of cardinality n, denoted by |S|=n. Otherwise, the set is infinite.• What is the cardinality of the set of vowels in the

English language?

• Given a set S, the power set of S is the set of all subsets of the set S, and is denoted by P(S).• If |S|=n, |P(S)|=2n elements

10

Page 11: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Examples

• What is the power set of • {1,2}• {}• {{1,2}}

• What is the cardinality of each of the following sets• {a}• {{a}}• {a,a,a,a}• {a,{a},{a,{a}}}

11

Page 12: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Cartesian Products

• The ordered n-tuple (a1, a2,…, an) is the ordered collection that has a1 as its first element, a2 as its second element, …, an as its nth element.

• Two ordered tuples (a1, a2,…,am) and (b1, b2,…, bn) are said to be equal if and only if 1. m = n and

2. ai= bi for 1 i n.

• An ordered 2-tuple is called an ordered pair.

• The Cartesian product of the sets A1, A2, …, An, denoted by A1 A2 … An is the set of ordered n-tuples (a1, a2,…, an), where ai belongs to Ai, for i=1,2,…, n.

12

Page 13: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Examples

• What is the Cartesian product of A={1,2}, B={3,4} and C={5}?

• Q23 pp 120: Let A={a, b, c, d} and B={y, z}. Find a) A B b) B A

13

Page 14: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Using Set Notation with QuantifiersxS (P(x)) is shorthand for x(xS P(x)).

• Similarly, xS (P(x)) is shorthand for ……………

• Note that x P(x) is true over the domain U if and only if the truth set of P is the set U.

• Likewise, x P(x) is true over the domain U if and only if the truth set of P is nonempty.

14

Truth Sets of Quantifiers

Page 15: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Examples

• Q33 pp120: Translate each of these quantifications into English and determine its truth value.

a) xℝ (x2 – 1) b) xℤ (x2 = 2)

c) xℤ (x2 > 0) d) xℝ (x2 = x)

15

Page 16: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Examples

• Q35 pp120: Find the truth set of each of these predicates where the domain is the set of integers, :ℤa) P(x): “x2 < 3” b) Q(x): “x2 > x”

c) R(x): “2x + 1 = 0”

16

Page 17: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Section 2.2: Set Operations• Let A and B be sets.

• The union of the sets A and B, denoted by AB, is the set that contains those elements that are either in A or in B, or in both.

• The intersection of the sets A and B, denoted by AB, is the set containing those elements in both A and B.

• A and B are called disjoint sets if their intersection is the empty set.

• The difference of A and B, denoted by A B, is the set containing those elements that are in A but not in B.• The difference of A and B is also called the complement of B

with respect to A.

17

Page 18: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Complement of a Set

• Let U be the universal set. The complement of the set A, denoted by A, is the complement of A with respect to U, i.e. U A.

• Question 4 page 95: Let A={a,b,c,d,e} and B={a,b,c,d,e,f,g,h}. Find:• A B• A B• A B• B A

18

Page 19: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Example

• Q32 pp 131: The symmetric difference of A and B, denoted by A B, is the set containing those elements in either A or B, but not in both A and B.

Find the symmetric difference of { 1, 3, 5} and {1, 2, 3}.

19

Page 20: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Cardinality of Some Set Operations

• Given finite sets A and B,

|AB| = |A| + |B| – |A B|.

• Can you come up with a law for the |A – B|?

20

Page 21: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Set IdentitiesIdentityLaws

DominationLaws

IdempotentLaws

Complementation Law

CommutativeLaws

21

A U A A A A U U A A A A A A A

A A

A B B A A B B A

Page 22: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Set Identities (Cont.)

AssociativeLaws

DistributiveLaws

De Morgan’sLaws

Absorption Laws

ComplementLaws

22

A B C A B C

A B C A B C

A B C A B A C

A B C A B A C

A B A B

A B A B

A A B A A B A

A A U

A A

Page 23: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Set Identities Verification

• Prove that • Using the definitions• Using membership tables

BAB A

23

Page 24: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Examples

• Q30 pp 131: Can we conclude that A = B if A, B and C are sets such that

1. A C = B C ?

2. A C = B C ?

24

Page 25: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Generalized Union and Intersection

• The union of a collection of sets is the set that contains those elements that are members of at least one set in the collection.

• The intersection of a collection of sets is the set that contains those elements that are members of all the sets in the collection.

25

Page 26: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Examples

26

• Q47 pp 131: Let Ai be the set of all nonempty bit strings (i.e. bit strings of length at least one) of length not exceeding i. Find

1.

2.

1

1

n

ii

n

ii

A

A

Page 27: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Computer Representation of Sets• Although sets are unordered, representing the universal

set in a specific order in computers has a lot of advantages• U must be finite, with number of elements not exceeding

available memory• The members of U are given an arbitrary order, i.e. {a1, a2, …, an}

• Any subset A of U is represented with a n-bit string S, where n=|U|, such that for each element e U at position j:• If e A then Sj=1 else Sj=0• What is the representation of U and ?• What is the intersection, union, difference?

27

Page 28: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Example

• Q55 (a,c) pp 132: Show how bitwise operations on bit strings can be used to find these combinations of A = {a, b, c, d, e}, B={b, c, d, g, p, t, v}, C = {c, e, i, 0, u, x , y, z} and D = {d, e, h, i, n, o, t, u, x, y}.

a) A B

c) (A D) (B C)

*) A B

28

Page 29: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Section 2.3: Functions• The concept of a function is important in discrete mathematics

• Sequences and strings• Algorithm efficiency in space and time• Algorithm development through recursive functions

• Let A and B be sets. A function f from A to B is an assignment of exactly one element of B to each element of A• f(a) = b

• b is the image of a and a is the preimage of b.

• f : A B (f maps A to B)• A: Domain of f.• B: Codomain of f.• Range of f: Set of all images of elements in A.

• Functions are sometimes called mappings or transformations

29

Page 30: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Examples

30

1)( xxf

Page 31: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Examples• Q5 pp 146: Find the domain and range of these

functions. Note that in each case, to find the domain, determine the set of elements assigned values by the function.a) the function that assigns to each bit string the numberof ones minus the number of zerosb) the function that assigns to each bit string twice thenumber of zeros in that stringc) the function that assigns the number of bits left overwhen a bit string is split into bytes (which are blocksof 8 bits)d) the function that assigns to each positive integer thelargest perfect square not exceeding this integer

31

Page 32: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Examples

• The domain and codomain of functions are often specified in programming languages. For instance, the Java statement

int floor(float real) { . . .}

specifies that the domain and range of the function floor are………………

32

Page 33: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Some Operations on Functions• Let f1 and f2 be functions from A to ℝ.

Then• f1 + f2 is a function from A to ℝ.

• f1f2 is a function from A to ℝ.

• Is f1/f2 a function?

• Let f be a function from set A to set B and let S be a subset of A. The image of S is a subset of B that consists of the images of the elements of S, denoted by f(S).

33

Page 34: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Some Functional Properties

• A function f is said to be one-to-one or injective if and only if f(x)=f(y) implies that x=y for all x and y in the domain of f. The function is said to be an injection.

• A function f from A to B is said to be onto or surjective if and only if for every element bB there is an element aA with f(a)=b. The function is said to be a surjection.

• A function f is called a one-to-one correspondence, or a bijection, if it is both one-to-one and onto.

34

Page 35: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Examples• Q10 and 11 pp 146: Determine whether each of

these functions from {a, b, c, d} to itself is one-to-one or onto.a) f(a) = b, f(b) = a, f(c) = c, f(d) = d

b) f(a) = b, f(b) = b, f(c) = d, f(d) = c

c) f(a) = d, f(b) = b, f(c) = c, f(d) = d

• Q12 and 13 pp 146: Determine whether each of these functions from to is one-to-one or onto.ℤ ℤa) f(n) = n – 1 b) f(n) = n2 + 1

c) f(n) = n3 d) f(n) = n/2

35

Page 36: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

More Properties

• A function f whose domain and co-domain are subsets of is called strictly increasing ℝif f(x) < f(y) whenever x < y and x and y are in the domain of f.

• A function f whose domain and co-domain are subsets of is called strictly decreasing ℝif f(x) > f(y) whenever x < y and x and y are in the domain of f.

36

Page 37: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Example• Q21 pp 147: Let f: ℝ and f(x) > 0. Show ℝ

that f(x) is strictly decreasing if and only if the function g(x) = 1/f(x) is strictly increasing.

37

Page 38: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Inverse Functions

• Let f be a 1:1 correspondence from the set A onto the set B. The inverse function of f, denoted by f -1, is the function that assigns to an element b B the unique element aA such that f(a)=b. • f –1(b)=a when f(a) = b

• Find the inverse function for each 1:1correspondence in theprevious slide.

38

Page 39: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Composition of Functions

• Let g be a function from the set A to the set B and let f be a function from the set B to the set C. The composition of the functions f and g, denoted by f g is defined by

(f g)(a) = f (g(a))

39

Page 40: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Example

• Q32 pp 147: Find f g and g f, where f(x)=x2 + 1 and g(x)=x + 2, are functions from to .ℝ ℝ

40

Page 41: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Graphs of Functions

• Let f be a function from the set A to the set B. The graph of the function f is the set of ordered pairs {(a,b) | a A and f(a) = b}

41

Page 42: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Graph of f(n)=1 – n2 from to ℤ ℤ

42

Page 43: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Some Important Functions

• The floor function assigns to the real number x the largest integer that is less than or equal to x, denoted by x.

• The ceiling function assigns to the real number x the smallest integer that is greater than or equal to x, denoted by x.

1/2 = 1/2 = -1/2 = -1/2 =• The factorial function f: ℕ ℤ+, denoted by

f(n) = n!, is the product of the first n positive integers, so f(n) = n (n – 1) … (2)(1) and f(0)=1.

43

Page 44: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Graph of f(x)= x for x in ℝ

44

Page 45: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Graph of f(x)= x for x in ℝ

45

Page 46: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Q60 pp 148: Graph of f(x)= x/2 for x in ℝ

46

Page 47: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Useful Properties of the Floor and Ceiling Functions

47

Page 48: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Example

• Prove that x + n = x + n, where x ℝand n ℤ

48

Page 49: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Section 2.4: Sequences and Summations

• 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. • We use the notation an to denote the image of the

integer n.

• We call an a term of the sequence.

• The notation {an} is used to describe the sequence

49

Page 50: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Notation

• A geometric progression is a sequence of the form

a, ar, ar 2 ,..., ar n ,...

where the initial term a and the common ratio r are real numbers.

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

50

Page 51: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Notation

• An arithmetic progression is a sequence of the form

a, a + d, a + 2d, . . . , a + n d, . . .

where the initial term a and the common difference d are real numbers.

• An arithmetic progression is a discrete analogue of the linear function ……

51

Page 52: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Examples

• Q2 pp 160: 2. What is the term a8 of the sequence {an} if an equals

a) 2n – l? b) 7?

c) 1 + (–1)n ? d) –(–2)n?

52

Page 53: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Sequence Generalization

• The problem is how to generalize a sequence from its first few terms.

• Examples• 1, 1/2, 1/4, 1/8, 1/16, …• 1, 3, 5, 7, 9, …• 1, –1, 1, –1 , 1, …• 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, …• 5, 11, 17, 23, 29, 35, 41, 47, 53, 59, …

53

Page 54: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

A Table to Memorize!

nth term First 10 terms

n2 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, ...

n3 1, 8, 27, 64, 125, 216, 343, 512, 729, 1000, ...

n4 1, 16, 81, 256, 625, 1296, 2401, 4096, 6561, 10000, ...

2n 2, 4, 8, 16, 32, 64, 128, 256 , 512, 1024, ...

3n 3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, ...

n! 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800,...

54

Page 55: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

More Examples

• 1, 7, 25, 79, 241, 727, 2185, 6559, 19681, 59047, …

• Q10 (b,c) pp 161: For each of these lists of integers, provide a simple formula or rule that generates the terms of an integer sequence that begins with the given list. Assuming that your formula or rule is correct, determine the next three terms of the sequence.b) 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, ...c) 1, 10, 11, 100, 101, 110, 111, 1000, 1001 , 1010,

1011, . . .

55

Page 56: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

b) 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, ...

c) 1, 10, 11, 100, 101, 110, 111, 1000, 1001 , 1010, 1011, . . .

56

Page 57: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Summations

57

n

mjja

n

mj ja njm ja

nmm aaa ... represent all 1

j : index of summation, can be replaced by any arbitrary variablem: lower limit n: upper limit

Important rule:

n

mjj

n

mjj

n

mjjj ybxabyax

Page 58: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Examples

• Express the sum of the first 100 terms of the sequence {an}, where an = 1/n for n = 1, 2, 3, …

58

3

1

22 sum theof value theisWhat j

j

7

2

1 sum theof value theisWhat j

j

Page 59: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Index Changes in the Summation

• Consider the summation and assume that

we want the index to start from 0 to n – 1 rather than 1 to n. How do we change the index?

59

n

j

j1

2

Page 60: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Theorem 1

• If a and r are real numbers and r 0, then

Proof

60

1if1

1if1

1

0 ran

rr

aarar

nn

j

j

Page 61: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Examples

61

4 3

1 1i j

ij

2,4,6ss

Page 62: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Some Useful Summations

62

Page 63: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

More Examples

• Find

• Let x be a real number with |x|<1. Find

• Find

63

1002

50k

k

0

n

n

x

1

1

k

k

kx

Page 64: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

More Examples

• Q10 (a) pp 161: For each of these lists of integers, provide a simple formula or rule that generates the terms of an integer sequence that begins with the given list. Assuming that your formula or rule is correct, determine the next three terms of the sequence.3, 6, 11, 18, 27, 38, 51, 66, 83, 102, ...

64

Page 65: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Cardinality

• Definition: The sets A and B have the same cardinality if and only if there is a one-to-one correspondence from A to B.

• Definition: A set that is either finite or has the same cardinality as the set of positive integers is called countable. A set that is not countable is called uncountable. When an infinite set S is countable, we denote the cardinality of S by 0

(where 0 is aleph, the first letter of the Hebrew alphabet). We write |S| = 0 and say that S has cardinality "aleph null."

65

Page 66: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Cardinality

• Question: What do we need to do to find whether a set is countable or not?

• Example 1: Show that the set of odd positive integers is a countable set.

66

Page 67: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Cardinality

• Example 2: Show that the set of all integers is countable.

67

Page 68: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Cardinality

• Example 3: Show that the set of positive rational numbers is countable.

68

Page 69: ICS 253: Discrete Structures I Basic Structures: Sets, Functions, Sequences and Sums King Fahd University of Petroleum & Minerals Information & Computer

Basic Structures: Sets, Functions, Sequences and SumsICS 253: Discrete Structures I

Cardinality

• Example 4: Show that the set of real numbers is an uncountable set.

69