0% found this document useful (0 votes)
9 views

Functions - ComMSc (1)

Uploaded by

usj.dcs
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Functions - ComMSc (1)

Uploaded by

usj.dcs
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 69

M.Sc.

in Computer Science

Functions
By
Naleen Ganegoda
Department of Mathematics
University of Sri Jayewardenepura
Functions
At the end of this lesson you will be able to

1. identify the rule of a function.


2. determine domain, codomain and range of a
function.
3. plot a function in a coordinate plane.
4. carryout arithmetic operations on functions
and recognize the equality of functions.
5. construct compositions of functions.
6. recognize one-to-one and onto functions.
7. construct the inverse of a function.
Components of a function
Let A and B be non-empty sets. Suppose each
element in A is assigned by a certain rule to a
unique element in B. This assignment is called a
function (mapping) from A to B. Then, the set A
is called the domain and the set B is called the
codomain. The rule that assigns elements from A
to B is considered as the rule of the function.
x f y
input output

Rule
A B
(Domain) (Codomain)

f
Notation : f : A B or A   B

eg. Rule of raising to the power 2 (or squaring)

x squaring y x 2
So, rule can be expressed as f(x)  x 2 , where generally f(x)
is for " function of x ". Alternativ ely it can be denoted by
x  x 2 as well.

eg. Let A { 1, 1, 2} , B {1, 2, 3, 4}


f :A B
f(x)  x 2

1 1
1 2
2 3
4
Ex. Denote the function t hat raises elements to the power 4
from the set of real numbers to the set of non - negative
real numbers.
f :    0 (or  0 or  0 )
f(x)  x 4
Remark : There are rules which do not describe a function.
eg. Rule : assign x to a value whose square is equal to x .
x
x
 x
This is not a unique assignment .
So, it cannot be a rule of a function.
Remark : Because of the unique assignment in a function,
different outputs are associated with different inputs.
To convince this feature, functions are said to be
" single - valued " or " well - defined " . Then, the other
rules without t he unique assignment may be reffered as
" multi - valued " .
Range of a function
Let f be a function w ith f : A B. Suppose a  A is
assigned to b  B by f ( ie. f(a)  b). Then b is called the
image of a. Set of all images of the elements in the domain
is called the range of the function. Usually, it is denoted by
f (A) . Note that f (A)  B.

eg. Let A { 1, 1, 2} , B {1, 2, 3, 4}


f :A B
f(x)  x 2
Image of  1 is f  1 1
Image of 1 is f 1 1 So, Range of f {1, 4}
Image of 2 is f 2  4

Remark : Real - valued and complex - valued functions


(Refer : See what happens to the images of these functions)

Ex . Let f :   f (0) 0
f ( x)  x f ( 1)  f (1) 1
f ( 2)  f (2) 2
What is the range of f ? 

Thus, we have only non - negative integers as images.
So, Range of f    0 (or  0 or  0 ).

Ex. f :  
What is the range of f
i. if f ( x)  x i. Range  -0
ii. if f ( x)  x  1 ii. Range   (or  )
iii. if f ( x)  x  1 ? iii. Range  0
Ex. Let f ( x)  1  x 2
i. What is the minimum restrictio n on x   which
defines a domain for the rule f ( x) ?
 1  x 1

ii. What is the range of f for the above domain ?


2
 1  x 1  0  x 1
2
 0 1  x 1
 0  1  x 2 1
 Range of f  y | y   , 0  y 1
Ex. Let f ( x) x 3 . If the range of f is set to have
0  f ( x) 8, then what is the suitable domain
for f ? Can we have a codomain w ith the real
values strictly between 0 and 8 ?

Domain of f  x | x  , 0  x 2

x | x  , 0  x  8 cannot be a codomain since


range should be a subset of codomain. Here 0 and 8
belong to range but they are not in the codomain.
Ex. Determine suitable domains with minimum restrictio ns
on  for the following rules and determine the
correspond ing ranges for each case.
i. f ( x)  1  x
1
ii. f ( x) 
x
1
iii. f ( x) 
sin x
1
iv. f ( x)  2 ;  1  f ( x) 1
x 1
Graph of a function
When the rule of a function f is denoted by y  f ( x) ,
the graph or the curve of f is given by the points ( x,y ) in
the usual Cartesian Coordinate plane. So, domain is
represente d in x - axis while range is represente d in y - axis.
Y

graph of f
y
( y  f ( x))

0 X
x
Once we set a function as y  f ( x), x is called the
independent variable and y is called the dependent
variable.
eg. What is the rule of the function plotted in the following
figure ? Determine the domain and the range.
Y

X
 1 0 1
Rule : f ( x)  x  1
Domain : x | x  ,  1  x 1
Range :  y | y  , 0  y 2

Remark : Vertical line test for the rule of a function.


( ie. for the single - valued feature)
Step 1 : Plot the rule in the coordinate plane.
Step 2 : Imagine of drawing vertical lines cutting the graph.
Step 3 : Decision on single - valued feature. If at least one of such lines
intersects the graph at more than one point, then the rule is not
single - valued. (ie. not a function)
eg. Graph of y  x
Y

0 X
1 2 3 4

Vertical line (intersect s the graph


more than once)

 y  x cannot be a rule of a function.


Ex. Can circle or ellipse represent a single - valued
function ?
No.
Arithmetic operations on functions
Functions can be combined under arithmetic operators
( ,  , , ) provided care is taken over their common
domains and any other possibilit ies of undefined
situations .

eg. If f ( x )  x 2  1 ;  2  x  4 and
2
g( x )  ; 0  x  5.
x 3
Comment on rule and domain for f  g and g .
f
Then, the rule for f  g :  f  g x 
 f x  g x 
2 2
x 1 
x 3
the domain for f  g : 0  x  4

Then, the rule for g :  g  x 


f  f
g x  2
 
f x  x  3x 2  1
the domain for g : 0  x  4 and x 1
f
2x
Ex. Let f ( x)  2 ;  1  x 2 and x 1
x 1
x 1
g ( x)  ; 0x4
x 3
Determine rule and domain for each of the operations
f  g , f  g , fg , f , g .
g f
Equality of functions
Two functions f : A  B and g : A  B are said
to be equal, written f  g , if f (a)  g (a ) for
every a  A . Note that domains and codomains of
f and g should also be equal.

The negation of f  g (ie. f  g ) is the statement :


There exists an a  A for which f (a )  g (a ).
eg. f :   0 and g :    0
2 2
f ( x) sin x  cos x g ( x) 1

Here, f  g .
1 ; x  \ 
If g ( x) is changed as g (x) 
0 ; x 

then f  g . (for x 0 , f (0) 1 but g (0) 0 )


Composition of functions
Chains of functions can be built up where output of
one function forms the input to the next function.

function f function g
x f (x) g ( f ( x))


output of f
becomes input for g
Consider t he functions f : A  B and g : B  C .
Then, the compositio n of f and g , denoted by g O f ,
is the function g O f : A  C defined by
g O f x   g ( f ( x)) .
We read g O f as " g circle f " or " g of f " .

Note that for the compositio n g O f , codomain of f must


be equal to the domain of g.
Furthermor e, domain of f becomes the domain of g O f
and codomain of g becomes the codomain of g O f .
f g
A   B   C

g f
Ultimately , compositio n can be seen as a " function
of a function " .
2
eg. If the rules are given by f ( x)  x  1 and g ( x)  x ,
then find the composed rules for g O f and f O g .

g O f ( x)  g ( f ( x))  g ( x  1) ( x  1) 2
2 2
f O g ( x)  f ( g ( x))  f ( x )  x  1

Generally, g O f ( x)  f O g ( x) (ie. compositio n is not


commutativ e). But there are many cases with
g O f ( x)  f O g ( x) .
1
See the composed rules with f ( x)  and g ( x)  x 2 .
x

 x  1 x
g O f ( x)  g ( f ( x))  g 1 2

 
f O g ( x)  f ( g ( x))  f x  1
2
x2


Ex. Let f :    and g :
 
x g ( x )  sin x
f(x)
2
Determine the domain, codomain, composed rule and
the range of g O f .
f  g gO f
          
 
Domain of g O f  , Codomain of g O f 
 x 
Composed rule : g O f ( x)  g ( f ( x))  g  
 2
x
sin
2
x
For x  , sin is either 1,  1 or 0.
2
 Range of g O f { 1, 0, 1}
eg. There are 2 electric devices A and B, where A reduces
the voltage by half of its original input and B reduces
the voltage by one third of its original input.
i. What is the composed voltage reduction if a current
first passes through A and then thro ugh B ?
ii. What is the final output if the original voltage is 230v
if A and B are connected as stated in (i) ?
iii. What is the compositio n if A and B are interchang ed
in their connection ? Does this make any difference
to the compositio n in (i) ?
Device A Device B
v v v 2v
v v  v v 
2 2 3 3
Rule : a (v)  v Rule : b(v) 2v
2 3

i. Compositio n : v a (v ) b(a (v))


 2  v 3
bO a (v) b(a (v)) b v
Thus, voltage is reduced by two third of the original

input v  v
3

ie. v  2v  .
3
ii. For the input of 230v
bO a (230) 230 76.67
3
 2v  v
iii. Compositio n : aO b(v) a (b(v)) a  
 3 3
No difference to (i).

We can compose more than two functions at once.


However, composed rule can be constructe d by composing
two functions at a time. One important result (associati ve
law) is given below with two compositio ns and it can be
extended for more compositio ns.
Result : Let f : A  B , g : B  C , h : C  D .
Then hO ( g O f )  (hO g ) O f

First compositio n is g O f First compositio n is hO g


and then the resultant and then the resultant
function is composed function is composed
with h. with f .

The above result can easily be proved by seeing


(hO ( g O f ))( a ) (( hO g ) O f )( a ) h( g ( f (a )))
for every a  A .
One-to-one (1-1) functions
This is a special type of functions, where for each
element in the range, there is only one mapping
from the domain. That is different elements of the
domain have distinct images.

not 1  1 1 1
This fact is defined as follows.
Definition : A function f : A  B is said to be
one - to - one (or injective) if f (a1 )  f (a2 ) then
a1 a2 for every a1 , a2  A .
(equivalen tly, if a1 a2 , then f (a1 )  f (a2 ))
eg. f ( x) 2 x  1 is 1  1.
Let f ( x1 )  f ( x2 )
2 x1  1  2 x2  1
2 x1  2 x2
x1  x2
ie. f ( x1 )  f ( x2 )  x1  x2
 f is 1  1.

eg. f ( x)  1 ; x 0 is 1  1.
x
Let f ( x1 )  f ( x2 )
1 1

x1 x2
x1  x2
ie. f ( x1 )  f ( x2 )  x1  x2
 f is 1  1.
eg. f ( x)  x 2 is not 1  1.
Though f (1)  f ( 1) 1 , 1  1.
 f is not 1  1.

eg. Is f ( x)  x sin x 1  1 or not ?


Not 1  1 .
f (0)  f ( ) 0 , but 0  .
 f is not 1  1.
3
Ex. Show that i. f ( x)  x is 1  1 .
ii. f ( x)  x  x 2 is not 1  1 .
Ex. If two functions f and g are 1  1 , then show that
the compositio ns g O f and f O g are also 1  1 .
g O f is 1  1
want : ( g O f )( x1 ) ( g O f )( x2 )  x1  x2
for every x1 , x2  D g O f
(Domain of g O f )
( g O f )( x1 ) ( g O f )( x2 )  g ( f ( x1 ))  g ( f ( x2 ))
 f ( x1 )  f ( x2 ) ( g is 1  1)
 x1  x2 ( f is 1  1)
 g O f is 1  1 .
Try to show f O g is also 1  1 .
Remark : Horizontal line test to check 1  1 feature.
Step 1 : Plot the graph of the function.
Step 2 : Imagine of drawing horizontal lines cutting
the graph.
Step 3 : Decision on 1  1 feature. If at least one of
such lines intersects the graph at more than
one point, then the function is not 1  1 .

eg. f ( x) x 2 is not 1  1 . Let us test this by the horizontal


line test. (Note that if the domain is not given or
restricted , it is assumed that the domain is .)
Y

y x 2

0 X

horizontal line intersects


the graph at two (more than one) points.
eg. f ( x) x 3 is 1  1 .
Y

y x 3

X
0

any horizontal line intersects


the graph only at one point.
eg. f ( x) sin x ;   x 3 is 1  1 .
2 2
Y

 3 X
0
2  2

1
intersects at
one point.
eg. f ( x) sin x ; 0  x 3 is not 1  1 .
2

some horizontal lines intersects


Y
the graph more than once.
1

3
2
 X
0
2 
Ex. Check whether the following functions are 1  1
or not using the horizontal line test.
i. f ( x )  x 4 ii. f ( x )  x iii. f ( x ) cos 2 x
iv. f ( x ) tan x ;    x 
2 2
v. f ( x )  x ; x  0
Onto functions
This is also a special type of functions, where for each
element in the codomain, there is at least one mapping
from the domain.

onto not onto


Definition for this onto feature is as follows.
Definition : A function f : A  B is said to be
onto (or surjective ) if every b  B is the image of
at least one a  A .

eg. f :   
f ( x)  x  1 is onto.
For every y   (codomain) , there exists y  1  
(domain) such that f ( y  1)  y  1  1  y . ie. y is
the image of y  1. So, f is onto.
eg. f :   
f ( x)  x  1 is not onto.
For  1   (codomain) , there is no any element

in  (domain) whose image is  1. So, f is not

onto. Note that f (0)  1, but 0   .

eg. f :   0
f ( x)  x 2 is onto.
For every y   0 , there exists  y   such that
 
f  y  y . ie. y is the image of y or  y.
So, f is onto.
eg. f :   
f ( x)  x 2 is not onto.
For  1   (codomain) , there is no any element in 
(domain) whose image is  1. So, f is not onto.
Ex. Show that i. f :  
f ( x)  x 3 is onto.
ii. f :    1, 1
f ( x) sin x is onto.
(Here  1, 1 is the set of real numbers
x that satisfy  1  x 1. Note that if
we put ( 1, 1) , then  1  x  1)
iii. f : 0 , 1 0 ,1
f ( x )  x is not onto.

iv. f :   0 , 2
f ( x ) cos x is not onto.
( Note x  0 , 2  0  x 2)

v. f :   
f ( x )  x  x is not onto.
Ex. If two functions f : A  B and g : B  C
are onto, then show that g O f is also onto.
Here , g O f : A  C
Want : for every y  C ,  (there exists)
a  A s.t. (such that ) g O f (a )  y.
Since g is onto, for every y  C ,  b  B
s.t. g (b)  y .
But , since f is onto, for every b  B ,  a  A
s.t. f (a ) b .
That is , for every y  C ,  a  A
s.t. g ( f (a ))  y ie. g O f (a )  y .
 g O f is onto.
Remark : Horizontal line test to check onto feature.

Step 1 : Plot the graph of the function.


Step 2 : Imagine of drawing horizontal lines cutting
the codomain v alues represente d in the y - axis.
Step 3 : Decision on onto feature. If at least one of
such lines does not intersect the graph, then the
function is not onto .
eg : f : 0 ,     1, 1
f ( x) sin x is not onto.
Y

Codomain
 X
values 0 
2

1
Horizontal lines cutting
the codomain below to
the x-axis do not
intersect the graph
eg : f : 0 ,    0, 1
f ( x) sin x is onto.
Y
1

Codomain
values
X
0  
2
each horizontal line
intersects the graph.
Ex. Check whether the following functions are onto
or not using the horizontal line test.
i. f : Z   ii. f :   0 ,1
3
f ( x ) x f ( x ) cos x
iii. f :      iv. f :    
2
f ( x ) x f ( x )  x
Inverse of a function
Suppose y is the image of x under the rule of a
function f . Then, what is the rule that assigns y to x ?
f
x y

?
This reverse process is called the inversion and the
required function is called the inverse function of f
or simply the inverse of f . Inverse of f is denoted
by f  1.
We can construct the rule of the inverse function
without th inking much about domain and codomain.

eg. What is the rule of the inverse for f ( x) x  2 ?


f

x x2 f  1 ( x) x  2
1
f
1
eg. Find f for f ( x) 2 x  1 ?
f
1 x 1
x 2x  1 f ( x) 
2
1
f
Note that addition and substracti on are inverses
of each other. Multiplica tion and division are
also inveres of each other. In calculatio ns, rule
of inverse can easily be constructe d by putting
y  f ( x) and obtaining x in terms of y .

eg. For f ( x ) 2 x  1  y 2 x  1
2 x  y 1
y 1
x
2
1 y 1 1 x 1
Then, f ( y )  or identicall y we have f ( x )  .
2 2
Inverse can be composed with the original function
as follows.
f f 1 1
x   f ( x)    f ( f ( x))  x
f 1
x    f  1 ( x) f  f ( f  1 ( x))  x
ie. ( f O f  1 )( x)  ( f  1O f )( x)  x

Later, we use these compositio ns to define the inverse


of a function in a precise manner. In addition, we
need both 1  1 and onto features. Furthermor e, the
concept of identity functions is also applicable here.
One-to-one correspondence
Definition : A function f : A  B is said to be
one - to - one correspond ence between A and B
(or bijective) if f is both one - to - one and onto.

eg. f :   
3
f ( x)  x is a 1  1 correspond ence.

Identity functions
An identity function assigns an element to itself.
Definition : The function f : A  A defined by
f (a ) a for every a  A is called the identity
function.
It is usually denoted by Ι A or simply by Ι . Thus,
for any a  A, we have Ι A (a ) a. (ie. a  a)
Now, we can define the inverse of a function precisely.

Definition : Let f : A  B . We call g : B  A


1
the inverse of f , written as f , if
f O g Ι B and g O f Ι A .
Remark : Function f has an inverse (invertibl e)
if and only if f is a one - to - one correspond ence
between A and B (ie. 1  1 and onto).
1
Also, if b  B, then f ( b ) a , where a is
the unique element of A for which f ( a ) b.
Here, a is called the preimage of b.
f

a b
1
f
eg. f :   
f ( x)  x 3 . Show that f ( x) is invertible and find f  1 ( x).

f is 1  1
3 3
f ( x1 )  f ( x2 )  x1  x2
3 3
x1 , x2   x1  x2 0
2 2
( x1  x2 ) ( x1  x1 x2  x2 ) 0
0
(for x1 , x2  0)
 x1  x2  0
x1  x2
ie. f ( x1 )  f ( x2 )  x1  x2
 f is 1  1.
f is onto
1
For every y   (codomain ),  y 3
  (domain) s.t.
 1
3
1
f  y   y . So, y is the image of y 3 .
 
 f is onto.

Since f is 1  1 and onto, f is invertible .

f  1 rule
3
y x 1
Inverse of f : f :  
1
x y 3
1
1
f ( x)  x 3
1
1
f ( x ) x 3
Ex. determine whether the following functions are
invertible or not. If it is invertible , then find the
rule of the inverse ( f  1 ( x)).
i. f :    ii. f :   
f ( x) x 2 f ( x)  1
x
iii. f :    iv.  2 2

f :   ,    1, 1
f ( x) x 2 f ( x) sin x
v. f : 0 ,     2, 2
f ( x) 2 cos x
5
Ex. Function f ( x)  x  32converts temperatu re into Celsius
9
when x is given by Fahrenheit .
What is the function for opposite conversion ?
Inverse of compositions
1 1 1
If h( x)  g ( f ( x)) , then h ( x)  f ( g ( x))
1 1 1
ie. ( g O f ) f O g

Notice the reversal of order of the functions in the


compositio n.
We can extend this result for further compositio ns.
1 1 1 1
For instance, (hO g O f ) f O g O h .
1
eg. Let f ( x ) 3 x , g ( x )  x  5 and h( x )  x 3 .
1
If k ( x ) (hO g O f ) ( x ) , then find k ( x ).
1 1 1 1
k ( x)( f O g O h ) (x )
1 x 1
f ( x)  , g ( x)  x  5 and h ( x)  x 1 3
3
 k  1 ( x)  f  1 ( g  1 (h  1 ( x)))
1 1 3
 f ( g ( x ))
1 3
 f ( x  5)
3
x 5

3
Graph of the inverse rule
Rule of f  1 ( x) can be plotted using the graph of f ( x)
by interchang ing X and Y axes appropreat ely.
That interchang e is based on the following implicatio n.
y  f  1( x )  f ( y ) x
eg. Plotting the inverse rule of y  x 2 .
Y
Y X

X Y
y x 2 x y2 y  x
(y  f(x)) (x  f(y)) (y  f  1(x))
1
Alternativ ely, graph of f ( x ) can be taken as the
reflection (mirror image) of the graph of f ( x ) over
the line y  x.
3 Y
eg. f ( x)  x y x 3
1
1 y  x
f ( x)  x 3
1
y x 3

You might also like