Вы находитесь на странице: 1из 22

FUNCTIONS

DEFINITION 1

Let A and B be 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 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.

Assignment of Grades in a Discrete Mathematics Class.


The function f Maps A to B

f
a b = f(a)

A f B
DEFINITION 2
If f is a function from A to 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 the pre-image of b.
The range of f is the set of all images of elements of
A. Also, if f is a function from A to B, we say that f
maps A to B.
Example 1: Let f be the function that assigns the last
two bits of a bit string of length 2 or greater to that
string. Then, the domain of f is the set of all bit strins
of length 2 or greater, and both the codomain and
range are the set {00,01,10,11}.
DEFINTION 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).
Example:
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
(f1+f2)(x) = x2 + x - x2 = x
(f1f2)(x) = x2(x-x2) = x3 – x4.
DEFINITION 4
Let f be a function from the set A to the set B and let S
be a subset of A. The image of S is the subset of B
that consists of the images of the elements of S. We
denote the image of S by f(S), so that
f(S) = {f(s) | s  S}
Example:
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, and f(e) = 1. The image
of the subset S = {b,c,d} is the set f(S) = {1,4}.
ONE-TO-ONE AND ONTO FUNCTIONS
DEFINITION 5
A function f is said to be one-to-one, or injective, if and
only if f(x) = f(y) implies that x=y for all x and y in
the domain of f. A function is said to be an injection if
it is one-to-one.
EXAMPLE:
Determine whether the function f from {a,b,c,d} to
{1,2,3,4,5} with f(a) = 4, f(d) = 5, f(c)=1, and f(d) = 3
is one-to-one.
Solution: The function f is a one-to-one since 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.
Solution: The function f(x) = x2 is not one-to-one
because for instance, f(1)= f(-1)= 1, but 1  -1. Note
that the function f is one-to-one if its domain is
restricted to Z+.
Example: Determine whether the function f(x)= x+ 1 is
one-to-one.
Solution: The function f(x)= x+1 is a one-to-one
function. To demonstrate this, note that x+1  y+1
when x  y.
DEFINITION 6
A function f from A to B is called onto, or
surjective, iff 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.
Example:
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
function?
Solution:
Since all three elements of the codomain are images of
elements in the domain, we see that f is onto.
Example:Is the function f(x)=x2 from the set of integers
to the set of integers onto?
Solution: The function f is not onto since there is no
integer x with x2-1, for instance.
Example: Is the function f(x)=x+1 from the set of
integers to the set of integers onto?
Solution: This function is onto, since every integer y
there is an integer x such that f(x)=y.
DEFINITION 8
The 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,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?

Solution: Yes.
INVERSE FUNCTIONS AND COMPOSITIONS
OF FUNCTIONS
DEFINITION 9
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.
f-1(b)
f (a)
a =f-1(b) b = f(a)
f -1
A f B
EXAMPLE: 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?
Solution: The function f is invertible since it is one-to-one
correspondence. The inverse function f-1 reverses the
correspondence given by f, so that f-1(1)=c, f-1(2)=a, and
f-1(3)=b.
EXAMPLE: Let f be the function from the set of integers to the
set of integers such that f(x)=x+1. Is f invertible, and if it is,
what is its inverse?
Solution:The function has an inverse since it is one-to-one
correspondence.
f(x)= y = x+1; x = y – 1= f(y)
x=2; f(2)=2 + 1 = 3; f(3) = 3 – 1 = 2.
EXAMPLE: Let f be the function from Z to Z with f(x) = x2. Is f
invertible?
Solution: Since f(-1) = f(1) = 1, f is not one-to-one. If an inverse
function were defined, it would have to assign two elements to
1. Hence, f is not invertible.

DEFINITION 10
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
function f and g, denoted by f  g, is defined by
( f  g)(a) = f(g(a)).
EXAMPLE:
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, and (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.
EXERCISES

1. Why is f not a function from R to R if a) f(x)=1/x? b) f(x)=x1/2?


c) f(x)= ((x2+1))1/2?
2. Determine whether f is a function from Z to R if a)f(n)= n
b)f(n)=(n2+1)1/2 c) f(n)=1/(n2-4).
3. Determine whether f is a function from the set of all bit strings
to the set of integers if a) f(S) is the position of a 0 bit in S. b)
f(S) is the number of 1 bits in S. c) f(S) is the smallest integer I
such that the ith bit of S is 1 and f(S)=0 when S is the empty
string, the string with no bits.
4. Determine whether each of these functions from Z to Z is one-
to-one. a)f(n)=n-1, b) f(n)=n2+1, c)f(n)=n3, d) f(n)=n/2 
5. Which functions in #4 are onto?
6. Determine whether f:ZxZ  Z is onto if a)f(m,n)=2m-n,
b)f(m,n)=m2-n2, c)f(m,n)=m.
7. Determine whether each of these functions is a bijection from
R to R. a) f(x)=-3x+4, b) f(x)=-3x2+7, c) f(x)=(x+1)/(x+2),
d) f(x)=x5 + 1
8. Let f be the function from R to R defined by f(x)=x2. Find
a) f-1 ({1}), b) f-1({x|0<x<1}), c) f-1({x|x>4})
THE GROWTH OF FUNCTIONS
BIG-O NOTATION
Definition 1 Let f and g be functions from the set of integers or
the set of real numbers to the set of real numbers. We say that
f(x) if O(g(x)) if there are constants C and k such that
|f(x)|  C|g(x)|
whenever x>k. (This is read as “f(x) is big-oh of g(x).”)
EXAMPLE: Show that f(x)= x2 + 2x+ 1 is O(x2).
Solution: We observe that we can readily estimate the size of f(x)
when x>1 because x<x2 and 1<x2 when x>1. It follows that
0  x2+2x+1  x2+2x2+ x2=4x2. When x>1, C=4 and k=1.
The function x2+2x+1 is O(x2)
f(x) 4x2 x2+2x+1 x2

k=1 x
EXAMPLE: Show that 7x2 is O(x2).
Solution:Note that x>7, we have 7x2<x3. C=1 and k=7.

THEOREM 1 Let f(x) = anxn + an-1xn-1+…+ a1x + a0, where


a0,a1,…,an-1, an are real numbers. Then f(x) is O(xn).

EXAMPLE: How can big-O notation be used to estimate the sum


of the first n positive integers?
Solution:
1+2+3+…+n  n+n+…+n = n2
From this inequality it follows that 1+2+3+..+n is O(n2), taking
C=1 and k=1.
EXAMPLE: Give big-O estimate for the factorial function and
the logarithm of the factorial function, where the factorial
function f(n)=n! is defined by n!=1.2.3.4…n whenever n
is positive integer, and 0!=1.
Solution: n! = 1.2.3.4…n
 n.n.n…n = nn O(nn) C= 1 and k=1
f(n) = log n!
log n!  log nn = n log n O(n log n) C=1 and k=1

HAVE A
EXERCISES
1. Determine whether each of these function is O(x).
a) f(x) = 10 b) f(x) = 3x + 7, c) f(x)= x2+ x + 1,
d) f(x) = 5 log x, e) f(x) = x , f) f(x) = x/2
2. Determine whether each of these function is O(x2).
a) f(x)=17x + 11, b) f(x)= x2 + 1000,
c) f(x)=x log x, d) f(x) = x4/2, e) f(x) = 2x
3. Show that x4 + 9x3 + 4x +7 is O(x4).
4. Find the least integer n such that f(x) is O(xn) for each of
these functions. a)f(x)=2x3 + x2 log x, b) f(x) 3x3 + (log x)4
c) f(x)=(x4 + x2 + 1)/(x3+1), d) f(x)= (x4 + 5 log x)/(x4+1)