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

Week 6 - Functions

Module for week 6

Uploaded by

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

Week 6 - Functions

Module for week 6

Uploaded by

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

Functions

5 FUNCTIONS
The student’s grade in a course is a function of the student’s performance. Many computer programs
and subroutines are designed to calculate values of functions. Hence, the concept of function is
important in mathematics and computer science. In the previous module, we have discussed truth
tables which can be regarded as Boolean function. In this module, the focus will be on discrete sets and
the use of function in mathematics.

Objectives:

After completing this module, you should be able to:

1. Explain the concept and uses of functions.


2. Describe the domain, the codomain, the range, and the assignment of values to elements of the
domain of a function.
3. Analyze functions as to one-to-one, onto, and one-to-one correspondence.

DISCRETE STRUCTURES 1 41
Functions

Introduction

 In many instances, we assign to each element of a set a particular element of a second set
(which may be the same as the first).
 For 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 Adams, C for Chou, B for
Goodfriend, D for Rodriguez, and F for Stevens.
 This assignment is an example of a function. The concept of a function is extremely important in
mathematics and computer science.
 For example, 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.

Function

 A function f from a set A to a set B is an assignment of exactly one element of B to each element
of A.
 if b is the unique element of B assigned by the function f to the element a of A.
 We write f(a) = b
 If f is a function from A to B,
 we write f: AB
(note: Here, ““ has nothing to do with if… then)

If f:AB, we say that A is the domain of f and B is the codomain of f.

If f(a) = b, we say that b is the image of a and a is the pre-image of b.

The range of f:AB is the set of all images of elements of A.

We say that f:AB maps A to B.

Example:

Let us take a look at the function f:PC with

P = {John, Peter, Liza, Don}

C = {Singapore, Philippines, India, Malaysia}

DISCRETE STRUCTURES 1 42
Functions

Let us re-specify f as follows:

f(John) = Singapore

f(Peter) = Philippines

f(Liza) = India

f(Don) = Malaysia

Here, the range of f is {Singapore, Philippines, India, Malaysia}

Then

f(John) = Singapore

f(Peter) = Philippines

f(Liza) = India

f(Don) = Malaysia

Here, the range of f is C.

Other ways to represent f:

DISCRETE STRUCTURES 1 43
Functions

The definition of a function implies that the arrow diagram for a function f has the
following two properties:

1. Every element of X has an arrow coming out of it

2. No two elements of X has two arrows coming out of it that point to two different
elements of Y.

Example:

Let

X = {a, b, c} and Y = {1, 2, 3, 4}.

Define a function f from X to Y using the


arrow diagram

Domain and co-domain of f

domain of f = {a, b, c}, co-domain of f = {1, 2, 3, 4}

f(a), f(b), and f(c)

f (a) = 2, f (b) = 4, f (c) = 2

Range of f

{2, 4}

The inverse image of c

2, and b is not an inverse image of 3.

inverse image of 2

{a, c}

inverse image of 4

{b}

inverse image of 1

DISCRETE STRUCTURES 1 44
Functions

∅ (since no arrows point to 1)

f is represented as a set of ordered pairs

{(a, 2), (b, 4), (c, 2)}

There are no arrows pointing to the 1 or the 3.

This illustrates the fact that although each element of the domain of a function must have an
arrow pointing out from it, there can be elements of the co-domain to which no arrows point.

Note also that there are two arrows pointing to the 2—one coming from a and the other from c.

Example:

Let f be the function that assigns the last two bits of a bit string of length 2 or greater to that
string.

For example, f (11010) = 10. Then, the domain of f is the set of all bit strings of length 2 or
greater, and both the codomain and range are the set {00, 01, 10, 11}.

Let f : Z  Z assign the square of an integer to this integer. Then, f (x) = x2, where the domain of
f is the set of all integers, the codomain of f is the set of all integers, and the range of f is the set
of all integers that are perfect squares, namely, {0, 1, 4, 9, . . . }.

Exercise

Which of the arrow diagrams define functions from X = {a, b, c} to Y = {1, 2, 3, 4}?

Justify your answer.

If the domain of our function f is large, it is convenient to specify f with a formula.

Example:

Let

f:RR

f(x) = 2x

DISCRETE STRUCTURES 1 45
Functions

This leads to:

f(1) = 2

f(3) = 6

f(-3) = -6

DISCRETE STRUCTURES 1 46
Functions

Example:

Let

f1 and f2 be functions from A to R.

Then

the sum and the product of f1 and f2 are also functions from A to R defined by:

(f1 + f2)(x) = f1(x) + f2(x)

(f1f2)(x) = f1(x) f2(x)

Note that the functions f1 + f2 and f1f2 have been defined by specifying their values at x in terms
of the values of f1 and f2 at x.

Example:

f1(x) = 3x,

f2(x) = x + 5

(f1 + f2)(x) = f1(x) + f2(x) = 3x + x + 5 = 4x + 5

(f1f2)(x) = f1(x) f2(x) = 3x (x + 5) = 3x2 + 15x

Exercise

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?

We already know that the range of a function f:AB is the set of all images of elements aA.

If we only regard a subset S  A, the set of all images of elements sS is called the image of S.

We denote the image of S by f(S):

f(S) = {f(s) | s  S}

DISCRETE STRUCTURES 1 47
Functions

Example:

Let us take a look at the function

f(John) = Singapore

f(Peter) = Philippines

f(Liza) = Singapore

f(Don) = Malaysia

If S={Peter, Don} then f(S)={Philippines, Malaysia}

If S={John, Liza} the f(S)={Singapore}

Exercise

Let

A = {a, b, c, d, e}

B = {1, 2, 3, 4}

with f(a)=2, f(b)=1, f(c)=4, f(d)=1, and f(e)=1.

The image of the subset S = {b, c, d}

Find f(S) = ?

Types of functions

1. One-to-one
2. Onto
3. One-to-one correspondence

One-to-one

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

Thus, f is one-to-one if, and only if, it does not map


two distinct elements of A onto the same element
of B.

A function is said to be injective if it is one-to-one.

Note that a function f is one-to-one if and only if f (a) = f (b) whenever a = b.

DISCRETE STRUCTURES 1 48
Functions

This way of expressing that f is one-to-one is obtained by taking the contrapositive of


the implication in the definition.

Example:

Let us take a look at the function f

f(John) = Singapore

f(Peter) = Philippines

f(Liza) = Singapore

f(Don) = Malaysia

Is f One-to-one?

No, John and Liza are mapped onto the same element of the image.

Let us take a look at the function g

g(John) = Singapore

g(Peter) = Philippines

g(Liza) = India

g(Don) = Malaysia

Is g One-to-one?

Yes, each element is assigned a unique element of the image.

Exercise

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.

Illustrate your answer using a diagram.

DISCRETE STRUCTURES 1 49
Functions

Onto

 A function f:A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.

In other words, f is onto if, and only if, its range is its entire codomain.
That is, f is onto if every element of its co-domain is the image of some element(s) of its
domain. Thus, co-domain of f = range of f
Using the arrow diagram, a function is onto if each element of the co-domain has an
arrow pointing to it from some element of the domain.

A function is not onto if at least one element in its co-domain does not have an arrow
pointing to it.

Exercise

Determine whether the function f from {a, b, c, d, e} to {1, 3, 4, 5} with f(a)=4, f(b)=5, f(c)=1, f(d)=3, and
f(e)=1 is onto.

Illustrate your answer using a diagram.

DISCRETE STRUCTURES 1 50
Functions

One-to-one correspondence

 A function f: AB is a one-to-one correspondence, or a bijection, if, and only if, it is both one-
to-one and onto.
 Obviously, if f is a bijection and A and B are finite sets, then |A| = |B|.

Consider a function F: AB that is both one-to-one and onto. Given any element x in A,
there is a unique corresponding element b = F(a) in B (since F is a function).

Also given any element b in B , there is an element a in A such that F(a) = b (since F is
onto) and there is only one such a (since F is one-to-one).

Thus, a function that is one-to-one and onto sets up a pairing between the elements of
A and the elements of B that match.

Exercise

Determine whether the function f from {a, b, c, d} to {1, 3, 4, 5} with f(a)=4, f(b)=5, f(c)=1, and f(d)=3 is
one-to-one correspondence.

Illustrate your answer using a diagram.

DISCRETE STRUCTURES 1 51
Functions

References:

1. Kenneth H. Rosen. Discrete Mathematics and Its Applications, 7th Edition. McGrawHill, 2012
2. Gary Weiss Damian Lyons, et al., Fundamentals of Discrete Structures, 2nd edition, Pearson
Learning Solutions, 2012.
3. Susanna S. Epp, Discrete Mathematics with Applications, Brooks Cole; 4th edition, 2011.
4. James L. Hein, Discrete Structures, Logic, and Computability, 3rd edition, Jones & Bartlett
Publishers, 3rd edition, 2009.
5. Kolman, B., Busby, R. C., Ross, S. C. Discrete Mathematical Structures, 6th Edition. Prentice Hall,
2008.

DISCRETE STRUCTURES 1 52

You might also like