0% found this document useful (0 votes)
15 views32 pages

Slide 2 - Function

Uploaded by

crid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views32 pages

Slide 2 - Function

Uploaded by

crid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 32

Function

Nakib Hayat Chowdhury


Assistant Professor, Dept. of CSE, BAUST

1
Every extraordinary feat began in ordinary circumstances. I will start my journey of success from where I am now.
Function
Definition
• 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.
Function
Function
Definition of a function
f:R Z

f maps R to
R Z
Domain Z Co-domain
f

f(4.3
4.3 ) 4

Pre-image of 4 Image of 4.3


Function
More functions
A pre-image The image
Domain Co-domain of 1 of “a”

Topu A “a” 1
x B “bb” 2
Nahid C “cccc” 3
y D “dd” 4
z F “e” 5

A class grade function A string length function


Function
Even more functions

Range

a 1 “a” 1
e 2 “bb“ 2
i 3 “cccc” 3
o 4 “dd” 4
u 5 “e” 5

Some function… Not a valid function!


Also not a valid function!
Function: Domain, Codomain
Function and Formula

Function arithmetic
Definition
Let f1 and f2 be function from A to B. Then f1 + f2 and f1 f2 are also
functions from A to B defined by
• (f1 + f2)(x) = f1(x) + f2(x)

• (f1 f2)(x) = f1(x) f2(x)


Function : Loss vs NO Loss

• f(x) = x2
• f grading system

• f(x) = 0.1x
One to One Function
One-to-one functions
Definition
A function is one-to-one if elements in the co-domain has a unique pre-
image

a 1 a 1
e 2 e 2
i 3 i 3
o 4 o 4
5 5

A one-to-one function A function that is


not one-to-one
One to One Function
More on one-to-one
• Injective is synonymous with one-to-one
• “A function is injective”
• A function is an injection if it is one-to-one
a 1
e 2
• Note that there can be un-used elements i 3
in the co-domain o 4
5

A one-to-one function
OneMore
to One Function
on one-to-one

• Determine whether the function f form {a, b, c, d} to {1, 2, 3, 4, 5}


with f(a)= 4, f(b)= 5, f(c)= 1, f(d)= 3 is one-to-one or not.

• Determine whether the function f(x) = x2 from the set of integers to


the set of integers is one-to-one?

• Determine whether the function f(x) = x+1 from the set of integers to
the set of integers is one-to-one?
Onto functions
Definition
A function is onto if each element in the co-domain is an image of some
pre-image(s).
Onto functions
Definition
A function is onto if each element in the co-domain is an image of some
pre-image

a 1 a 1
e 2 e 2
i 3 i 3
o 4 o 4
u 5

An onto function A function that


is not onto
Onto functions
More on onto
• Surjective is synonymous with onto
• “A function is surjective”
• A function is an surjection if it is onto
a 1

• Note that there can be multiply used e 2

elements in the co-domain i 3


o 4
u

An onto function
Onto functions
More onto

• Determine whether the function f form {a, b, c, d} to {1, 2, 3} with


f(a)= 3, f(b)= 2, f(c)= 1, f(d)= 3 is onto or not.

• Determine whether the function f(x) = x2 from the set of integers to


the set of integers is onto?

• Determine whether the function f(x) = x+1 from the set of integers to
the set of integers is onto?
Onto vs. one-to-one
Are the following functions onto, one-to-one, both, or neither?

a 1 a 1
a 1
b 2 b 2
b 2
c 3 c 3
c 3
4 d 4
4
1-to-1, not onto Both 1-to-1 and onto Not a valid function

a 1 a 1
b 2 b 2
c 3 c 3
d d 4
Onto, not 1-to-1 Neither 1-to-1 nor onto
Bijections
Definition
• A function that is both one-to-one and onto Such a function is a one-
to-one correspondence, or a bijection.

a 1
• We only can find the inverse of a function if it is a bijection b 2
function. c 3
d 4
Bijections

• 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 bijection?
Identity functions
Definition
A function such that the image and the pre-image are ALWAYS equal

• f(x) = 1*x
• f(x) = x + 0

• The domain and the co-domain must be the same set


Inverse functions
Inverse functions
Let f(x) = 2*x

R f R

f-1

f(4.3)
4.3 8.6
f-1(8.6)

Then f-1(x) = x/2


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 f-1 .


• Hence, f-1 (b) = a when f(a) = b
More on inverse
Inverse functions
functions
• Can we define the inverse of the following functions?
a 1 a 1
b 2 b 2
c 3 c 3
4 d

What is f-1(2)? What is f-1(2)?


Not onto! Not 1-to-1!

• An inverse function can ONLY be done defined on a bijection


Few functions
Few Examples
• f: Z → Z
• f(x) = x
• f(x) = 2x
• f(x) = x+1
• f: R → R
• f(x) = 2x
• f(x) = x2
• f(x) = x3
• f: R → R+ ∪ {0}
• f(x) = x2
Compositions of functions
(f ○ g)(x) = f(g(x))
f○g

A B C
g f

g(a) f(b)

a f(g(a))
b = g(a)

(f ○ g)(a)
Compositions of 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 f o g is defined by

(f o g)(a) = f(g(a))

Note that the composition f o g can not be defined unless the range of g is a subset
of the domain of f.
Compositions offunctions
Compositions of functions
Let f(x) = 2x+3 f○g
Let g(x) =
3x+2
R R R
g f

g(1) f(5)
f(g(1))=13
1
g(1)=5

(f ○ g)(1)

f(g(x)) = 2(3x+2)+3 =
6x+7
Compositions of
Compositions of functions functions
Does f(g(x)) = g(f(x))?

Let f(x) = 2x+3 Let g(x) = 3x+2

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


Not equal!
g(f(x)) = 3(2x+3)+2 = 6x+11

Function composition is not commutative!


Graphs of functions f(x)
=3
x=
1

Let f(x)=2x+1
f(x)
=5
x=
Plot (x, f(x)) 2

This is a plot
of f(x)
Graphs of functions

Not one-to- one one-to- one


Not onto Nor onto

Both one-to- one


and onto Not one-to- one
Bur onto
Useful functions

• Floor: ⎣x⎦ means take the greatest integer less than or equal to the
number

• Ceiling: ⎡x⎤ means take the lowest integer


greater than or equal to the number

• round(x) = ⎣ x+0.5 ⎦
Floor, Ceiling Examples

• Find these values

• ⎣1.1⎦ 1
• ⎡1.1⎤ 2
• ⎣-0.1⎦ -1
• ⎡-0.1⎤ 0

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy