Discrete Mathematics & Mathematical Reasoning Basic Structures: - - PowerPoint PPT Presentation

discrete mathematics mathematical reasoning basic
SMART_READER_LITE
LIVE PREVIEW

Discrete Mathematics & Mathematical Reasoning Basic Structures: - - PowerPoint PPT Presentation

Discrete Mathematics & Mathematical Reasoning Basic Structures: Sets, Functions, Relations, Sequences and Sums Colin Stirling Informatics Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 1 / 38 Sets A set is an


slide-1
SLIDE 1

Discrete Mathematics & Mathematical Reasoning Basic Structures: Sets, Functions, Relations, Sequences and Sums

Colin Stirling

Informatics

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 1 / 38

slide-2
SLIDE 2

Sets

A set is an unordered collection of elements

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 2 / 38

slide-3
SLIDE 3

Sets

A set is an unordered collection of elements A = {3, 2, 1, 0} = {1, 2, 0, 3}

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 2 / 38

slide-4
SLIDE 4

Sets

A set is an unordered collection of elements A = {3, 2, 1, 0} = {1, 2, 0, 3} Membership 3 ∈ A Non-membership 5 ∈ A

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 2 / 38

slide-5
SLIDE 5

Sets

A set is an unordered collection of elements A = {3, 2, 1, 0} = {1, 2, 0, 3} Membership 3 ∈ A Non-membership 5 ∈ A Emptyset ∅ = { }

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 2 / 38

slide-6
SLIDE 6

Some important sets (boldface in the textbook)

B = {true, false} Boolean values

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 3 / 38

slide-7
SLIDE 7

Some important sets (boldface in the textbook)

B = {true, false} Boolean values N = {0, 1, 2, 3, . . . } Natural numbers

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 3 / 38

slide-8
SLIDE 8

Some important sets (boldface in the textbook)

B = {true, false} Boolean values N = {0, 1, 2, 3, . . . } Natural numbers Z = {. . . , −3, −2, −1, 0, 1, 2, 3, . . . } Integers

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 3 / 38

slide-9
SLIDE 9

Some important sets (boldface in the textbook)

B = {true, false} Boolean values N = {0, 1, 2, 3, . . . } Natural numbers Z = {. . . , −3, −2, −1, 0, 1, 2, 3, . . . } Integers Z+ = {1, 2, 3, . . . } Positive integers

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 3 / 38

slide-10
SLIDE 10

Some important sets (boldface in the textbook)

B = {true, false} Boolean values N = {0, 1, 2, 3, . . . } Natural numbers Z = {. . . , −3, −2, −1, 0, 1, 2, 3, . . . } Integers Z+ = {1, 2, 3, . . . } Positive integers R Real numbers

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 3 / 38

slide-11
SLIDE 11

Some important sets (boldface in the textbook)

B = {true, false} Boolean values N = {0, 1, 2, 3, . . . } Natural numbers Z = {. . . , −3, −2, −1, 0, 1, 2, 3, . . . } Integers Z+ = {1, 2, 3, . . . } Positive integers R Real numbers R+ Positive real numbers

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 3 / 38

slide-12
SLIDE 12

Some important sets (boldface in the textbook)

B = {true, false} Boolean values N = {0, 1, 2, 3, . . . } Natural numbers Z = {. . . , −3, −2, −1, 0, 1, 2, 3, . . . } Integers Z+ = {1, 2, 3, . . . } Positive integers R Real numbers R+ Positive real numbers Q Rational numbers

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 3 / 38

slide-13
SLIDE 13

Some important sets (boldface in the textbook)

B = {true, false} Boolean values N = {0, 1, 2, 3, . . . } Natural numbers Z = {. . . , −3, −2, −1, 0, 1, 2, 3, . . . } Integers Z+ = {1, 2, 3, . . . } Positive integers R Real numbers R+ Positive real numbers Q Rational numbers C Complex numbers

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 3 / 38

slide-14
SLIDE 14

Sets defined using comprehension

S = {x | P(x) } where P(x) is a predicate

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 4 / 38

slide-15
SLIDE 15

Sets defined using comprehension

S = {x | P(x) } where P(x) is a predicate {x | x ∈ N ∧ 2 divides x} = {2m | m ≥ 0}

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 4 / 38

slide-16
SLIDE 16

Sets defined using comprehension

S = {x | P(x) } where P(x) is a predicate {x | x ∈ N ∧ 2 divides x} = {2m | m ≥ 0} Subsets of sets upon which an order is defined [a, b] = {x | a ≤ x ≤ b} closed interval [a, b) = {x | a ≤ x < b} (a, b] = {x | a < x ≤ b} (a, b) = {x | a < x < b}

  • pen interval

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 4 / 38

slide-17
SLIDE 17

Notation

A ∪ B union; A ∩ B intersection; A − B difference

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 5 / 38

slide-18
SLIDE 18

Notation

A ∪ B union; A ∩ B intersection; A − B difference If Ai are sets for all i ∈ I then

i∈I Ai and i∈I Ai are sets

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 5 / 38

slide-19
SLIDE 19

Notation

A ∪ B union; A ∩ B intersection; A − B difference If Ai are sets for all i ∈ I then

i∈I Ai and i∈I Ai are sets

A ⊆ B subset; A ⊇ B superset

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 5 / 38

slide-20
SLIDE 20

Notation

A ∪ B union; A ∩ B intersection; A − B difference If Ai are sets for all i ∈ I then

i∈I Ai and i∈I Ai are sets

A ⊆ B subset; A ⊇ B superset A = B set equality

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 5 / 38

slide-21
SLIDE 21

Notation

A ∪ B union; A ∩ B intersection; A − B difference If Ai are sets for all i ∈ I then

i∈I Ai and i∈I Ai are sets

A ⊆ B subset; A ⊇ B superset A = B set equality P(A) powerset (set of all subsets of A); also 2A

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 5 / 38

slide-22
SLIDE 22

Notation

A ∪ B union; A ∩ B intersection; A − B difference If Ai are sets for all i ∈ I then

i∈I Ai and i∈I Ai are sets

A ⊆ B subset; A ⊇ B superset A = B set equality P(A) powerset (set of all subsets of A); also 2A |A| cardinality

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 5 / 38

slide-23
SLIDE 23

Notation

A ∪ B union; A ∩ B intersection; A − B difference If Ai are sets for all i ∈ I then

i∈I Ai and i∈I Ai are sets

A ⊆ B subset; A ⊇ B superset A = B set equality P(A) powerset (set of all subsets of A); also 2A |A| cardinality A × B cartesian product (tuple sets)

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 5 / 38

slide-24
SLIDE 24

A proper mathematical definition of set is complicated (Russell’s paradox)

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 6 / 38

slide-25
SLIDE 25

A proper mathematical definition of set is complicated (Russell’s paradox)

The set of cats is not a cat (is not a member of itself)

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 6 / 38

slide-26
SLIDE 26

A proper mathematical definition of set is complicated (Russell’s paradox)

The set of cats is not a cat (is not a member of itself) The set of non-cats (all things that are not cats) is a member of itself

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 6 / 38

slide-27
SLIDE 27

A proper mathematical definition of set is complicated (Russell’s paradox)

The set of cats is not a cat (is not a member of itself) The set of non-cats (all things that are not cats) is a member of itself Let S be the set of all sets which are not members of themselves

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 6 / 38

slide-28
SLIDE 28

A proper mathematical definition of set is complicated (Russell’s paradox)

The set of cats is not a cat (is not a member of itself) The set of non-cats (all things that are not cats) is a member of itself Let S be the set of all sets which are not members of themselves S = {x | x ∈ x} (using naive comprehension)

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 6 / 38

slide-29
SLIDE 29

A proper mathematical definition of set is complicated (Russell’s paradox)

The set of cats is not a cat (is not a member of itself) The set of non-cats (all things that are not cats) is a member of itself Let S be the set of all sets which are not members of themselves S = {x | x ∈ x} (using naive comprehension) Question: is S a member of itself (S ∈ S) ?

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 6 / 38

slide-30
SLIDE 30

A proper mathematical definition of set is complicated (Russell’s paradox)

The set of cats is not a cat (is not a member of itself) The set of non-cats (all things that are not cats) is a member of itself Let S be the set of all sets which are not members of themselves S = {x | x ∈ x} (using naive comprehension) Question: is S a member of itself (S ∈ S) ? S ∈ S provided that S ∈ S; S ∈ S provided that S ∈ S

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 6 / 38

slide-31
SLIDE 31

A proper mathematical definition of set is complicated (Russell’s paradox)

The set of cats is not a cat (is not a member of itself) The set of non-cats (all things that are not cats) is a member of itself Let S be the set of all sets which are not members of themselves S = {x | x ∈ x} (using naive comprehension) Question: is S a member of itself (S ∈ S) ? S ∈ S provided that S ∈ S; S ∈ S provided that S ∈ S Modern formulations (such as Zermelo-Fraenkel set theory) restrict comprehension. (However, it is impossible to prove in ZF that ZF is consistent unless ZF is inconsistent.)

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 6 / 38

slide-32
SLIDE 32

Functions

Assume A and B are non-empty sets

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 7 / 38

slide-33
SLIDE 33

Functions

Assume A and B are non-empty sets A function f from A to B is an assignment of exactly one element

  • f B to each element of A

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 7 / 38

slide-34
SLIDE 34

Functions

Assume A and B are non-empty sets A function f from A to B is an assignment of exactly one element

  • f B to each element of A

f(a) = b if f assigns b to a

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 7 / 38

slide-35
SLIDE 35

Functions

Assume A and B are non-empty sets A function f from A to B is an assignment of exactly one element

  • f B to each element of A

f(a) = b if f assigns b to a f : A → B if f is a function from A to B

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 7 / 38

slide-36
SLIDE 36

One-to-one or injective functions

Definition

f : A → B is injective iff ∀a, c ∈ A (if f(a) = f(c) then a = c)

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 8 / 38

slide-37
SLIDE 37

One-to-one or injective functions

Definition

f : A → B is injective iff ∀a, c ∈ A (if f(a) = f(c) then a = c) Is the identity function ιA : A → A injective?

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 8 / 38

slide-38
SLIDE 38

One-to-one or injective functions

Definition

f : A → B is injective iff ∀a, c ∈ A (if f(a) = f(c) then a = c) Is the identity function ιA : A → A injective? YES

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 8 / 38

slide-39
SLIDE 39

One-to-one or injective functions

Definition

f : A → B is injective iff ∀a, c ∈ A (if f(a) = f(c) then a = c) Is the identity function ιA : A → A injective? YES Is the function √· : Z+ → R+ injective?

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 8 / 38

slide-40
SLIDE 40

One-to-one or injective functions

Definition

f : A → B is injective iff ∀a, c ∈ A (if f(a) = f(c) then a = c) Is the identity function ιA : A → A injective? YES Is the function √· : Z+ → R+ injective? YES

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 8 / 38

slide-41
SLIDE 41

One-to-one or injective functions

Definition

f : A → B is injective iff ∀a, c ∈ A (if f(a) = f(c) then a = c) Is the identity function ιA : A → A injective? YES Is the function √· : Z+ → R+ injective? YES Is the squaring function ·2 : Z → Z injective?

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 8 / 38

slide-42
SLIDE 42

One-to-one or injective functions

Definition

f : A → B is injective iff ∀a, c ∈ A (if f(a) = f(c) then a = c) Is the identity function ιA : A → A injective? YES Is the function √· : Z+ → R+ injective? YES Is the squaring function ·2 : Z → Z injective? NO

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 8 / 38

slide-43
SLIDE 43

One-to-one or injective functions

Definition

f : A → B is injective iff ∀a, c ∈ A (if f(a) = f(c) then a = c) Is the identity function ιA : A → A injective? YES Is the function √· : Z+ → R+ injective? YES Is the squaring function ·2 : Z → Z injective? NO Is the function | · | : R → R injective?

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 8 / 38

slide-44
SLIDE 44

One-to-one or injective functions

Definition

f : A → B is injective iff ∀a, c ∈ A (if f(a) = f(c) then a = c) Is the identity function ιA : A → A injective? YES Is the function √· : Z+ → R+ injective? YES Is the squaring function ·2 : Z → Z injective? NO Is the function | · | : R → R injective? NO

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 8 / 38

slide-45
SLIDE 45

One-to-one or injective functions

Definition

f : A → B is injective iff ∀a, c ∈ A (if f(a) = f(c) then a = c) Is the identity function ιA : A → A injective? YES Is the function √· : Z+ → R+ injective? YES Is the squaring function ·2 : Z → Z injective? NO Is the function | · | : R → R injective? NO Assume m > 1. Is mod m : Z → {0, . . . , m − 1} injective?

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 8 / 38

slide-46
SLIDE 46

One-to-one or injective functions

Definition

f : A → B is injective iff ∀a, c ∈ A (if f(a) = f(c) then a = c) Is the identity function ιA : A → A injective? YES Is the function √· : Z+ → R+ injective? YES Is the squaring function ·2 : Z → Z injective? NO Is the function | · | : R → R injective? NO Assume m > 1. Is mod m : Z → {0, . . . , m − 1} injective? NO

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 8 / 38

slide-47
SLIDE 47

Onto or surjective functions

Definition

f : A → B is surjective iff ∀b ∈ B ∃a ∈ A (f(a) = b)

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 9 / 38

slide-48
SLIDE 48

Onto or surjective functions

Definition

f : A → B is surjective iff ∀b ∈ B ∃a ∈ A (f(a) = b) Is the identity function ιA : A → A surjective?

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 9 / 38

slide-49
SLIDE 49

Onto or surjective functions

Definition

f : A → B is surjective iff ∀b ∈ B ∃a ∈ A (f(a) = b) Is the identity function ιA : A → A surjective? YES

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 9 / 38

slide-50
SLIDE 50

Onto or surjective functions

Definition

f : A → B is surjective iff ∀b ∈ B ∃a ∈ A (f(a) = b) Is the identity function ιA : A → A surjective? YES Is the function √· : Z+ → R+ surjective?

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 9 / 38

slide-51
SLIDE 51

Onto or surjective functions

Definition

f : A → B is surjective iff ∀b ∈ B ∃a ∈ A (f(a) = b) Is the identity function ιA : A → A surjective? YES Is the function √· : Z+ → R+ surjective? NO

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 9 / 38

slide-52
SLIDE 52

Onto or surjective functions

Definition

f : A → B is surjective iff ∀b ∈ B ∃a ∈ A (f(a) = b) Is the identity function ιA : A → A surjective? YES Is the function √· : Z+ → R+ surjective? NO Is the function ·2 : Z → Z surjective?

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 9 / 38

slide-53
SLIDE 53

Onto or surjective functions

Definition

f : A → B is surjective iff ∀b ∈ B ∃a ∈ A (f(a) = b) Is the identity function ιA : A → A surjective? YES Is the function √· : Z+ → R+ surjective? NO Is the function ·2 : Z → Z surjective? NO

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 9 / 38

slide-54
SLIDE 54

Onto or surjective functions

Definition

f : A → B is surjective iff ∀b ∈ B ∃a ∈ A (f(a) = b) Is the identity function ιA : A → A surjective? YES Is the function √· : Z+ → R+ surjective? NO Is the function ·2 : Z → Z surjective? NO Is the function | · | : R → R surjective?

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 9 / 38

slide-55
SLIDE 55

Onto or surjective functions

Definition

f : A → B is surjective iff ∀b ∈ B ∃a ∈ A (f(a) = b) Is the identity function ιA : A → A surjective? YES Is the function √· : Z+ → R+ surjective? NO Is the function ·2 : Z → Z surjective? NO Is the function | · | : R → R surjective? NO

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 9 / 38

slide-56
SLIDE 56

Onto or surjective functions

Definition

f : A → B is surjective iff ∀b ∈ B ∃a ∈ A (f(a) = b) Is the identity function ιA : A → A surjective? YES Is the function √· : Z+ → R+ surjective? NO Is the function ·2 : Z → Z surjective? NO Is the function | · | : R → R surjective? NO Assume m > 1. Is mod m : Z → {0, . . . , m − 1} surjective?

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 9 / 38

slide-57
SLIDE 57

Onto or surjective functions

Definition

f : A → B is surjective iff ∀b ∈ B ∃a ∈ A (f(a) = b) Is the identity function ιA : A → A surjective? YES Is the function √· : Z+ → R+ surjective? NO Is the function ·2 : Z → Z surjective? NO Is the function | · | : R → R surjective? NO Assume m > 1. Is mod m : Z → {0, . . . , m − 1} surjective? YES

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 9 / 38

slide-58
SLIDE 58

One-to-one correspondence or bijection

Definition

f : A → B is a bijection iff it is both injective and surjective

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 10 / 38

slide-59
SLIDE 59

One-to-one correspondence or bijection

Definition

f : A → B is a bijection iff it is both injective and surjective Is the identity function ιA : A → A a bijection?

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 10 / 38

slide-60
SLIDE 60

One-to-one correspondence or bijection

Definition

f : A → B is a bijection iff it is both injective and surjective Is the identity function ιA : A → A a bijection? YES

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 10 / 38

slide-61
SLIDE 61

One-to-one correspondence or bijection

Definition

f : A → B is a bijection iff it is both injective and surjective Is the identity function ιA : A → A a bijection? YES Is the function √· : R+ → R+ a bijection?

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 10 / 38

slide-62
SLIDE 62

One-to-one correspondence or bijection

Definition

f : A → B is a bijection iff it is both injective and surjective Is the identity function ιA : A → A a bijection? YES Is the function √· : R+ → R+ a bijection? YES

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 10 / 38

slide-63
SLIDE 63

One-to-one correspondence or bijection

Definition

f : A → B is a bijection iff it is both injective and surjective Is the identity function ιA : A → A a bijection? YES Is the function √· : R+ → R+ a bijection? YES Is the function ·2 : R → R a bijection?

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 10 / 38

slide-64
SLIDE 64

One-to-one correspondence or bijection

Definition

f : A → B is a bijection iff it is both injective and surjective Is the identity function ιA : A → A a bijection? YES Is the function √· : R+ → R+ a bijection? YES Is the function ·2 : R → R a bijection? NO

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 10 / 38

slide-65
SLIDE 65

One-to-one correspondence or bijection

Definition

f : A → B is a bijection iff it is both injective and surjective Is the identity function ιA : A → A a bijection? YES Is the function √· : R+ → R+ a bijection? YES Is the function ·2 : R → R a bijection? NO Is the function | · | : R → R a bijection?

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 10 / 38

slide-66
SLIDE 66

One-to-one correspondence or bijection

Definition

f : A → B is a bijection iff it is both injective and surjective Is the identity function ιA : A → A a bijection? YES Is the function √· : R+ → R+ a bijection? YES Is the function ·2 : R → R a bijection? NO Is the function | · | : R → R a bijection? NO

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 10 / 38

slide-67
SLIDE 67

Function composition

Definition

Let f : B → C and g : A → B. The composition function f ◦ g : A → C is (f ◦ g)(a) = f(g(a))

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 11 / 38

slide-68
SLIDE 68

Results about function composition

Theorem

The composition of two functions is a function

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 12 / 38

slide-69
SLIDE 69

Results about function composition

Theorem

The composition of two functions is a function

Theorem

The composition of two injective functions is an injective function

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 12 / 38

slide-70
SLIDE 70

Results about function composition

Theorem

The composition of two functions is a function

Theorem

The composition of two injective functions is an injective function

Theorem

The composition of two surjective functions is a surjective function

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 12 / 38

slide-71
SLIDE 71

Results about function composition

Theorem

The composition of two functions is a function

Theorem

The composition of two injective functions is an injective function

Theorem

The composition of two surjective functions is a surjective function

Corollary

The composition of two bijections is a bijection

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 12 / 38

slide-72
SLIDE 72

Inverse function

Definition

If f : A → B is a bijection, then the inverse of f, written f −1 : B → A is f −1(b) = a iff f(a) = b

f A B a = f –1(b) b = f(a) f(a) f –1(b) f –1 1 Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 13 / 38

slide-73
SLIDE 73

Inverse function

Definition

If f : A → B is a bijection, then the inverse of f, written f −1 : B → A is f −1(b) = a iff f(a) = b

f A B a = f –1(b) b = f(a) f(a) f –1(b) f –1 1

What is the inverse of ιA : A → A?

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 13 / 38

slide-74
SLIDE 74

Inverse function

Definition

If f : A → B is a bijection, then the inverse of f, written f −1 : B → A is f −1(b) = a iff f(a) = b

f A B a = f –1(b) b = f(a) f(a) f –1(b) f –1 1

What is the inverse of ιA : A → A? What is the inverse of √· : R+ → R+?

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 13 / 38

slide-75
SLIDE 75

Inverse function

Definition

If f : A → B is a bijection, then the inverse of f, written f −1 : B → A is f −1(b) = a iff f(a) = b

f A B a = f –1(b) b = f(a) f(a) f –1(b) f –1 1

What is the inverse of ιA : A → A? What is the inverse of √· : R+ → R+? What is f −1 ◦ f? and f ◦ f −1?

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 13 / 38

slide-76
SLIDE 76

The floor and ceiling functions

Definition

The floor function ⌊ ⌋ : R → Z is ⌊x⌋ equals the largest integer less than or equal to x

Definition

The ceiling function ⌈ ⌉ : R → Z is ⌈x⌉ equals the smallest integer greater than or equal to x

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 14 / 38

slide-77
SLIDE 77

The floor and ceiling functions

Definition

The floor function ⌊ ⌋ : R → Z is ⌊x⌋ equals the largest integer less than or equal to x

Definition

The ceiling function ⌈ ⌉ : R → Z is ⌈x⌉ equals the smallest integer greater than or equal to x 1 2

  • =
  • −1

2

  • = ⌊0⌋ = ⌈0⌉ = 0

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 14 / 38

slide-78
SLIDE 78

The floor and ceiling functions

Definition

The floor function ⌊ ⌋ : R → Z is ⌊x⌋ equals the largest integer less than or equal to x

Definition

The ceiling function ⌈ ⌉ : R → Z is ⌈x⌉ equals the smallest integer greater than or equal to x 1 2

  • =
  • −1

2

  • = ⌊0⌋ = ⌈0⌉ = 0

⌊−6.1⌋ = −7 ⌈6.1⌉ = 7

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 14 / 38

slide-79
SLIDE 79

The factorial function

Definition

The factorial function f : N → N, denoted as f(n) = n! assigns to n the product of the first n positive integers f(0) = 0! = 1 and f(n) = n! = 1 · 2 · · · · · (n − 1) · n

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 15 / 38

slide-80
SLIDE 80

Relations

Definition

A binary relation R on sets A and B is a subset R ⊆ A × B

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 16 / 38

slide-81
SLIDE 81

Relations

Definition

A binary relation R on sets A and B is a subset R ⊆ A × B R is a set of tuples (a, b) with a ∈ A and b ∈ B

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 16 / 38

slide-82
SLIDE 82

Relations

Definition

A binary relation R on sets A and B is a subset R ⊆ A × B R is a set of tuples (a, b) with a ∈ A and b ∈ B Often we write a R b for (a, b) ∈ R

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 16 / 38

slide-83
SLIDE 83

Relations

Definition

A binary relation R on sets A and B is a subset R ⊆ A × B R is a set of tuples (a, b) with a ∈ A and b ∈ B Often we write a R b for (a, b) ∈ R A function f is a restricted relation where ∀a ∈ A ∃b ∈ B (((a, b) ∈ f) ∧ ∀c ∈ B ((a, c) ∈ f → c = b))

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 16 / 38

slide-84
SLIDE 84

Relations

Definition

A binary relation R on sets A and B is a subset R ⊆ A × B R is a set of tuples (a, b) with a ∈ A and b ∈ B Often we write a R b for (a, b) ∈ R A function f is a restricted relation where ∀a ∈ A ∃b ∈ B (((a, b) ∈ f) ∧ ∀c ∈ B ((a, c) ∈ f → c = b)) R is a relation on A if B = A (so, R ⊆ A × A)

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 16 / 38

slide-85
SLIDE 85

Relations

Definition

A binary relation R on sets A and B is a subset R ⊆ A × B R is a set of tuples (a, b) with a ∈ A and b ∈ B Often we write a R b for (a, b) ∈ R A function f is a restricted relation where ∀a ∈ A ∃b ∈ B (((a, b) ∈ f) ∧ ∀c ∈ B ((a, c) ∈ f → c = b)) R is a relation on A if B = A (so, R ⊆ A × A)

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 16 / 38

slide-86
SLIDE 86

Relations

Definition

A binary relation R on sets A and B is a subset R ⊆ A × B R is a set of tuples (a, b) with a ∈ A and b ∈ B Often we write a R b for (a, b) ∈ R A function f is a restricted relation where ∀a ∈ A ∃b ∈ B (((a, b) ∈ f) ∧ ∀c ∈ B ((a, c) ∈ f → c = b)) R is a relation on A if B = A (so, R ⊆ A × A)

Definition

Given sets A1, . . . , An a subset R ⊆ A1 × · · · × An is an n-ary relation

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 16 / 38

slide-87
SLIDE 87

Examples

R ⊆ A × B, A students, B courses; (A Student, DMMR) ∈ R

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 17 / 38

slide-88
SLIDE 88

Examples

R ⊆ A × B, A students, B courses; (A Student, DMMR) ∈ R Graphs are relations on vertices: covered later in course

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 17 / 38

slide-89
SLIDE 89

Examples

R ⊆ A × B, A students, B courses; (A Student, DMMR) ∈ R Graphs are relations on vertices: covered later in course Divides | : Z+ × Z+ is {(n, m) | ∃k ∈ Z+ (m = kn)}

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 17 / 38

slide-90
SLIDE 90

Examples

R ⊆ A × B, A students, B courses; (A Student, DMMR) ∈ R Graphs are relations on vertices: covered later in course Divides | : Z+ × Z+ is {(n, m) | ∃k ∈ Z+ (m = kn)} R = {(a, b) | m divides a − b} where m > 1 is an integer

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 17 / 38

slide-91
SLIDE 91

Examples

R ⊆ A × B, A students, B courses; (A Student, DMMR) ∈ R Graphs are relations on vertices: covered later in course Divides | : Z+ × Z+ is {(n, m) | ∃k ∈ Z+ (m = kn)} R = {(a, b) | m divides a − b} where m > 1 is an integer Written as a ≡ b (mod m)

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 17 / 38

slide-92
SLIDE 92

Notation

R ∪ S union; R ∩ S intersection;

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 18 / 38

slide-93
SLIDE 93

Notation

R ∪ S union; R ∩ S intersection; If Ri are relations on A × B for all i ∈ I then

i∈I Ri and i∈I Ri are

relations on A × B

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 18 / 38

slide-94
SLIDE 94

Notation

R ∪ S union; R ∩ S intersection; If Ri are relations on A × B for all i ∈ I then

i∈I Ri and i∈I Ri are

relations on A × B R ⊆ S subset and R = S equality

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 18 / 38

slide-95
SLIDE 95

Relation composition

Definition

Let R ⊆ B × C and S ⊆ A × B. The composition relation (R ◦ S) ⊆ A × C is {(a, c) | ∃b (a, b) ∈ S ∧ (b, c) ∈ R}

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 19 / 38

slide-96
SLIDE 96

Relation composition

Definition

Let R ⊆ B × C and S ⊆ A × B. The composition relation (R ◦ S) ⊆ A × C is {(a, c) | ∃b (a, b) ∈ S ∧ (b, c) ∈ R} Closure R is a relation on A: R0 is the identity relation (ιA) Rn+1 = Rn ◦ R R∗ =

n≥0 Rn

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 19 / 38

slide-97
SLIDE 97

Relation composition

Definition

Let R ⊆ B × C and S ⊆ A × B. The composition relation (R ◦ S) ⊆ A × C is {(a, c) | ∃b (a, b) ∈ S ∧ (b, c) ∈ R} Closure R is a relation on A: R0 is the identity relation (ιA) Rn+1 = Rn ◦ R R∗ =

n≥0 Rn

Example: reachability in a graph

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 19 / 38

slide-98
SLIDE 98

Properties of binary relation R on A

reflexive iff ∀x ∈ A (x, x) ∈ R

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 20 / 38

slide-99
SLIDE 99

Properties of binary relation R on A

reflexive iff ∀x ∈ A (x, x) ∈ R ≤, =, and | are reflexive, but < is not

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 20 / 38

slide-100
SLIDE 100

Properties of binary relation R on A

reflexive iff ∀x ∈ A (x, x) ∈ R ≤, =, and | are reflexive, but < is not symmetric iff ∀x, y ∈ A ((x, y) ∈ R → (y, x) ∈ R) = is symmetric, but ≤, <, and | are not

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 20 / 38

slide-101
SLIDE 101

Properties of binary relation R on A

reflexive iff ∀x ∈ A (x, x) ∈ R ≤, =, and | are reflexive, but < is not symmetric iff ∀x, y ∈ A ((x, y) ∈ R → (y, x) ∈ R) = is symmetric, but ≤, <, and | are not antisymmetric iff ∀x, y ∈ A (((x, y) ∈ R ∧ (y, x) ∈ R) → x = y)

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 20 / 38

slide-102
SLIDE 102

Properties of binary relation R on A

reflexive iff ∀x ∈ A (x, x) ∈ R ≤, =, and | are reflexive, but < is not symmetric iff ∀x, y ∈ A ((x, y) ∈ R → (y, x) ∈ R) = is symmetric, but ≤, <, and | are not antisymmetric iff ∀x, y ∈ A (((x, y) ∈ R ∧ (y, x) ∈ R) → x = y) ≤, =, <, and | are antisymmetric

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 20 / 38

slide-103
SLIDE 103

Properties of binary relation R on A

reflexive iff ∀x ∈ A (x, x) ∈ R ≤, =, and | are reflexive, but < is not symmetric iff ∀x, y ∈ A ((x, y) ∈ R → (y, x) ∈ R) = is symmetric, but ≤, <, and | are not antisymmetric iff ∀x, y ∈ A (((x, y) ∈ R ∧ (y, x) ∈ R) → x = y) ≤, =, <, and | are antisymmetric transitive iff ∀x, y, z ∈ A (((x, y) ∈ R ∧ (y, z) ∈ R) → (x, z) ∈ R) ≤, =, <, and | are transitive

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 20 / 38

slide-104
SLIDE 104

Properties of binary relation R on A

reflexive iff ∀x ∈ A (x, x) ∈ R ≤, =, and | are reflexive, but < is not symmetric iff ∀x, y ∈ A ((x, y) ∈ R → (y, x) ∈ R) = is symmetric, but ≤, <, and | are not antisymmetric iff ∀x, y ∈ A (((x, y) ∈ R ∧ (y, x) ∈ R) → x = y) ≤, =, <, and | are antisymmetric transitive iff ∀x, y, z ∈ A (((x, y) ∈ R ∧ (y, z) ∈ R) → (x, z) ∈ R) ≤, =, <, and | are transitive R∗ is the reflexive and transitive closure of R

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 20 / 38

slide-105
SLIDE 105

Equivalence relations

Definition

A relation R on a set A is an equivalence relation iff it is reflexive, symmetric and transitive

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 21 / 38

slide-106
SLIDE 106

Equivalence relations

Definition

A relation R on a set A is an equivalence relation iff it is reflexive, symmetric and transitive Let Σ∗ be the set of strings over alphabet Σ. The relation {(s, t) ∈ Σ∗ × Σ∗ | |s| = |t|} is an equivalence relation

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 21 / 38

slide-107
SLIDE 107

Equivalence relations

Definition

A relation R on a set A is an equivalence relation iff it is reflexive, symmetric and transitive Let Σ∗ be the set of strings over alphabet Σ. The relation {(s, t) ∈ Σ∗ × Σ∗ | |s| = |t|} is an equivalence relation | on integers is not an equivalence relation.

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 21 / 38

slide-108
SLIDE 108

Equivalence relations

Definition

A relation R on a set A is an equivalence relation iff it is reflexive, symmetric and transitive Let Σ∗ be the set of strings over alphabet Σ. The relation {(s, t) ∈ Σ∗ × Σ∗ | |s| = |t|} is an equivalence relation | on integers is not an equivalence relation. For integer m > 1 the relation ≡ (mod m) is an equivalence relation on integers

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 21 / 38

slide-109
SLIDE 109

Equivalence classes

Definition

Let R be an equivalence relation on a set A and a ∈ A. Let [a]R = {s | (a, s) ∈ R} be the equivalence class of a w.r.t. R

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 22 / 38

slide-110
SLIDE 110

Equivalence classes

Definition

Let R be an equivalence relation on a set A and a ∈ A. Let [a]R = {s | (a, s) ∈ R} be the equivalence class of a w.r.t. R If b ∈ [a]R then b is called a representative of the equivalence class

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 22 / 38

slide-111
SLIDE 111

Theorem

Result

Let R be an equivalence relation on A and a, b ∈ A. The following three statements are equivalent

1

aRb

2

[a]R = [b]R

3

[a]R ∩ [b]R = ∅

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 23 / 38

slide-112
SLIDE 112

Theorem

Result

Let R be an equivalence relation on A and a, b ∈ A. The following three statements are equivalent

1

aRb

2

[a]R = [b]R

3

[a]R ∩ [b]R = ∅ Proof in book

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 23 / 38

slide-113
SLIDE 113

Partitions of a set

Definition

A partition of a set A is a collection of disjoint, nonempty subsets that have A as their union. In other words, the collection of subsets Ai ⊆ A with i ∈ I (where I is an index set) forms a partition of A iff

1

Ai = ∅ for all i ∈ I

2

Ai ∩ Aj = ∅ for all i = j ∈ I

3

  • i∈I Ai = A

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 24 / 38

slide-114
SLIDE 114

Result

Theorem

1

If R is an equivalence on A, then the equivalence classes of R form a partition of A

2

Conversely, given a partition {Ai | i ∈ I} of A there exists an equivalence relation R that has exactly the sets Ai, i ∈ I, as its equivalence classes

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 25 / 38

slide-115
SLIDE 115

Result

Theorem

1

If R is an equivalence on A, then the equivalence classes of R form a partition of A

2

Conversely, given a partition {Ai | i ∈ I} of A there exists an equivalence relation R that has exactly the sets Ai, i ∈ I, as its equivalence classes Proof in book

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 25 / 38

slide-116
SLIDE 116

Sequences

Sequences are ordered lists of elements 2, 3, 5, 7, 11, 13, 17, 19, . . . or a, b, c, d, . . ., y, z

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 26 / 38

slide-117
SLIDE 117

Sequences

Sequences are ordered lists of elements 2, 3, 5, 7, 11, 13, 17, 19, . . . or a, b, c, d, . . ., y, z

Definition

A sequence over a set S is a function f from a subset of the integers (typically N or Z+) to the set S. If the domain of f is finite then the sequence is finite

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 26 / 38

slide-118
SLIDE 118

Examples

f : Z+ → Q is f(n) = 1/n defines the sequence

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 27 / 38

slide-119
SLIDE 119

Examples

f : Z+ → Q is f(n) = 1/n defines the sequence 1, 1/2, 1/3, 1/4, . . .

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 27 / 38

slide-120
SLIDE 120

Examples

f : Z+ → Q is f(n) = 1/n defines the sequence 1, 1/2, 1/3, 1/4, . . . Assuming an = f(n), the sequence is also written a1, a2, a3, . . .

  • r as {an}n∈Z+

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 27 / 38

slide-121
SLIDE 121

Examples

f : Z+ → Q is f(n) = 1/n defines the sequence 1, 1/2, 1/3, 1/4, . . . Assuming an = f(n), the sequence is also written a1, a2, a3, . . .

  • r as {an}n∈Z+

g : N → N is g(n) = n2 defines the sequence 0, 1, 4, 9, . . .

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 27 / 38

slide-122
SLIDE 122

Examples

f : Z+ → Q is f(n) = 1/n defines the sequence 1, 1/2, 1/3, 1/4, . . . Assuming an = f(n), the sequence is also written a1, a2, a3, . . .

  • r as {an}n∈Z+

g : N → N is g(n) = n2 defines the sequence 0, 1, 4, 9, . . . Assuming bn = g(n), also written b0, b1, b2, . . . or as {bn}n∈N

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 27 / 38

slide-123
SLIDE 123

Geometric and arithmetic progressions

A geometric progression is a sequence of the form a, ar, ar 2, ar 3, . . . , ar n, . . .

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 28 / 38

slide-124
SLIDE 124

Geometric and arithmetic progressions

A geometric progression is a sequence of the form a, ar, ar 2, ar 3, . . . , ar n, . . . Example {bn}n∈N with bn = 6(1/3)n

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 28 / 38

slide-125
SLIDE 125

Geometric and arithmetic progressions

A geometric progression is a sequence of the form a, ar, ar 2, ar 3, . . . , ar n, . . . Example {bn}n∈N with bn = 6(1/3)n An arithmetic progression is a sequence of the form a, a + d, a + 2d, a + 3d, . . . , a + nd, . . .

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 28 / 38

slide-126
SLIDE 126

Geometric and arithmetic progressions

A geometric progression is a sequence of the form a, ar, ar 2, ar 3, . . . , ar n, . . . Example {bn}n∈N with bn = 6(1/3)n An arithmetic progression is a sequence of the form a, a + d, a + 2d, a + 3d, . . . , a + nd, . . . Example {cn}n∈N with cn = 7 − 3n

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 28 / 38

slide-127
SLIDE 127

Geometric and arithmetic progressions

A geometric progression is a sequence of the form a, ar, ar 2, ar 3, . . . , ar n, . . . Example {bn}n∈N with bn = 6(1/3)n An arithmetic progression is a sequence of the form a, a + d, a + 2d, a + 3d, . . . , a + nd, . . . Example {cn}n∈N with cn = 7 − 3n where the initial elements a, the common ratio r and the common difference d are real numbers

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 28 / 38

slide-128
SLIDE 128

Recurrence relations

Definition

A recurrence relation for {an}n∈N is an equation that expresses an in terms of one or more of the elements a0, a1, . . . , an−1

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 29 / 38

slide-129
SLIDE 129

Recurrence relations

Definition

A recurrence relation for {an}n∈N is an equation that expresses an in terms of one or more of the elements a0, a1, . . . , an−1 Typically the recurrence relation expresses an in terms of just a fixed number of previous elements (such as an = g(an−1, an−2))

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 29 / 38

slide-130
SLIDE 130

Recurrence relations

Definition

A recurrence relation for {an}n∈N is an equation that expresses an in terms of one or more of the elements a0, a1, . . . , an−1 Typically the recurrence relation expresses an in terms of just a fixed number of previous elements (such as an = g(an−1, an−2)) The initial conditions specify the first elements of the sequence, before the recurrence relation applies

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 29 / 38

slide-131
SLIDE 131

Recurrence relations

Definition

A recurrence relation for {an}n∈N is an equation that expresses an in terms of one or more of the elements a0, a1, . . . , an−1 Typically the recurrence relation expresses an in terms of just a fixed number of previous elements (such as an = g(an−1, an−2)) The initial conditions specify the first elements of the sequence, before the recurrence relation applies A sequence is called a solution of a recurrence relation iff its terms satisfy the recurrence relation

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 29 / 38

slide-132
SLIDE 132

Rabbits and Fibonacci sequence

A rabbit is placed on an island

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 30 / 38

slide-133
SLIDE 133

Rabbits and Fibonacci sequence

A rabbit is placed on an island After every 2 months, a rabbit produces a new rabbit.

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 30 / 38

slide-134
SLIDE 134

Rabbits and Fibonacci sequence

A rabbit is placed on an island After every 2 months, a rabbit produces a new rabbit. Find a recurrence relation for number of rabbits after n ∈ Z+ months assuming no rabbits die

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 30 / 38

slide-135
SLIDE 135

Rabbits and Fibonacci sequence

A rabbit is placed on an island After every 2 months, a rabbit produces a new rabbit. Find a recurrence relation for number of rabbits after n ∈ Z+ months assuming no rabbits die Answer is the Fibonacci sequence    f(1) = 1 f(2) = 1 f(n) = f(n − 1) + f(n − 2) for n > 2

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 30 / 38

slide-136
SLIDE 136

Rabbits and Fibonacci sequence

A rabbit is placed on an island After every 2 months, a rabbit produces a new rabbit. Find a recurrence relation for number of rabbits after n ∈ Z+ months assuming no rabbits die Answer is the Fibonacci sequence    f(1) = 1 f(2) = 1 f(n) = f(n − 1) + f(n − 2) for n > 2 Yields the sequence 1, 1, 2, 3, 5, 8, 13, . . .

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 30 / 38

slide-137
SLIDE 137

Solving recurrence relations

Finding a formula for the nth term of the sequence generated by a recurrence relation is called solving the recurrence relation

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 31 / 38

slide-138
SLIDE 138

Solving recurrence relations

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

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 31 / 38

slide-139
SLIDE 139

Solving recurrence relations

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 more advanced methods for solving recurrence relations are covered in Chapter 8 of the book (not part of this course)

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 31 / 38

slide-140
SLIDE 140

Solving recurrence relations

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 more advanced methods for solving recurrence relations are covered in Chapter 8 of the book (not part of this course) Here we illustrate by example the method of iteration in which we need to guess the formula

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 31 / 38

slide-141
SLIDE 141

Solving recurrence relations

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 more advanced methods for solving recurrence relations are covered in Chapter 8 of the book (not part of this course) Here we illustrate by example the method of iteration in which we need to guess the formula The guess can be proved correct by the method of induction (to be covered)

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 31 / 38

slide-142
SLIDE 142

Iterative solution - working upwards

Forward substitution

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 32 / 38

slide-143
SLIDE 143

Iterative solution - working upwards

Forward substitution an = an−1 + 3 for n ≥ 2 with a1 = 2

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 32 / 38

slide-144
SLIDE 144

Iterative solution - working upwards

Forward substitution an = an−1 + 3 for n ≥ 2 with a1 = 2 a2 = 2 + 3

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 32 / 38

slide-145
SLIDE 145

Iterative solution - working upwards

Forward substitution an = an−1 + 3 for n ≥ 2 with a1 = 2 a2 = 2 + 3 a3 = (2 + 3) + 3 = 2 + 3 · 2

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 32 / 38

slide-146
SLIDE 146

Iterative solution - working upwards

Forward substitution an = an−1 + 3 for n ≥ 2 with a1 = 2 a2 = 2 + 3 a3 = (2 + 3) + 3 = 2 + 3 · 2 a4 = (2 + 2 · 3) + 3 = 2 + 3 · 3

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 32 / 38

slide-147
SLIDE 147

Iterative solution - working upwards

Forward substitution an = an−1 + 3 for n ≥ 2 with a1 = 2 a2 = 2 + 3 a3 = (2 + 3) + 3 = 2 + 3 · 2 a4 = (2 + 2 · 3) + 3 = 2 + 3 · 3 . . . an = an−1 + 3 = (2 + 3 · (n − 2)) + 3 = 2 + 3 · (n − 1)

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 32 / 38

slide-148
SLIDE 148

Iterative solution - working downward

Backward substitution

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 33 / 38

slide-149
SLIDE 149

Iterative solution - working downward

Backward substitution an = an−1 + 3 for n ≥ 2 with a1 = 2 an = an−1 + 3

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 33 / 38

slide-150
SLIDE 150

Iterative solution - working downward

Backward substitution an = an−1 + 3 for n ≥ 2 with a1 = 2 an = an−1 + 3 = (an−2 + 3) + 3 = an−2 + 3 · 2

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 33 / 38

slide-151
SLIDE 151

Iterative solution - working downward

Backward substitution an = an−1 + 3 for n ≥ 2 with a1 = 2 an = an−1 + 3 = (an−2 + 3) + 3 = an−2 + 3 · 2 = (an−3 + 3) + 3 · 2 = an−3 + 3 · 3

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 33 / 38

slide-152
SLIDE 152

Iterative solution - working downward

Backward substitution an = an−1 + 3 for n ≥ 2 with a1 = 2 an = an−1 + 3 = (an−2 + 3) + 3 = an−2 + 3 · 2 = (an−3 + 3) + 3 · 2 = an−3 + 3 · 3 . . . = a2 + 3(n − 2) = (a1 + 3) + 3 · (n − 2) = 2 + 3 · (n − 1)

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 33 / 38

slide-153
SLIDE 153

Compound interest

Suppose a person deposits £1000 in a savings account yielding 3% per year with interest compounded annually. How much is in the account after 20 years?

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 34 / 38

slide-154
SLIDE 154

Compound interest

Suppose a person deposits £1000 in a savings account yielding 3% per year with interest compounded annually. How much is in the account after 20 years? Let Pn denote amount after n years

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 34 / 38

slide-155
SLIDE 155

Compound interest

Suppose a person deposits £1000 in a savings account yielding 3% per year with interest compounded annually. How much is in the account after 20 years? Let Pn denote amount after n years Pn = Pn−1 + 0.03 Pn−1 = (1.03)Pn−1

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 34 / 38

slide-156
SLIDE 156

Compound interest

Suppose a person deposits £1000 in a savings account yielding 3% per year with interest compounded annually. How much is in the account after 20 years? Let Pn denote amount after n years Pn = Pn−1 + 0.03 Pn−1 = (1.03)Pn−1 The initial condition P0 = 1000.

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 34 / 38

slide-157
SLIDE 157

Compound interest

Suppose a person deposits £1000 in a savings account yielding 3% per year with interest compounded annually. How much is in the account after 20 years? Let Pn denote amount after n years Pn = Pn−1 + 0.03 Pn−1 = (1.03)Pn−1 The initial condition P0 = 1000. P1 = (1.03) P0, . . ., Pn = (1.03)Pn−1 = (1.03)nP0

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 34 / 38

slide-158
SLIDE 158

Compound interest

Suppose a person deposits £1000 in a savings account yielding 3% per year with interest compounded annually. How much is in the account after 20 years? Let Pn denote amount after n years Pn = Pn−1 + 0.03 Pn−1 = (1.03)Pn−1 The initial condition P0 = 1000. P1 = (1.03) P0, . . ., Pn = (1.03)Pn−1 = (1.03)nP0 P20 = (1.03)20 1000 = 1, 806

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 34 / 38

slide-159
SLIDE 159

Common sequences

TABLE 1 Some Useful Sequences.

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, . . . fn 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, . . .

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 35 / 38

slide-160
SLIDE 160

Summations

Given a sequence {an}, the sum of terms am, am+1, . . . , aℓ is am + am+1 + . . . + aℓ

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 36 / 38

slide-161
SLIDE 161

Summations

Given a sequence {an}, the sum of terms am, am+1, . . . , aℓ is am + am+1 + . . . + aℓ

  • j=m

aj

  • r
  • m≤j≤ℓ

aj

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 36 / 38

slide-162
SLIDE 162

Summations

Given a sequence {an}, the sum of terms am, am+1, . . . , aℓ is am + am+1 + . . . + aℓ

  • j=m

aj

  • r
  • m≤j≤ℓ

aj The variable j is called the index of summation More generally for an index set S

  • j∈S

aj

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 36 / 38

slide-163
SLIDE 163

Useful summation formulas

TABLE 2 Some Useful Summation Formulae.

Sum Closed Form

n

  • k = 0

ark (r ̸= 0) arn+1 − a r − 1 , r ̸= 1

n

  • k = 1

k n(n + 1) 2

n

  • k = 1

k2 n(n + 1)(2n + 1) 6

n

  • k = 1

k3 n2(n + 1)2 4

  • k = 0

xk, |x| < 1 1 1 − x

  • k = 1

kxk−1, |x| < 1 1 (1 − x)2

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 37 / 38

slide-164
SLIDE 164

Products

Given a sequence {an}, the product of terms am, am+1, . . . , aℓ is am · am+1 · . . . · aℓ

  • j=m

aj

  • r
  • m≤j≤ℓ

aj More generally for a finite index set S one writes

  • j∈S

aj

Colin Stirling (Informatics) Discrete Mathematics (Chaps 2 & 9) Today 38 / 38