Sie sind auf Seite 1von 45

1

Functions
2
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 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.
Definition: Function
3
Example
Function that assigns a grade to a student in our DM class:
X = {Neha, Divya, Deepak, Nitish}, Y = {A, B, C, D, E, F}
f: X Y, f(Neha)=C, f(Divya)=A, f(Deepak)=A, f(Nitish)=B
Y
A
B
C
D
E
F
X
Neha
Divya
Depak
Nitish




Arrow Diagram of f:
4
If f is a function from A to B, we say that A is
the domain of f and B is the co-domain of f.
if f(a) = b, we say that b is the image of a and a
is a 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 f
maps A to B.
A Few Terms
5
Example
X
Y
A
B
C
D
E
F
Neha
Divya
Depak
Nitish




X = domain of f
Y = co-domain of f
f(Divya) = A: A is the image of Divya
Divya is a pre-image of A, Depak is also a pre-image of A
E has no pre-image
Range(f) = {A, B, C}
Range of f
6
Example
Let f be the function from Z
to Z that assigns the square
of an integer to this integer,
Then, f: Z Z, f(x) = x
2
Range(f) =

{0, 1, 4, 9, 16, 25,
.}
Z
:
4
3
2
1
0
1
:
Z
:
2
1
0
1
2
:
7
Example
Functions and Nonfunctions: Which of the arrow
diagrams defines a function from X = {a,b,c} to Y =
{1,2,3,4} ?
a
b
c
1
2
3
4
f
a
b
c
1
2
3
4
g
a
b
c
1
2
3
4
h
No,
b has no image
No,
c has two images
Yes,
each element of X has
exactly one image
8
Definition: f
1
+ f
2
and f
1
f
2

Let f
1
and f
2
be functions from A to B
Then f
1
+ f
2
and f
1
f
2
are also functions from
A to B defined by
(f
1
+ f
2
)(x) = f
1
(x) + f
2
(x),
(f
1
f
2
)(x) =f
1
(x)f
2
(x)

9
Example
Let f
1
and f
2
be functions from R to R such
that
f
1
(x) = x
2
and f
2
(x) = xx
2
;
What are the functions f
1
+ f
2
and f
1
f
2
?
(f
1
+ f
2
)(x) = f
1
(x) + f
2
(x) = x
2
+x x
2
= x
(f
1
f
2
)(x) = f
1
(x) f
2
(x) = x
2
(xx
2
) = x
3
x
4

10
One-to-One Functions
A function f is one-to-one (or injective), iff f (x)
= f(y) implies x = y for all x and y in the domain
of f.
In other words:
All elements in the domain of f have different
images or
No element in the co-domain of f has two (or more)
pre-images
11
One-to-One Functions
f:AB is one-to-one x,yeA (f(x)=f(y) x=y)
Negation:
There are two different elements in the domain
of f with the same image
f:AB is not one-to-one
-x,yeA (f(x)=f(y).x=y)
Contrapositive:
f:AB is one-to-one x,yeA (x=y f(x)=f(y))
12
Example
one-to-one
(all elements in A have
a different image)
not one-to-one
(a and b have the same
image)
a
b
c
1
2
3
4
A B
a
b
c
1
2
3
4
A
B
Which of the following functions is one-to-one?
13
Example
Is f: R R, f(x) = 4x1 one-to-one?
To show:
x
1
, x
2
e R (f(x
1
)=f(x
2
) x
1
= x
2
)
Suppose arbitrary x
1
, x
2
e R
with f(x
1
) = f(x
2
).
Then 4x
1
1 = 4x
2
1
4x
1
= 4x
2
x
1
=x
2

Yes !
(Do all elements in R have a different image ?)
14
Example
Is g: R R, g(x) = x
2
one-to-one?
To show:
- x
1
, x
2
e R (g(x
1
)=g(x
2
) . x
1
= x
2
)
Take x
1
= 2 and x
2
= 2.
Then
g(x
1
) = 2
2
= 4 = (2)
2
= g(x
2
) and x
1
= x
2

No !
(Do all elements in R have a different image ?)
15
Onto Functions
A function f from X to Y is onto (or surjective),
iff for every element yeY there is an element
xeX with f(x)=y.
In other words:
All elements in the co-domain of f have a pre-
image
16
Onto Functions
f:XY is onto yeY -xeX such that f(x) = y
Negation:
There is an element in the co-domain of f which
has no pre-image
f:XY is not onto
-yeY such that xeX f(x) = y
17
Example
onto
(all elements in Y have
a pre-image)
a
b
c
1
2
3
X
Y
d
not onto
(1 has no pre-image)
a
b
c
1
2
3
X
Y
d
Which of the following functions is onto?
18
Example
Is f:RR, f(x)=4x1 onto ?
To show: yeR -xeR such that f(x) = y
Let yeR.
[Calculate x with f(x)=y: y = 4x1
(y+1)/4 = x ]
Let x = (y+1)/4 eR
Then f(x) = 4x1 = 4((y+1)/4) 1
= (y+1) 1 = y
Yes !
(Do all elements in R have a pre-image ?)
19
Example
Is g:RR, g(x)=x
2
onto ?
To show: -yeR such that xeR g(x) = y
Take y = 1 eR
Then any xeR holds g(x) = x
2
= 1 = y
But g:RR
+0
, g(x)=x
2
,(where R
+0
denotes
the set of non-negative real numbers) is
onto!

(Do all elements in R have a pre-image ?)
No !
20
Is f:Z
+0
Z
+0
Z
+0
, f(l,m)=l + m onto or one-to-
one or both ?
Let ne Z
nonneg
.
Then f((0,n))= 0+n = n
One-to-one: Do all elements in
Z
nonneg
have a different image ?
Onto: Do all elements in Z
+0

have a pre-image ?
Yes !
f((1,1))= 1+1 = 2 = 2+0 = f((2,0))
Z
+0

0
1
2
3
4
:
:
Z
+0
Z
+0
(0,0)
(0,1)
(1,0)
(1,1)
(2,0)
(0,2)
(2,1)
(1,2)
(3,0)
(0,3)
(4,0)
:
Example
No !
21
A function f is a one-to-one correspondence (or
bijection), iff it is both one-to-one and onto
In other words:
No element in the co-domain of f has two (or
more) pre-images (one-to-one) and
All elements in the co-domain of f have a pre-
image (onto)
One-to-one Correspondence
22
f is a one-to-one correspondence All
elements in the co-domain of f have exactly one
pre-image
f is not a one-to-one correspondence there
exists an element in the co-domain of f which
has not exactly one pre-image
One-to-one Correspondence
23
Example
Which of the following functions is a bijection?
No
(not onto, 2
has no pre-
image)
No
(not one-to-
one, 1 has
two pre-
imags)
a
b
c
1
2
3
d
Yes
(each element
has exactly one
pre-image)
a
b
c
1
2
3
d 4
a
b
c
1
2
3
4
No
(neither one-
to-one nor
onto)
a
b
c
1
2
3
d 4
No
(not a function,
a has two
images)
a
b
c
1
2
3
4
24
Example
The identity function on a set A:
i
A
:AA, i
A
(x) = x.
is a bijection.
e.g. for A = {a, b, c, d, e}:
A
a
b
c
d
e
A
a
b
c
d
e
25
Example
Let
3
be the set of all strings of length 3 made up of 0s
and 1s, i.e.
3
= {000, 001, 010, 100, 011, 110, 101,
111}. h: P({a,b,c})
3
, h(X) = s
1
s
2
s
3
, with
s
1
=
1 if aeX
0 otherwise
Is h a bijection ?
C
P({a,b,c})
{a}
{b}
{c}
{a,b}
{a,c}
{b,c}
{a,b,c}

3

000
001
010
100
011
110
101
111
Yes !
P({a,b,c})
and
3
have
the same
cardinality !
s
3
=
1 if ceX
0 otherwise
s
2
=
1 if beX
0 otherwise
26
Inverse Functions
Let f:AB be a one-to-one correspondence
A
B
f
f
1

b
a
f(a)=b
f
1
(b)=a
Then there is a function f
1
:BA, that is defined
as follows:
f
1
is called the inverse function of f
f
1
(b) = that unique element aeA such that f(a)=b.
27
Example
a
b
c
1
2
3
f
A B
d 4
A B
a
b
c
1
2
3
d 4
f
1

Find the inverse function of the following function:
In other words:
Let f:AB be a one-to-one correspondence and
f
1
:BA its inverse. Then it holds
beB aeA (f
1
(b)=a b=f(a))
28
Inverse Functions
A one-to-one correspondence is called invertible
A function is not invertible if it is not a one-to-
one correspondence (since the inverse of such a
function does not exist)
A
B
f
f
1

b
a
f(a)=b
f
1
(b)=a
29
Example
What is the inverse of f:RR, f(x)=4x1?
Let yeR.
Calculate x with f(x)=y:
y = 4x1 (y+1)/4 = x
Hence, f
1
(y) = (y+1)/4
30
Example
What is the inverse of g:RR, g(x)=x
2
?
g is not invertible !
31
Inverse Functions
Theorem 1: If f:XY is a one-to-one
correspondence, then f
1
:YX is a one-to-one
correspondence.
Proof:
(a) f
1
is one-to-one: take arbitrary y
1
,y
2
eY
such that f
1
(y
1
) = f
1
(y
2
)
to show: y
1
= y
2
Let x = f
1
(y
1
) = f
1
(y
2
)
Then f(x) = y
1
and f(x) = y
2
by definition
Therefore, y
1
= y
2
X
Y
f
f
1
x
y
1

y
2

f
1
(y
1
)

f
1
(y
2
)

32
Inverse Functions
Theorem 1: If f:XY is a onto correspondence,
then f
1
:YX is a onto correspondence.
Proof:
(b) f
1
is onto:
take arbitrary xeX
to show: -yeY s.t. f
1
(y) = x
Let y = f(x)
Then f
1
(y) = x
X
Y
f
f
1
x
y
f(x)

f
1
(y)

33
A B C
f
g
Composition of Functions
g(f(a))
Let f:AB and g:BC be functions. The
composition of the functions f and g, denoted
as g f, is defined by: g f: A C, (g f)(a) =
g(f(a))
= (gf)(a)
g f
a
f(a)
34
Example
a
b
c
1
2
3
f
X
Y
4
5
m
n
p
Z
q
g
g f is not defined,
because
range(f)={m,n,p,q} is not
a subset of X={a,b,c}
Find f g and g f
a
b
c
m
n
p
q
f g
X
Z
1
2
3
Y
4
5
m
n
p
Z
q
f
a
b
c
1
2
3
X
Y
4
5
g
35
Example
Let f:ZZ, f(n)=2n+3 and g:ZZ, g(n)=3n+2.
What is g f and f g?
(f g)(n) = f(g(n)) = f(3n+2) = 2(3n+2) + 3 = 6n+7
(g f)(n) = g(f(n)) = g(2n+3) = 3(2n+3) + 2 = 6n+11
Hence, f g = g f
Hence, the commutative law does not hold for the
composition of functions !
36
Composition of Functions
Composing an invertible function with its
inverse:
a
b
c
1
2
3
f
A B
d 4
A B
a
b
c
1
2
3
d 4
f
1

a
b
c
A
d
a
b
c
A
d
f
1
f
1
2
3
4
1
2
3
4
B B
f f
1
In general:
if f:XY is invertible with the inverse function
f
1
:YX, then f
1
f = i
X
and f f
1
= i
Y
37
Composition of Functions
Let f:XY and g:YZ be two one-to-one functions.
Must g f also be one-to-one?
a
b
c
g f
X
1
2
3
Z
4
5
a
b
c
X
g f
1
2
3
Z
4
5
w
Y
x
y
z
38
Composition of Functions
Theorem 2: Let f:XY and g:YZ be both one-
to-one functions. Then g f is also one-to-one.
Proof: to show:
x
1
, x
2
e X ((g f )(x
1
) = (g f )(x
2
) x
1
= x
2
)
Suppose x
1
, x
2
e X with (g f )(x
1
) = (g f )(x
2
).
Then g (f (x
1
))=g(f (x
2
)).
Since g is one-to-one, it follows f (x
1
) = f (x
2
).
Since f is one-to-one, it follows x
1
= x
2
.

39
X
Y
Z
f g
Composition of Functions
Theorem 2: Let f:XY and g:YZ be both one-
to-one functions. Then g f is also one-to-one.
x
1
g(f (x
1
))=g(f (x
2
))
x
2
f (x
1
)=f (x
2
)
=

40
a
b
c
X
d
e
g f
a
b
c
X
d
e
1
2
3
Z
Composition of Functions
Let f:XY and g:YZ be two onto functions.
Must then g f also be onto ?
Is this example an accident?
g
1
2
3
Z
f
w
Y
x
y
z
41
Composition of Functions
Theorem 3: Let f:XY and g:YZ be both
onto functions. Then g f is also onto.
Proof: to show:
zeZ -xeX such that (g f )(x) = z
Let zeZ.
Since g is onto -yeY with g(y)=z.
Since f is onto -xeX with f(x)=y.
Hence, with (g f )(x) = g(f (x)) = g(y) = z.



42
X
Y
Z
f g
Composition of Functions
Theorem 3: Let f:XY and g:YZ be both
onto functions. Then g f is also onto.
z
g(y)=z
y
x
f(x)=y
(g f )(x) = z
43
x
y
z
Y
Composition of Functions
If f:XY and g:YZ are functions and
g f:XZ is one-to-one, must both f and g be
one-to-one?
a
b
c
X
1
2
3
Z
w
a
b
c
g f
X
1
2
3
Z
g
f
Found a
counterexample!
g f is one-to-
one, but g is not !
44
Composition of Functions
If f:XY and g:YZ are functions and g f :
XZ is onto, must both f and g be onto?
45
Summary
Definitions
One-to-One Functions
Onto Functions
One-to-one correspondences (bijections)
Inverse Functions
Composition of Functions

Das könnte Ihnen auch gefallen