Lecture 06
Lecture 06
(CSE 0611101)
2.3 Functions
2.4 Sequences and Summations
1
Functions
• Definition 1: Let A and B be nonempty sets.
A function f from A to B is an assignment of exactly
one element of B to each element of A.
We write f(a) = b if b is the unique element of B
assigned by the function f to the element a of A.
• If f is a function from A to B, we write f: AB
• Functions are also called mappings or
transformations.
2
Functions
• Functions are specified in many different ways.
• Sometimes we explicitly state the assignments, as in
Figure 1.
• Often we give a formula, such as f(x) = x + 1, to
define a function.
• Other times we use a computer program to specify a
function.
3
Functions
• A function f: A B can also be defined in terms of a
relation from A to B.
• A relation from A to B is just a subset of A X B
• A relation from A to B that contains one, and only
one, ordered pair ( a, b) for every element a A,
defines a function f from A to B. This function is
defined by the assignment f(a)=b, where ( a, b) is the
unique ordered pair in the relation that has a as its
first element.
4
FIGURE 1: Assignment of Grades in a
Discrete Mathematics Class
5
Some Function Terminology
6
Some Function Terminology
• If f is a function from A to B, we say that f maps from
A to B
• f: A B
– A: domain of f
– B: codomain of f
– f(a)=b,
• a is called the preimage of b
• b is called the image of a
– Range of f : the set of all images of elements of A
7
Range versus Codomain
8
Range versus Codomain: Example
9
Example 1 (page 134)
• What are the domain, codomain, and range of the function
that assigns grades to students of Discrete Math class as
follows?
10
Example 1 (page 134)
• Solution:
• Let G be the function that assigns grade to a student
of DM class.
• The domain of G is the set { Adams, Chou,
Goodfriend, Rodriguez, Stevens}
• The codomain of G is the set { A, B, C, D, E}
• The range of G is the set { A, B, C, E}
– Because each grade except D is assigned to some
student
11
Example 2(Page 134)
• Let R be the relation consisting of ordered pairs (Abdul, 22),
(Brenda,24), (Carla,21), (Desire,22), (Eddie,24), and (Felicia,22),
where each pair consists of a graduate student and the age of
this student. What is the function that this relation determines?
• Solution: This relation defines the function f, where with
f(Abdul)= 22, f(Brenda)=24, f(Carla)=21, f(Desire)=22, f(Eddie)=
24, and f(Felicia)=22.
• Here, domain is the set { Abdul, Brenda, Carla, Desire, Eddie, Felicia }
• To define the function f, we need to specify a codomain. Here, we can
take the codomain to be the set of positive integers
• Range is the set {21,22,24}
12
Functions
• Definition 3: Let f1 and f2 be functions from A to R.
Then f1+f2 and f1f2 are also functions from A to R
defined by
• (f1+f2)(x) = f1(x)+f2(x)
• (f1f2)(x)=f1(x)f2(x)
13
Example 6 (page 135)
• Let f1 and f2 be functions from R to R such that
f1(x)=x2 and f2(x)=x – x2 .
What are the functions f1+f2 and f1f2 ?
• Solution:
• (f1+f2)(x) = f1(x)+f2(x) = x2 + (x –x2 ) = x
• (f1f2)(x) = x2(x- x2 ) = x3 – x4
14
Functions
• Definition 4: Let f be a function from the set A to the
set B, and let S is a subset of A. The image of S under
the function f is the subset of B that consists of the
images of the elements of S.
• We denote the image of S by f(S).
f(S)={t|sS(t=f(s))}
15
Example 7 (page 136)
• Let A = {a, b, c, d, e} and B = {1, 2, 3, 4}
with f(a)=2, f(b)=1, f(c)= 4, f(d)=1, f(e)=1.
What is the image of the subset S = {b, c, d}?
• Solution:
• The image of the subset S = {b, c, d} is the set
f(S) = {1, 4}
16
One-to-One Functions
• Definition 5: A function f is one-to-one or injective, iff
f(a)=f(b) implies that a=b for all a and b in the
domain of f.
• ab( f(a)=f(b) a=b ) or
ab( a b f(a) f(b) )
• A function f: AB is said to be one-to-one if different
elements in the domain A have distinct images.
• A function is one-to-one, iff every element of its
range has exactly one pre-image.
17
FIGURE 3 A One-to-One Function
18
Example 8(page 136)
• Determine whether the function f from {a, b, c, d} to
{1, 2, 3, 4, 5} with f(a)=4, f(b)=5, f(c)= 1, and f(d)=3
is one-to-one.
19
Example 9(page 136)
• Example 9(page 136): Determine whether the
function f(x) = x2 from the set of integers to the set of
integers is one-to-one.
• Solution: The function f(x) = x2 is not one-to-one
because, for instance, f(1)= f(–1) = 1, but 1 = – 1
• Question: Determine whether the function f(x) = x2
from the set of positive integers to the set of
positive integers is one-to-one.
20
Example 10 (p.137)
• Determine whether the function f(x) = x + 1 from the
set of real numbers to the set of real numbers is one-
to-one.
• Solution: The function f(x) = x + 1 is a one-to-one
function. Since x+1 = y+1, when x = y
21
Example : One-to-one function
• Let A = {1, 2, 3} and B = {a, b, c, d}, and
let f(1) = a, f(2) = b, f(3) = d.
Then f is injective, since the different elements 1, 2, 3
in A are assigned to the different elements a, c, d
respectively in B
22
Onto Function
• Definition 7: A function f from A to B is onto or
surjective, iff for every element bB there is an
element aA with f(a)=b.
yx( f(x)=y ) or ab( a b f(a) f(b) )
• A function f: AB is said to be an onto function if
each element of B is the image of some element of A
• A function f from A to B is onto if every element of B
is the image of some element in A,
i.e., if B = range of f
23
FIGURE 4 An Onto Function.
24
Example 11(p.138)
• 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 onto? [see Fig. on last slide]
• Solution: Because all three elements of the
codomain are images of elements in the domain,
f is onto.
25
Example 12(p.138)
26
One-to-one correspondence (bijection )
• Definition 8: A function f is a one-to-one correspondence
or a bijection if it is both one-to-one and onto.
• Example: Let f be the function from A to B where A={1,
2, 3, 4} and B = {a, b, c, d} with f(1)=d, f(2)=b, f(3)=c, and
f(4)=a, then f is bijective function.
– f is one-to-one since the function takes on distinct
values.
– f is onto since every element of B is the image of
some element in A.
– Hence f is a bijection
• Practice yourself: Example 14(p.138)
27
FIGURE 5 Examples of Different Types of
Correspondences
28
Inverse Functions
• Definition 9: Let f be a one-to-one
correspondence from A to B. The inverse
function of f is the function that assigns to an
element b belonging to B the unique element
a in A such that f(a)=b. Hence,
f-1(b) = a , when f(a) = b
29
FIGURE 6 The Function f - 1
Is the Inverse of Function
f
30
Inverse Functions
31
Example 16(p.140)
• 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 it is, what is its inverse?
32
Example 17(p.140)
• Let f: ZZ be such that f(x) = x +1.
Is f invertible? and if it is, what is its inverse?
• Solution: The function has an inverse because it is a
one-to-one correspondence, as we have shown.
To reverse the correspondence, suppose that y is the
image of x, so that y = x+1. Then x = y – 1.
This means that y – 1 is the unique element of Z that
is sent to y by f. Consequently, f -1 (y) = y – 1
33
Example 18(p.140)
• Let f be the function from R to R with f(x)=x2.
Is f invertible?
34
Homework
35
Section 2.3
36
Some Important Functions [Sec. 2.3, page.142]
33
Floor Function
• The floor function assigns to the real number x the
largest integer that is less than or equal to x.
– Let x be a real number. The floor function rounds x down
to the closest integer less than or equal to x.
38
Ceiling Function
39
Section 2.4
40
Sequences
• A sequence is a discrete structure used to represent
an ordered list.
– For example, 1, 2, 3, 5, 8 is a sequence with five elements
and 1, 3, 9, 27, 81 , ……., 30, …. is an infinite sequence.
41
Sequences
• Definition 1: A sequence is a function from a
subset of the set of integers to a set S. We use
an to denote the image of the integer n (a
term of the sequence)
– The sequence {an}
• Ex: an=1/n
42
Sequences
• Definition 2: A geometric progression is a sequence
of the form a, ar, ar2, …, arn, …
where the initial term a and the common ratio r are
real numbers
43
Some Useful Sequences
44
Summations
• Summation notation:
n
a j
n
j m
aj
1 j n
aj
j m
– am+am+1+…+an
• j: index of summation
• m: lower limit
• n: upper limit
45
Summations
46
Example 10 (p.154)
j 1
j 2 ?
47