Chapter 2
Chapter 2
Chapter 2
Functions,/Sequences, Sums,
and Matrices
Chapter 2
Chapter Summary
Sets
• The Language of Sets
• Set Operations
• Set Identities
Functions
• Types of Functions
• Operations on Functions
• Computability
Sequences and Summations
• Types of Sequences
• Summation Formulae
Set Cardinality
• Countable Sets
Matrices
• Matrix Arithmetic
Sets
載入中⋯
Section 2.1
Section Summary 1
Definition of sets
Describing Sets
• Roster Method
• Set-Builder Notation
Some Important Sets in Mathematics
Empty Set and Universal Set
Subsets and Set Equality
Cardinality of Sets
Tuples
Cartesian Product
Introduction
Sets are one of the basic building blocks for the types of
objects considered in discrete mathematics.
• Important for counting.
• Here we are not concerned with a formal set of axioms for set
theory. Instead, we will use what is called naïve set theory.
Sets
A set is an unordered collection of objects.
• the students in this class
• the chairs in this room
The objects in a set are called the elements, or
members of the set. A set is said to contain its
elements.
The notation a ∈ A denotes that a is an element
of the set A.
If a is not a member of A, write a ∉ A
Describing a Set: Roster Method
S = {a,b,c,d}
Order not important
S = {a,b,c,d} = {b,c,a,d}
Each distinct object is either a member or not; listing
more than once does not change the set.
S = {a,b,c,d} = {a,b,c,b,c,d}
Elipses (…) may be used to describe a set without listing
all of the members when the pattern is clear.
S = {a,b,c,d, ……,z }
Roster Method
Set of all vowels in the English alphabet:
V = {a,e,i,o,u}
Set of all odd positive integers less than 10:
O = {1,3,5,7,9}
Set of all positive integers less than 100:
S = {1,2,3,……..,99}
Set of all integers less than 0:
S = {…., -3,-2,-1}
Some Important Sets
N = natural numbers = {0,1,2,3….}
Z = integers = {…,-3,-2,-1,0,1,2,3,…}
Z⁺ = positive integers = {1,2,3,…..}
R = set of real numbers
R+ = set of positive real numbers
C = set of complex numbers.
Q = set of rational numbers
Set-Builder Notation
Specify the property or properties that all members must
satisfy:
S = {x | x is a positive integer less than 100}
O = {x | x is an odd positive integer less than 10}
O = {x ∈ Z⁺ | x is odd and x < 10}
A predicate may be used:
S = {x | P(x)}
Example: S = {x | Prime(x)}
Positive rational numbers:
Q+ = {x ∈ R | x = p/q, for some positive integers p,q}
Interval Notation
載入中⋯
closed interval [a,b]
open interval (a,b)
Universal Set and Empty Set
The universal set U is the set containing everything
currently under consideration.
• Sometimes implicit Venn Diagram
• Sometimes explicitly stated.
{1,3,5} = {3, 5, 1}
{1,5,5,5,3,3,1} = {1,3,5}
Subsets
Definition: The set A is a subset of B, if and
only if every element of A is also an element of
B.
• The notation A ⊆ B is used to indicate that A is a
subset of the set B.
is true.
1. • A ⊆ BBecause
holdsaif∈and
∅ isonly if false, ∅ ⊆ S ,for every set S.
always
This is equivalent to
A ⊆ B and B⊆A
Proper Subsets
Definition: If A ⊆ B, but A ≠B, then we say A is
a proper subset of B, denoted by A ⊂ B. If A ⊂ B,
then
is true.
Venn Diagram
Set Cardinality
Definition: If there are exactly n distinct elements in S
where n is a nonnegative integer, we say that S is finite.
Otherwise it is infinite.
Definition: The cardinality of a finite set A, denoted by
|A|, is the number of (distinct) elements of A.
Examples:
1. |ø| = 0
2. Let S be the letters of the English alphabet. Then |S| = 26
3. |{1,2,3}| = 3
4. |{ø}| = 1
5. The set of integers is infinite.
Power Sets
Definition: The set of all subsets of a set A,
denoted P(A), is called the power set of A.
Example: If A = {a,b} then
P(A) = {ø, {a},{b},{a,b}}
If a set has n elements, then the cardinality of the
power set is 2ⁿ. (In Chapters 5 and 6, we will
discuss different ways to show this.)
{ }
P ({0 , " n }) : {φ {} ①
, , } ,}, { } ,
{ 啊 {
2 } .
,
{ }
23 8
有 2 不同的組合 =
口
Tuples
The ordered n-tuple (a1,a2,…..,an) is the ordered
collection that has a1 as its first element and a2
as its second element and so on until an as its last
element.
Two n-tuples are equal if and only if their
corresponding elements are equal.
2-tuples are called ordered pairs.
The ordered pairs (a,b) and (c,d) are equal if and
only if a = c and b = d.
Cartesian Product 1
René Descartes
(1596-1650)
Definition: The Cartesian Product of two
sets A and B, denoted by A × B is the set of
ordered pairs (a,b) where a ∈ A and b ∈ B .
Example:
A = {a,b} B = {1,2,3}
A × B = {(a,1),(a,2),(a,3), (b,1),(b,2),(b,3)}
Definition: A subset R of the Cartesian product A × B is
called a relation from the set A to the set B. (Relations
will be covered in depth in Chapter 9.)
Cartesian Product 2
Set Operations
• Union
• Intersection
• Complementation
• Difference
More on Set Cardinality
Set Identities
Proving Identities
Membership Tables
Boolean Algebra
Propositional calculus and set theory are both
instances of an algebraic system called a Boolean
Algebra. This is discussed in Chapter 12.
The operators in set theory are analogous to the
corresponding operator in propositional calculus.
As always there must be a universal set U. All
sets are assumed to be subsets of U.
Union
Definition: Let A and B be sets. The union of the
sets A and B, denoted by A ∪ B, is the set:
載入中⋯
Example: What is {1,2,3} ∪ {3, 4, 5}?
Solution: {1,2,3,4,5} Venn Diagram for A ∪ B
Intersection
Definition: The intersection of sets A and B, denoted by
A ∩ B, is
Example:
U = {0,1,2,3,4,5,6,7,8,9,10}
A = {1,2,3,4,5} B ={4,5,6,7,8}
What is
Solution:
{1,2,3,6,7,8} Venn Diagram
Set Identities 1
Identity laws
Domination laws
Idempotent laws
Complementation law
Set Identities 2
Commutative laws
Associative laws
Distributive laws
Set Identities 3
De Morgan’s laws
Absorption laws
Complement laws
Proving Set Identities
Different ways to prove set identities:
1. Prove that each set (side of the identity) is a
subset of the other.
2. Use set builder notation and propositional logic.
3. Membership Tables: Verify that elements in the
same combination of sets always either belong or
do not belong to the same side of the identity. Use
1 to indicate it is in the set and a 0 to indicate that it
is not
Proof of Second De Morgan Law 1
Solution: A B C
1 1 1 1 1 1 1 1
1 1 0 0 1 1 1 1
1 0 1 0 1 1 1 1
1 0 0 0 1 1 1 1
0 1 1 1 1 1 1 1
0 1 0 0 0 1 0 0
0 0 1 0 0 0 1 0
0 0 0 0 0 0 0 0
Conversion Between Binary, Octal, and
Hexadecimal Expansions
Let A1, A2 ,…, An be an indexed collection of sets.
We define:
Definition of a Function.
• Domain, Codomain
• Image, Preimage
Injection, Surjection, Bijection
Inverse Function
Function Composition
Graphing Functions
Floor, Ceiling, Factorial
Partial Functions (optional)
Functions 1
and
Functions 3
Given a function f: A B:
• We say f maps A to B or f is a mapping from A to B.
• A is called the domain of f.
• B is called the codomain of f.
• If f(a) = b,
• then b is called the image of a under f.
• a is called the preimage of b.
• The range of f is the set of all images of points in A under f. We
denote it by f(A).
• Two functions are equal when they have the same domain, the same
codomain and map each element of the domain to the same element
of the codomain.
Jump to long description
Representing Functions
Functions may be specified in different ways:
• An explicit statement of the assignment. Students
and grades example.
• A formula.
• A computer program.
• A Java program that when given an integer n, produces the
nth Fibonacci Number (covered in the next section and
also in Chapter 5).
Questions
f(a) = ? z
The image of d is z
?
The domain of f is A
?
The codomain of f is B
?
The preimage of y is b
?
f(A) = {y,z
? }
The preimage(s) of z is (are) ? {a,c,d
}
Question on Functions and Sets
If and S is a subset of A, then
f {a,b,c,} is {y,z
? }
f {c,d} is {z
? }
Injections
Definition: A function f is said to be one-to-one ,
or injective, if and only if f(a) = f(b) implies that
a = b for all a and b in the domain of f. A
function is said to be an injection if it is one-to-
one.
Surjections
Definition: A function f from A to B is called
onto or surjective, if and only if for every
element
there is an element with
A function f is called a surjection if it is onto.
Bijections
Definition: A function f is a one-to-one
correspondence, or a bijection, if it is both one-
to-one and onto (surjective and injective).
Showing that f is one-to-one or onto 1
Suppose that f : A B.
To show that f is injective Show that if f (x) = f (y) for
arbitrary x, y ∈ A, then x = y.
To show that f is not injective Find particular
elements x, y ∈ A such that x ≠ y and f (x) = f (y).
To show that f is surjective Consider an arbitrary
element y ∈ B and find an element x ∈ A such that f
(x) = y.
To show that f is not surjective Find a particular y ∈
B such that f (x) ≠ y for all x ∈ A.
Showing that f is one-to-one or onto 2
Example 1:
If
Composition Questions 1
Stirling’s Formula:
Examples:
Partial Functions (optional)
Definition: A partial function f from a set A to a set B is an
assignment to each element a in a subset of A, called the
domain of definition of f, of a unique element b in B.
• The sets A and B are called the domain and codomain of f,
respectively.
• We day that f is undefined for elements in A that are not in the
domain of definition of f.
• When the domain of definition of f equals A, we say that f is a total
function.
Example: f: N R where f(n) = √n is a partial function from
Z to R where the domain of definition is the set of
nonnegative integers. Note that f is undefined for negative
integers.
Sequences and Summations
Section 2.4
Section Summary 4
Sequences.
• Examples: Geometric Progression, Arithmetic
Progression
Recurrence Relations
• Example: Fibonacci Sequence
Summations
Special Integer Sequences (optional)
Introduction 2
Here are three interesting sequences to try from the OESIS site. To solve each
puzzle, find a rule that determines the terms of the sequence.
Guess the rules for forming for the following sequences:
• 2, 3, 3, 5, 10, 13, 39, 43, 172, 177, ...
• Hint: Think of adding and multiplying by numbers to generate this
sequence.
• 0, 0, 0, 0, 4, 9, 5, 1, 1, 0, 55, ...
• Hint: Think of the English names for the numbers representing the
position in the sequence and the Roman Numerals for the same number.
• 2, 4, 6, 30, 32, 34, 36, 40, 42, 44, 46, ...
• Hint: Think of the English names for numbers, and whether or not they
have the letter ‘e.’
The answers and many more can be found at http://oeis.org/Spuzzle.html
Summations 1
if r ≠1
if r = 1
Some Useful Summation Formulae
TABLE 2 Some Useful Summation
Formulae. Geometric Series:
Sum Closed From
We just proved this.
Later we will
prove some of
these by
induction.
Proof in text
(requires
calculus)
Cardinality of Sets
Section 2.5
Section Summary 6
Cardinality
Countable Sets
Computability
Cardinality 1
And so on.
1, ½, 2, 3, 1/3,1/4, 2/3, ….
Uncountable (1845-1918)
Definition of a Matrix
Matrix Arithmetic
Transposes and Powers of Arithmetic
Zero-One matrices
Matrices
Matrices are useful discrete structures that can be used in
many ways. For example, they are used to:
• describe certain types of functions known as linear transformations.
• Express which vertices of a graph are connected by edges (see Chapter
10).
In later chapters, we will see matrices used to build models of:
• Transportation systems.
• Communication networks.
Algorithms based on matrix models will be presented in later
chapters.
Here we cover the aspect of matrix arithmetic that will be
needed later.
Matrix
Definition: A matrix is a rectangular array of
numbers. A matrix with m rows and n columns is
called an m × n matrix.
• The plural of matrix is matrices.
• A matrix with the same number of rows as columns is
called square.
• Two matrices are equal if they have the same number of
rows and the same number of columns
and the corresponding entries in every
position are equal.
3 × 2 matrix
Notation
Let m and n be positive integers and let
Does AB =
BA?
Solution:
AB ≠
BA
Identity Matrix and Powers of Matrices
Definition: The identity matrix of order n is the m × n
matrix In = [ ij], where ij = 1 if i = j and ij = 0 if i≠j.
AIn = ImA = A
when A is an m × n matrix
Example: Let