0% found this document useful (0 votes)
4 views

Chapter 2 P 3

Uploaded by

Michael Zhang
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Chapter 2 P 3

Uploaded by

Michael Zhang
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

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.

© 2019 McGraw-Hill Education


Surjections
Definition: A function f from A to B is called onto or
surjective, if and only if for every element b∈B
there is an element a ∈ A with f (a ) = b .
A function f is called a surjection if it is onto.

© 2019 McGraw-Hill Education


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).

© 2019 McGraw-Hill Education


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.
© 2019 McGraw-Hill Education
Showing that f is one-to-one or onto 2

Example 1: Let f be the function from {a,b,c,d} to {1,2,3}


defined by f(a) = 3, f(b) = 2, f(c) = 1, and f(d) = 3. Is f a
surjective function?
Solution: Yes, f is surjective since all three elements of
the codomain are images of elements in the domain.
(If the codomain were changed to {1,2,3,4}, f would not
be surjective.)
Example 2: Is the function f(x) = x2 from the set of
integers to the set of integers surjective?
Solution: No, f is not surjective because there is no
integer x with x2 = −1, for example.
© 2019 McGraw-Hill Education
Showing that f is one-to-one or onto 2

Example 1: Let f be the function from {a,b,c,d} to {1,2,3}


defined by f(a) = 3, f(b) = 2, f(c) = 1, and f(d) = 3. Is f an
injective function?
Solution: No, f is not injective since f(a) = f(d).
(If a=d then f would be injective.)
Example 2: Is the function f(x) = x2 from the set of
natural numbers to the set of integers injective?
Solution: Yes, f is injective because f(a) = f(b) implies
that √(a2) = √(b2) and we know that √(x2) = x for non-
negative integers, so a = b.

© 2019 McGraw-Hill Education


Inverse Functions 1

Definition: Let f be a bijection from A to B. Then


the inverse of f, denoted f −1 , is the function from
B to A defined as f −1 ( y ) = x iff f (x ) = y
No inverse exists unless f is a bijection. Why?

© 2019 McGraw-Hill Education


Inverse Functions 2

© 2019 McGraw-Hill Education


Questions 1

Example 1: Let f be the function from {a,b,c} to


{1,2,3} such that f(a) = 2, f(b) = 3, and f(c) = 1. Is f
invertible and if so what is its inverse?

Solution: The function f is invertible because it is


a bijection. The inverse function f−1 reverses the
correspondence given by f, so f−1 (1) = c, f−1 (2) =
a, and f−1 (3) = b.

© 2019 McGraw-Hill Education


Questions 2

Example 2: Let f: Z → Z be such that f(x) = x + 1.


Is f invertible, and if so, what is its inverse?

Solution: The function f is invertible because it is


a one-to-one correspondence. The inverse
function f−1 reverses the correspondence so f−1
(y) = y −1.

© 2019 McGraw-Hill Education


Questions 3

Example 3: Let f: R → R be such that f (x ) = x 2


Is f invertible, and if so, what is its inverse?

Solution: The function f is not invertible because it is


not injective, because f(-1) = f(1).

© 2019 McGraw-Hill Education


Composition 1

Definition: Let f: B→C, g: A→B. The composition of f with


g, denoted f ! g is the function from A to C defined by
f ! g (x ) = f (g (x ))

© 2019 McGraw-Hill Education


Composition 2

© 2019 McGraw-Hill Education


Composition 3

Example 1: If

2
f (x ) = x and g (x ) = 2 x + 1,
then
2
f (g (x )) = (2 x + 1)
and
2
g ( f (x )) = 2 x + 1

© 2019 McGraw-Hill Education


Composition Questions 1

Example 2: Let g be the function from the set {a,b,c} to itself


such that g(a) = b, g(b) = c, and g(c) = a. Let f be the function
from the set {a,b,c} to the set {1,2,3} such that f(a) = 3, f(b) =
2, and f(c) = 1.
What is the composition of f and g, and what is the
composition of g and f.
Solution: The composition f∘g is defined by

© 2019 McGraw-Hill Education


Composition Questions 1

Example 2: Let g be the function from the set {a,b,c} to itself


such that g(a) = b, g(b) = c, and g(c) = a. Let f be the function
from the set {a,b,c} to the set {1,2,3} such that f(a) = 3, f(b) =
2, and f(c) = 1.
What is the composition of f and g, and what is the
composition of g and f.
Solution: The composition f∘g is defined by
f ! g (a ) = f (g (a )) = f (b ) = 2.
f ! g (b ) = f (g (b )) = f (c ) = 1.
f ! g (c ) = f (g (c )) = f (a ) = 3.

© 2019 McGraw-Hill Education


Composition Questions 1

Example 2: Let g be the function from the set {a,b,c} to itself


such that g(a) = b, g(b) = c, and g(c) = a. Let f be the function
from the set {a,b,c} to the set {1,2,3} such that f(a) = 3, f(b) =
2, and f(c) = 1.
What is the composition of f and g, and what is the
composition of g and f.
Solution: The composition f∘g is defined by
f ! g (a ) = f (g (a )) = f (b ) = 2.
f ! g (b ) = f (g (b )) = f (c ) = 1.
f ! g (c ) = f (g (c )) = f (a ) = 3.
Note that g∘f is not defined, because the range of f is not a subset
of the domain of g.
© 2019 McGraw-Hill Education
Composition Questions 2

Example 2: Let f and g be functions from the set


of integers to the set of integers defined by
f (x ) = 2 x + 3 and g (x ) = 3 x + 2.
What is the composition of f and g, and also the
composition of g and f ?
Solution:
f ! g (x ) = f (g (x )) = f (3 x + 2 ) = 2 (3 x + 2 ) + 3 = 6 x + 7
(g ∘ f )(x) = g( f(x)) = g(2x + 3) = 3(2x + 3) + 2 = 6x + 11
g ! f (x ) = g ( f (x )) = g (3 x + 2 ) = 3 (3 x + 2 ) + 2 = 6 x + 11

© 2019 McGraw-Hill Education


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}.

Graph of f(n) = 2n + 1 Graph of f(x) = x2


from Z to Z from Z to Z
© 2019 McGraw-Hill Education
Some Important Functions
The floor function, denoted
f (x ) = ⎣ x ⎦
is the largest integer less than or equal to x.
The ceiling function, denoted

f (x ) = ⎡ x ⎤
is the smallest integer greater than or equal to x
Example: ⎡3.5⎤ = 4 ⎣3.5⎦ = 3
⎡−1.5⎤ = −1 ⎣−1.5⎦ = −2
© 2019 McGraw-Hill Education
Floor and Ceiling Functions 1

Graph of (a) Floor and (b) Ceiling Functions


© 2019 McGraw-Hill Education
Floor and Ceiling Functions 2

TABLE 1 Useful Properties of the Floor and Ceiling


Functions.
(n is an integer, x is a real number)

(2 ) x − 1 < ⎣ x⎦ ≤ x ≤ ⎡ x⎤ < x + 1
(3a ) ⎣− x ⎦ = − ⎡ x ⎤
(3b ) ⎡− x ⎤ = − ⎣ x ⎦
(4a ) ⎣ x + n⎦ = ⎣ x⎦ + n
(4b ) ⎡ x + n⎤ = ⎡ x⎤ + n

© 2019 McGraw-Hill Education


Proving Properties of Functions
Example: Prove that x is a real number, then
⌊2x⌋= ⌊x⌋ + ⌊x + 1/2⌋
Solution: Let x = n + ε, where n is an integer and 0 ≤ ε< 1.
Case 1: ε < ½
• 2x = 2n + 2ε and ⌊2x⌋ = 2n, since 0 ≤ 2ε< 1.
• ⌊x + 1/2⌋ = n, since x + ½ = n + (1/2 + ε ) and 0 ≤ ½ +ε < 1.
• Hence, ⌊2x⌋ = 2n and ⌊x⌋ + ⌊x + 1/2⌋ = n + n = 2n.
Case 2: ε ≥ ½
• 2x = 2n + 2ε = (2n + 1) +(2ε − 1) and ⌊2x⌋ =2n + 1, since 0 ≤ 2 ε − 1< 1.
• ⌊x + 1/2⌋ = ⌊ n + (1/2 + ε)⌋ = ⌊ n + 1 + (ε – 1/2)⌋ = n + 1 since 0 ≤ ε −
1/2< 1.
• Hence, ⌊2x⌋ = 2n + 1 and ⌊x⌋ + ⌊x + 1/2⌋ = n + (n + 1) = 2n + 1.

© 2019 McGraw-Hill Education


Factorial Function
Definition: f: N → Z+ , denoted by f(n) = n! is the product
of the first n positive integers when n is a nonnegative
integer.
f (n ) = 1 ⋅ 2 ⋅⋅⋅ (n –1)⋅ n, f (0 ) = 0! = 1

Stirling’s Formula:
n
Examples: n ! ! 2π n (n / e )

f (1) = 1! = 1 f (n ) ! g (n ) " limn → ∞f (n ) / g (n ) = 1

f (2 ) = 2! = 1 ⋅ 2 = 2
f (6 ) = 6! = 1 ⋅ 2 ⋅ 3 ⋅ 4 ⋅ 5 ⋅ 6 = 720
f (20 ) = 2, 432,902, 008,176, 640, 000.
© 2019 McGraw-Hill Education
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: Z → 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.

© 2019 McGraw-Hill Education


Sequences and Summations
Section 2.4

© 2019 McGraw-Hill Education


Section Summary 4

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

© 2019 McGraw-Hill Education


Introduction 2

Sequences are ordered lists of elements.


• 1, 2, 3, 5, 8
• 1, 3, 9, 27, 81, …….
Sequences arise throughout mathematics,
computer science, and in many other disciplines,
ranging from botany to music.
We will introduce the terminology to represent
sequences and sums of the terms in the
sequences.
© 2019 McGraw-Hill Education
Sequences 1

Definition: A sequence is a function from a subset


of the integers (usually either the set {0, 1, 2, 3, 4,
…..} or {1, 2, 3, 4, ….}) to a set S.
The notation an is used to denote the image of the
integer n. We can think of an as the equivalent of
f(n) where f is a function from {0,1,2,…..} to S. We
call an a term of the sequence.

© 2019 McGraw-Hill Education


Sequences 2

Example: Consider the sequence {an} where

1
an = {an } = {a1 , a2 , a3 ...}
n
1 1 1
1, , ,
2 3 4

© 2019 McGraw-Hill Education


Geometric Progression
Definition: 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.
Examples :
1. Let a = 1and r = −1. Then :
{bn } = {b0 , b1 , b2 , b3 , b4 ,...} = {1, − 1, 1, − 1, 1,...}
2. Let a = 2 and r = 5. Then :
{cn } = {c0 , c1 , c2 , c3 , c4 ,...} = {2, 10, 50, 250, 1250,...}
3. Let a = 6 and r = 1/ 3. Then :
⎧ 2 2 2 ⎫
{d n } = {d0 , d1 , d 2 , d3 , d 4 ,...} = ⎨6, 2, , , ,...⎬
⎩ 3 9 27 ⎭
© 2019 McGraw-Hill Education
Arithmetic Progression
Definition: A arithmetic progression is a sequence of the form:
a, a + d , a + 2d ,..., a + nd ,...
where the initial term a and the common difference d are real
numbers.
Examples :
1. Let a = −1and d = 4 :
{sn } = {s0 , s1 , s2 , s3 , s4 ,...} = {{-1,3,7,11,…}
1, − 1, 1, − 1, 1,...}
2. Let a = 7 and d = −3 :
{tn } = {t0 , t1 , t2 , t3 , t4 ,...} = {7, 4, 1, − 2, − 5,...}
3. Let a = 1and d = 2 :
{un } = {u0 , u1 , u2 , u3 , u4 ,...} = {1, 3, 5, 7, 9,...}
© 2019 McGraw-Hill Education
Strings 1

Definition: A string is a finite sequence of


characters from a finite set (an alphabet).
Sequences of characters or bits are important in
computer science.
The empty string is represented by λ.
The string abcde has length 5.

© 2019 McGraw-Hill Education


Recurrence Relations
Definition: A recurrence relation for the sequence {an}
is an equation that expresses an in terms of one or
more of the previous terms of the sequence, namely,
a0, a1, …, an−1, for all integers n with n ≥ n0, where n0 is
a nonnegative integer.
A sequence is called a solution of a recurrence relation
if its terms satisfy the recurrence relation.
The initial conditions for a sequence specify the terms
that precede the first term where the recurrence
relation takes effect.
© 2019 McGraw-Hill Education
Questions about Recurrence Relations 1

Example 1: Let {an} be a sequence that satisfies the


recurrence relation an = an−1 + 3 for n = 1,2,3,4,…. and
suppose that a0 = 2. What are a1 , a2 and a3?
[Here a0 = 2 is the initial condition.]
Solution: We see from the recurrence relation that
a1 = a0 + 3 = 2 + 3 = 5
a2 = 5 + 3 = 8
a3 = 8 + 3 = 11

© 2019 McGraw-Hill Education


Questions about Recurrence Relations 2

Example 2: Let {an} be a sequence that satisfies


the recurrence relation an = an-1 – an-2 for n =
2,3,4,…. and suppose that a0 = 3 and a1 = 5. What
are a2 and a3?
[Here the initial conditions are a0 = 3 and a1 = 5. ]
Solution: We see from the recurrence relation that
a2 = a1 − a0 = 5 − 3 = 2
a3 = a2 − a1 = 2 − 5 = −3
© 2019 McGraw-Hill Education
Fibonacci Sequence
Definition: Define the Fibonacci sequence, f0 ,f1 ,f2,…, by:
• Initial Conditions: f0 = 0, f1 = 1
• Recurrence Relation: fn = fn−1 + fn−2
Example: Find f2 ,f3 ,f4 , f5 and f6 .

Answer :
f 2 = f1 + f 0 = 1 + 0 = 1,
f3 = f 2 + f1 = 1 + 1 = 2,
f 4 = f3 + f 2 = 2 + 1 = 3,
f5 = f 4 + f3 = 3 + 2 = 5,
f 6 = f5 + f 4 = 5 + 3 = 8.
© 2019 McGraw-Hill Education
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 methods for solving recurrence relations will be
covered in Chapter 8 where recurrence relations will be
studied in greater depth.
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 (Chapter 5).
© 2019 McGraw-Hill Education

You might also like