Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

Functions

The document discusses functions and their properties. It defines functions and discusses one-to-one and onto functions. It provides examples of determining if functions have these properties and diagrams to illustrate one-to-one and onto functions.

Uploaded by

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

Functions

The document discusses functions and their properties. It defines functions and discusses one-to-one and onto functions. It provides examples of determining if functions have these properties and diagrams to illustrate one-to-one and onto functions.

Uploaded by

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

Lecture 7

Functions
Functions
Introduction
Example
Suppose that each student in a discrete mathematics class is assigned a
letter grade from the set {A, B, C, D, F}. And suppose that the grades are;
A for Adam, C for Ahmed, B for Hassan, A for Reema, and F for Saif.

Assignment of grades in a Discrete Mathematics Class

Adam ● ● A
Ahmed ● ● B
Hassan ● ● C
Reema ● ● D
Saif ● ● F

This assignment is an example of a function.


Functions
In discrete mathematics functions are used in the definition of such discrete
structures as sequences and strings.

Functions are also used to represent how long it takes a computer to solve
problems of a given size.

Many computer programs and subroutines are designed to calculate values of


functions.

Recursive functions, which are functions defined in terms of themselves, are used
throughout computer science
Functions
DEFINITION

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 : A → B.

Functions are sometimes also called mappings or transformations.

B
Functions
One-to-One and Onto Functions
Some functions never assign the same value to two different domain elements. These
functions are said to be one-to-one.

DEFINITION

A function f is said to be one-to-one, or an injunction, 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 injective if it is one-to-one.

A function is one-to-one if no two distinct elements of the domain have


the same image.
Functions
One-to-One Function

a ● ● 1
b ● ● 2
c ● ● 3
d ● ● 4
● 5
Note that a function f is one-to-one if and only if f (a) ≠ f (b) whenever a ≠ b.
This way of expressing that f is one-to-one is obtained by taking the
contrapositive of the implication in the definition.

f is one-to-one using quantifiers as ∀a ∀b (f (a) = f (b) → a = b) or


equivalently ∀a ∀b (a ≠ b → f (a) ≠ f (b))
Functions
Example
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.

The function f is one-to-one because f takes on different values at the four


elements of its domain.

Example
Determine whether the function f (x) = x2 from the set of integers to the set of
integers is one-to-one.

The function f (x) = x2 is not one-to-one because, for instance,


f (1) = f (−1) = 1, but 1 ≠ −1.
Functions

DEFINITION

A function f from A to B is called onto, or a surjection, if and


only if for every element b ∈ B there is an element a ∈ A with
f(a) = b. A function f is called surjective if it is onto.

A function f is onto if ∀y ∃x (f (x) = y), where the domain for x is


the domain of the function and the domain for y is the codomain
of the function.
Functions
Example
Determine whether the function f from {a, b, c, d} to {1, 2, 3} with
f(a) = 3, f(b) = 2, f(c) = 1, and f(d) = 3. is f an onto function?.

Because all three elements of the codomain are images of elements in the
domain, we see that f is onto. Note that if the codomain were {1, 2, 3, 4}, then
f would not be onto.

Example
Is the function f (x) = x + 1 from the set of integers to the set of integers onto?

This function is onto, because for every integer y there is an integer x such that
f (x) = y. To see this, note that f (x) = y if and only if x + 1 = y, which holds if
and only if x = y − 1.
Functions 144 1442 / Basic
2 / Structures: Sets, Functions,
Basic Structures: Sequences,
Sets, Functions, Sums,
Sequences, and and
Sums,
144 2 / Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Matrices
Matrices

Example
(a) One-to-one,
(a) One-to-one, (b) (b)Onto, Onto, (c) One-to-one,
(c) One-to-one, (d) Neither one-to
(d) Neither one
(a)
May 13, 2011 One-to-one,
10:24 (b)
not ontonot onto Onto, (c)
not one-to-one One-to-one, (d)
and onto Neither one-to-one (e)
nor nor N
ontoon
2011 10:24 not one-to-one and onto
not onto not 1one-to-one
a 1 a and onto
a a nor
1 onto
1a a
1 a a 1 a 1
a a 1 1
a 1 a
2 b 2 b b b 2 2b b
2 b b 2 b 2
b b 2 2
b 2 b
3 c 3 c 3 c c c c
3 c 3 3c c
3
c c 3 3
ctions, c 3 c
uences,Sequences,
Sums, and Sums,
Matricesand Matrices 4 d 4 d d d 4 4 4d d 4
4 d d d

(c) (c)FIGURE
One-to-one, FIGURE FIGURE
5 (d)Examples
One-to-one, Neither (d)5ofNeither
5 one-to-oneExamples
Examples
Different of
NotDifferent
of(e)Different
Types
one-to-one aof Types Types
aof
Correspondences.
(e) Not
function of Correspondences.
Correspondences.
function
-one and onto and onto nor onto nor onto
a a 1 a 1 a 1 1 1 1
1 a Solution:
This
Solution: Solution: function This
Thisais function
onto,
function because is for
is onto, onto, because
every
because for for
integer yevery
every there
int
b b 2 b 2 bf (x) = y. 2fTo y.2=Tonote
f=(x)
(x)see this, Tothat
y.see see f2this,
this, (x) note
note =that that
y if
2 and
f (x) = y=ififyxand
f (x)
only if+and=onl
1onlyy,i
2 x = y − 1. x =b yx − = 1.y − 1.b
c c 3 c 3 c 3 3 3 3
3 c c
d d EXAMPLE
4 d 4EXAMPLE
15 dConsider415
EXAMPLE 15
Consider
the function 4 f the function
in Example 4 f in
11 Example
that4assigns 11
Consider the function f in Example 11 that assigns job jobs that
to assigns
workers
for every for for every
job every
there is job there
a worker is a worker
assigned this assigned
job. Thethisthis job.f Th
function isf
least
job there is a worker assigned job. The
least one job that hasoneno job that assigned
worker has no worker
it. assigned it.
least one job that has no worker assigned it.
Functions
One-to-One and Onto
DEFINITION

The function f is a one-to-one correspondence, or a bijection, if it is both


one-to-one and onto. We also say that such a function is bijective.

Example
Let f be the function from {a, b, c, d} to {1, 2, 3, 4} with f(a) = 4, f(b) = 2,
f(c) = 1, and f(d)=3. Is f a bijection?

The function f is one-to-one and onto. It is one-to-one because no two values


in the domain are assigned the same function value. It is onto because all four
elements of the codomain are images of elements in the domain. Hence, f is a
bijection.
Functions
Inverse Functions

DEFINITION
Let f be a one-to-one correspondence from the set A to the set 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. The
inverse function of f is denoted by f −1. Hence, f −1(b) = a when f
(a) = b.

A one-to-one correspondence is called invertible because we can


define an inverse of this function. A function is not invertible if it is
not a one-to-one correspondence, because the inverse of such a
function does not exist.
Functions
Inverse Functions

f -1(a)
● ●
a = f -1(b) b = f(a)
f(a)
f(x)
f -1
A B
f
Functions
Example Laws of Log
Example Laws of Logic
Adam Khali
Let f be theExample
function from {a, b, c} to {1,2,3} such that f(a) = 2, f(b) = 3, and
Adam Khalid
f(c) = 1.let = {a, b, and
Is ffinvertible, c} ! if it{1,
is, 2, 3},isf (a)
what = 2, (f (b) = 3, f (c) = 1
its inverse?
findletf f 1= 1{a, b, c} ! {1, 2, 3}, f (a) = 2, (f (b) = 3, f (c) = 1
find f
The function
Solution f is invertible because it is a one-to-one correspondence.
The inverseSolution
function f −1 reverses the correspondence given by f , so
f 1 : {1, 2, 3} ! {a, b, c}, f 1 (1) = c, f 2 (2) = a, f 1 (3) =
f (1) = c,f 1f −1
−1
: (2)
{1, =2,a,
3}and f −1(3)
! {a, = b.f 1 (1) = c, f 2 (2) = a, f 1 (3) =
b, c},
b b
Functions
Example
Let f : Z → Z be such that f(x) = x + 1. Is f invertible, and if it is, what is its
inverse?
The function f has an inverse because it is a one-to-one correspondence. 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.
Functions
Example
Let f be the function from R to R with f (x) = x2. Is f invertible, and if it is, what is
its inverse?

Because f (−2) = f (2) = 4, f is not one-to-one. If an inverse function were


defined, it would have to assign two elements to 4. Hence, f is not
invertible.
Functions
Composite Functions

DEFINITION
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 for all a ∈ A by f ◦ g, is defined by
(f ◦ g) (a) = f (g(a)).
Functions
Composite Functions

(f ◦ g) (a)

g(a) f (g (a))

● ● ●
a g (a) f (g (a))
g(x) f(x)
A B C

(f ◦ g)
Functions
Example
Let g be the function from {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 ?

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, and

(f ◦ g) (c) = f (g (c)) = f (a) = 3.


Functions
Example
Let f and g be the functions from the set of integers to the set of
integers defined by f (x) = 2x + 3 and g (x) = 3x + 2. What is the
composition of f and g? What is the composition of g and f ?

Both the compositions f ◦ g and g ◦ f are defined. Moreover,


(f ◦g) (x) = f (g(x)) = f (3x + 2) = 2 (3x + 2) + 3 = 6x + 7

and
(g ◦ f )(x) = g (f (x)) = g (2x + 3) = 3 (2x + 3) + 2 = 6x + 11.
Functions
The Graphs of Functions

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

From the definition, the graph of a function f from A to B is the subset of


A × B containing the ordered pairs with the second entry equal to the
element of B assigned by f to the first entry. Also, note that the graph of a
function f from A to B is the same as the relation from A to B determined
by the function f .
an integer. This graph is displayed in Figure 9.

Functions Some Important Functions


Example Next, we introduce two important functions in discrete mathematics, namely, t
functions. Let x be a real number. The floor function rounds x down to the
Display the graph of thethanfunction
or equal fto(n) = 2n
x, and the+ceiling
1 from the set
function of integers
rounds to closest inte
x up to the
the set of integers. equal to x. These functions are often used when objects are counted. They
role in the analysis of the number of steps used by procedures to solve probl
The graph of f is the setsize.
of ordered pairs of the form (n, 2n + 1), where n
is an integer.
(–3,9)

(–2,4)

(–1,1)

The Graph8 ofThe


FIGURE f(n)=2n+1
Graphfrom
of Z to Z FIGURE 9 The G
f (n) = 2n + 1 from Z to Z. f (x) = x 2 from Z t
Functions
portant Functions
Example
oduce two important functions in discrete mathematics, namely, the floor and ceiling
t x be a real number. The floor function rounds x down to the closest integer less
to x, and theDisplay the graph
ceiling function of xthe
rounds upfunction f (x)integer
to the closest = x2 greater
from the
thanset
or of integers to the
hese functions setareofoften
integers.
used when objects are counted. They play an important
alysis of the number of steps used by procedures to solve problems of a particular
The graph of f is the set of ordered pairs of the form (x, f (x)) = (x, x2),
where x is an integer.
(–3, 9) (3, 9)

(–2, 4) (2, 4)

(–1, 1) (1, 1)

(0, 0)

The Graph of f (x) = x2 from Z to Z


The Graph of FIGURE 9 The Graph of
1 from Z to Z. f (x) = x 2 from Z to Z.
Functions
Some Important Functions
Two important functions in discrete mathematics are, the floor and
ceiling functions.

DEFINITION
The floor function assigns to the real number x the largest integer
that is less than or equal to x. The value of the floor function at x
is denoted by ⌊x⌋.
The ceiling function assigns to the real number x the smallest
integer that is greater than or equal to x. The value of the ceiling
function at x is denoted by ⌈x⌉.
Functions
Example
Write the values of the floor and ceiling functions given below:

!!
== 0 ⌊3.1⌋
⌊3.1⌋== 3
""

!!
== 1 ⌈3.1⌉
⌈3.1⌉== 4
""

! !
− − = =1 ⌊7⌋
⌊7⌋ == 7
" "

! !
− −= 0 ⌈7⌉
⌈7⌉ = 7
" "
Functions
Example
Data stored on a computer disk or transmitted over a data network are
usually represented as a string of bytes. Each byte is made up of 8 bits.
How many bytes are required to encode 100 bits of data?

To determine the number of bytes needed, we determine the smallest


integer that is at least as large as the quotient when 100 is divided by
8, the number of bits in a byte.
Consequently, ⌈100/8⌉ = ⌈12.5⌉ = 13 bytes are required.
Functions
Useful Properties of the Floor and Ceiling Functions.
(n is an integer, x is a real number)

(1a) ⌊x⌋ = n if and only if n ≤ x < n + 1


(1b) ⌈x⌉ = n if and only if n −1 < x ≤ n
(1c) ⌊x⌋ = n if and only if x −1 < n ≤ x
(1d) ⌈x⌉ = n if and only if x < n ≤ x + 1
(2) x − 1 < ⌊x⌋ ≤ x ≤ ⌈x⌉ < x + 1
(3a) ⌊−x⌋ = −⌈x⌉
(3b) ⌈−x⌉ = −⌊x⌋
(4a) ⌊x + n⌋ = ⌊x⌋ + n
(4b) ⌈x + n⌉ = ⌈x⌉ + n
Tutorial 7
Chapter 2.3 (page 152)
Questions
1, 8, 9, 10, 11, 12, 13, 16, 17, 22, 23
30, 31, 36, 37, 42, 62, 69

You might also like