Chapter 3 -Functions (1)
Chapter 3 -Functions (1)
First Grade
Chapter 3: Functions
◼◼ a is a pre-image of b under f
◼◼ Example 6:
Let f and g be functions from R to R
such that f(x) = x2 and g(x) = x – x2.
What are the functions f + g and fg?
Function Composition Operator
University of
= g(x 2)
= 2x 2 + 1
Note that f◦g g◦f. (4x2+4x+1 2x2+1)
Images of Sets under Functions University of Hawaii
◼◼ Let f : A → B be a bijection.
The inverse function of f is the function that
assigns to an element bB the unique element
aA such that f(a) = b.
The inverse function of f is denoted by f -1: B → A.
Hence, f -1(b) = a when f(a) = b.
Inverse Function Illustration
◼◼ Let f: A → B be a bijection
◼◼ Is a map a bijection?
Iff the cardinalities of the image and range are the same:
◼◼ if (map.keys().size()==map.values().size()) {
System.out.println("map is a bijection”);
}
Inverse Function in Java
◼◼ Let’s construct an inverse!
◼◼ Prepare the inverse function:
◼◼ Map inverse<String,Integer>
=new HashMap<String,Integer; )(>
◼◼ Here, the domain is String si niamodoc eht ,Integer
◼◼ Go through all keys in map eht fo stnemele lla(image )
otni }yek,eulav{ riap hcae tup dnainverse:
◼◼ for (Integer id:map.keys()) {
String name = map.get(id);
inverse.put(id:name,id;)
}
The Identity Function
◼◼ For any domain A, the identity function
I: A → A (also written as IA, 1, 1A) is the
unique function such that aA: I(a) = a.
◼◼ Note that the identity function is always both
one-to-one and onto (i.e., bijective).
◼◼ For a bijection f : A → B and its inverse
function f -1: B → A,
f −1 f = I A
◼◼ Some identity functions you’ve seen:
◼◼ + 0, 1, T, F, , U.
Identity Function Illustrations
◼◼ The identity function:
•
• •
• • y y = I(x) =
x
• •
• •
Floor Function
f (q ) = q the largest integer less than or equal to q
where q is rational numbers
f (1.5) = 1.5 = 1, f (−3) = −3 = −3, f ( −2.7) = −2.7 = −3
Ceiling Function
f (q ) = q the smallest integer greater than or equal to q
where q is rational numbers
School of Software
Floor & Ceiling Functions
Floor & Ceiling Functions
Plots with Floor/Ceiling:
Example
-6 -3 3 6 x
-2
References
❑ Discrete Mathematics and Its Applications Seventh Edition 7th Edition
,Kenneth Rosen , McGraw Hill , 2011
❑ Discrete mathematics for computer scientists , Clifford Stein, Robert L.
Drysdale, Kenneth Bogart.
❑ https://drive.google.com/file/d/1km8aUn2bHHbEUGIwuCKSTGeLe-
UDKCoe/view?usp=drive_link