Professional Documents
Culture Documents
COMPUTER SCIENCE
BITS Pilani
Pilani|Dubai|Goa|Hyderabad
BITS Pilani
Pilani|Dubai|Goa|Hyderabad
Contact Session 6
Sets, Operation on Sets And Functions
Sets
A set is well defined collection or group of objects or elements or members.
Example X is a set containing three elements a, b and c.
X ={a,b,c} a,b,c∈ X ; d is not an element of X: d X.
The set-builder notation
O={ x | (xZ) (x=2k) for some kZ}
reads: O is the set that contains all x such that x is an integer and x is even
• A set is defined in intension when you give its set-builder notation
O={ x | (xZ) (0x8) (x=2k) for some k Z }
• A set is defined in extension when you enumerate all the elements:
O={0,2,4,6,8}
Use set builder notation to give a description of each of these sets.
a) {0, 3, 6, 9, 12} ={x | x=3k and k=0,1,2,3,4}
b) {−3,−2,−1, 0, 1, 2, 3} = { x | -3 <= x <= 3}
c) {m, n, o, p}
Solution:
a) {1,-1}
b) {1,2,3,4,5,6,7,8,9,10,11}
c) {0, 1, 4, 9, 16, 25, 36, 49, 64, 81}
d) (√ 2 is not integer )
6
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Sets
Subsets
Definition: The set A is a subset of the set B, denoted
A B, iff x [x A x B]
a) the set of airline flights from NewYork to New Delhi, the set of
nonstop airline flights from New York to New Delhi
b) the set of people who speak English, the set of people who
speak Chinese
c) the set of flying squirrels, the set of living creatures that can fly
8
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Example
Rosen , Section 2.1: 6
• Suppose that A = {2, 4, 6}, B = {2, 6}, C = {4, 6},
and D = {4, 6, 8}.
• Determine which of these sets are subsets of
which other of these sets.
9
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Rosen , Section 2.1: 18
18. Find two sets A and B such that
A ∈ B and A ⊆ B.
B={ a, φ}
A= φ A ∈ B
Also φ ⊆ B A ⊆ B
10
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Example
Rosen , Section 2.1: 9,10,11
Determine whether each of these statements is true or false.
1) 0 ∈ ∅ F 2) ∅ ∈ {0} F
3) {0} ⊂ ∅F 4) ∅ ⊂ {0} T
5) {0} ∈ {0} F 6) {0} ⊂ {0} T
7) {∅} ⊆ {∅} 8) ∅ ∈ {∅}
9) ∅ ∈ {∅, {∅}} 10) {∅} ∈ {∅}
11) {∅} ∈ {{∅}} 12) {∅} ⊂ {∅, {∅}}
13 ) {{∅}} ⊂ {∅, {∅}} 14) {{∅}} ⊂ {{∅}, {∅}}
15) {x} ⊆ {x}
16) {x} ∈ {x}
17) {x} ∈ {{x}}
18) ∅ ⊆ {x}
19 ) ∅ ∈ {x}
20) x ∈ {x} ) T (in fact x is the only element)
11
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Solutions
1) 0∈∅ F
2) ∅ ∈ {0} F (the only element of { 0} is 0 , not a set)
3) {0} ⊂ ∅ F
4) ∅ ⊂ {0} T (the empty set is a subset of every set)
5) {0} ∈ {0} F (the only element of { 0} is 0, not a set)
6) {0} ⊂ {0} T (every set is a subset of itself)
7) {∅} ⊆ {∅} T (every set is a subset of itself)
8) ∅ ∈ {∅ } T
9) ∅ ∈ {∅, {∅}} T
10) {∅ } ∈ { ∅ } F
11) {∅} ∈ {{∅}} T
12) {∅} ⊂ {∅, {∅}} T
13 ) {{ ∅}} ⊂ {∅, { ∅}} T
14) {{∅}} ⊂ {{∅}, {∅}} T
15) {x} ⊆ {x} T (every set is a subset of itself)
16) {x} ∈ {x} F (the only element of { x} is a letter, not a set)
17) {x} ∈ {{x}} T
18) ∅ ⊆ {x} T (the empty set is a subset of every set)
19 ) ∅ ∈ {x} F (the only element of { x} is a letter, not a set)
20) x ∈ {x} T (in fact x is the only element)
12
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Sets
• Definition: If there are exactly n distinct elements in a set S, with n
a nonnegative integer, we say that:
– S is a finite set, and
– The cardinality of S is n. Notation: |S| = n.
• Definition: A set that is not finite is said to be infinite
• Examples
– Let B = {x | (x100) (x is prime)}, the cardinality of B is |B|=25
because there are 25 primes less than or equal to 100.
– The cardinality of the empty set is ||=0
– The sets N, Z, Q, R are all infinite
• Definition: The power set of a set S, denoted P(S), is the set of all
subsets of S.
– Examples
• Let A={a,b,c}, P(A)={,{a},{b},{c},{a,b},{b,c},{a,c},{a,b,c}}
• Let A={{a,b},c}, P(A)={,{{a,b}},{c},{{a,b},c}}
– Note: the empty set and the set itself are always elements
of the power set.
• The power set is a fundamental combinatorial object useful when
considering all possible combinations of elements of a set
• Fact: Let S be a set such that |S|=n, then
|P(S)| = 2n
19
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Rosen , Section 2.1: 28,30
28. What is the Cartesian product A × B, where A
is the set of courses offered by the mathematics
department at a university and B is the set of
mathematics professors at this university?
Give an example of how this Cartesian product
can be used.
AxB ={ (ci, pj) | ci is a course offered and pj is a
professor in the dept}
20
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
• 30. Suppose that A × B = ∅, where A and B are
sets. What can you conclude?
• A × B = ∅ A = ∅ or B= ∅
21
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Venn Diagram
• A set can be represented graphically using a Venn
Diagram.We use a rectangle to represent the universal set U
and circles to represent subsets of U.
U x y B
A
z
a
C
23
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Solution
Rosen , Section 2.1:13
Use a Venn diagram to illustrate the set of all months of the
year whose names do not contain the letter R in the set of all
months of the year.
24
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Solution
Rosen , Section 2.1: 14,15,16
14: Use a Venn diagram to illustrate the relationship A ⊆ B and B ⊆ C.
15: Use a Venn diagram to illustrate the relationships A ⊂ B and B ⊂ C.
16 Use a Venn diagram to illustrate the relationships A ⊂ B and A ⊂ C.
x
y
A ⊂ B and B ⊂ C
A ⊂ B and A ⊂ C
A ⊆ B and B ⊆ C.
y
x
25
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Set Operations
• Arithmetic operators (+,-, ,) can be used on
pairs of numbers to give us new numbers
• Similarly, set operators exist and act on two
sets to give us new sets
– Union
– Intersection
– Set difference
– Set complement
– Generalized union
– Generalized intersection
U
A B
U
A B
U
A B
U
A B
31
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Rosen , Section 2.2: 39
Solution:
We can conclude that B = 0. To see this, suppose that B contains some
element b. If b A, then b is excluded from A ⊕ B,
so A ⊕ B cannot equal A.
On the other hand, if b A, then b must be in A ⊕ B,
so again A ⊕ B cannot equal A.
Thus in either case, A ⊕ B A.
We conclude that B cannot have any elements.
32
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Set Complement
• Definition: The complement of a set A,
denoted A , consists of all elements not in A.
That is the difference of the universal set and
U: U\A
A= AC = {x | x A }
U A
A
34
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Set Complement: Absolute & Relative
• Given the Universe U, and A,B U.
• The (absolute) complement of A is A=U\A
• The (relative) complement of A in B is B\A
U U
A A B
A
36
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Example
27.Draw the Venn diagrams for each of these combinations
of the sets A, B, and C.
a) A ∩ (B − C) A B
A ∩(B-C)
b) b) (A ∩ B) ∪ (A ∩ C)
c) (A ∩ B) ∪ (A ∩ C) C
28. Draw the Venn diagrams for each of these combinations
of the sets A, B, C, and D.
c) (A ∩ B) ∪ (C ∩ D)
d) A ∪ B ∪ C ∪ D
c) A − (B ∩ C ∩ D)
37
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Set Identities
38
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Rosen , Section 2.2:30
30.Can you conclude that A = B
if A, B, and C are sets such that
a) A ∪ C = B ∪ C? b) A ∩ C = B ∩ C?
c) A ∪ C = B ∪ C and A ∩ C = B ∩ C?
39
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Union Rule for Sets
• Union Rule for Sets
n( A∪B) = n( A) + n(B) − n( A∩B)
• where n( X ) is the number of elements in set X.
• Union Rule for Disjoint Sets
If A and B are disjoint sets,
n( A∪B) = n( A) + n(B) .
40
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Proving Equivalence
• Finally to show that two sets are equal, it is sufficient
to show independently (much like a biconditional)
that
– A B and
– BA
• Logically speaking, you must show the following
quantified statements:
(x (xA xB)) (x (xB xA))
• Let
– A={x|x is even}
– B={x|x is a multiple of 3}
– C={x|x is a multiple of 6}
• Show that AB=C
• AB C: x AB
Þ x is a multiple of 2 and x is a multiple of 3
Þ we can write x=2.3.k for some integer k
Þ x=6k for some integer k x is a multiple of 6
ÞxC
• C AB: x C
Þ x is a multiple of 6 x=6k for some integer k
Þ x=2(3k)=3(2k) x is a multiple of 2 and of 3
Þ x AB
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Proving Set Equivalences
A =A
n
i 1 A2 … An
i=1
A =A
i=1
i 1 A2 … An
b) All the sets are subsets of the set of integers, and every nonzero integer is in exactly one of the sets, so
U∞ i=1 Ai = Z - {O}. Each pair of these sets are disjoint, so no element is common to all of the sets. Therefore
Ç ∞
i=1 Ai i = .
c) This is similar to part (a), the only difference being that here we are working with real numbers.
Therefore U∞ i=1 Ai = R (the set of all real numbers), and ∞ i=1 Ai = A1 = [-1, 1] (the interval of all real numbers
between -1 and 1, inclusive).
d) This time the sets are getting smaller as i increases: · · · A3 A2 A1 . Because A1 includes all
the others, U∞ i=1 Ai = A1 = [1, ∞) (all real numbers greater than or equal to 1). Every number eventually
gets excluded as i increases, so ∞ i=1 A = . Notice that ∞ is not a real number, so we cannot write
∞ i=1 Ai = {∞}
51
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Successor of a Set
The successor of the set A is the set A ∪ {A}.
Functions
Definition of Functions
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 element a of A. If f is a
function from A to B, we write f : A→ B .
R={(a1,b1), (a2,b2), (a3,b4),
(a4,b4)} subset of AxB
54
f A B
• •
f • •
• • • y
a b •
•
•
• x
A
B Graph Plot
Like Venn diagrams
55
58
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Rosen, Section2.3: 4
4) Find the domain and range of these functions. Note that in
each case, to find the domain, determine the set of elements
assigned values by the function.
a) the function that assigns to each nonnegative integer its last
digit
b) the function that assigns the next largest integer to a positive
integer
c) the function that assigns to a bit string the number of one bits
in the string
d) the function that assigns to a bit string the number of bits in
the string
59
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Solution
a) the function that assigns to each nonnegative integer its last digit
Clearly the Domain is Zero and all possible positive Integers , The Range set
include last digit [Ones place] which can hold nos {0,1,2,3,4,5,6,7,8,9}.
b) the function that assigns the next largest integer to a positive integer
Clearly the Domain is all possible positive Integers , The Range set includes all
Natural numbers greater than 1.
c) the function that assigns to a bit string the number of one bits in the string
Clearly the Domain is the set of all bit strings. The Range is Z+U{0}; the function
evaluated at a string with n l's
d) the function that assigns to a bit string the number of bits in the string
Clearly the Domain is the set of all bit strings. The Range is Z+; the function evaluated
at a string with n - l's and m - 0's
60
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Rosen, Section2.3: 5
5. Find the domain and range of these functions. Note that in each
case, to find the domain, determine the set of elements assigned
values by the function.
a) the function that assigns to each bit string the number of ones
in the string minus the number of zeros in the string
b) the function that assigns to each bit string twice the number of
zeros in that string
c) the function that assigns the number of bits left over when a
bit string is split into bytes (which are blocks of 8 bits)
d) the function that assigns to each positive integer the largest
perfect square not exceeding this integer
61
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Solution
In each case we want to find the domain (the set on which the function operates, which is implicitly stated in
the problem) and the range (the set of possible output values).
a) the function that assigns to each bit string the number of ones in the string minus the number of zeros in
the string
Clearly the domain is the set of all bit strings. The range is Z; the function evaluated at a string with n l's and no
O's is n, and the function evaluated at a string with n O's and no l's is -n.
b) the function that assigns to each bit string twice the number of zeros in that string
Again the domain is clearly the set of all bit strings. Since there can be any natural number of O's in a bit string,
the value of the function can be 0, 2, 4, .... Therefore the range is the set of even natural numbers.
c) the function that assigns the number of bits left over when a bit string is split into bytes (which are blocks
of 8 bits)
Again the domain is the set of all bit strings. Since the number of leftover bits can be any whole number
from 0 to 7 (if it were more, then we could form another byte),
the range is {O, 1, 2, 3, 4, 5, 6, 7}.
d) the function that assigns to each positive integer the largest perfect square not exceeding this integer
As the problem states, the domain is the set of positive integers. Only perfect squares can be function values,
and clearly every positive perfect square is possible. Therefore the range is {l, 4, 9, 16, ... }.
62
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Real-valued Functions
A function is said to be real-valued if all its
values are real numbers.
Example
f (x) = x2 for all x ∈ R
63
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Addition and Multiplication of Real-valued function
65
66
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.
67
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Example
Let f and g be the functions from the set of integers to the set of
integers defined by f (x) = 2x + 3 and g(x) = 3x + 2. What is the
composition of f and g? What is the composition of g and f ?
Solution:
Both the compositions f ◦ g and g ◦ f are defined. Moreover,
(f ◦ g)(x) = f (g(x)) = f (3x + 2) = 2(3x + 2) + 3 = 6x + 7
and
(g ◦ f )(x) = g(f (x)) = g(2x + 3) = 3(2x + 3) + 2 = 6x + 11.
68
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Images of Sets under Functions
• Given f:AB, and SA,
• The image of S under f is simply the set of all
images (under f) of the elements of S.
f(S) : {f(s) | sS}
: {b | sS: f(s)=b}.
• Note the range of f can be defined as simply
the image (under f) of f’s domain!
69
71
73
75
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Rosen, Section2.3:10
10. Determine whether each of these functions from
{a, b, c, d} to itself is one-to-one.
a) f (a) = b, f (b) = a, f (c) = c, f (d) = d
76
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Rosen, Section2.3: 12
12. 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 = largest integer greater than n/2
F(2)=ceil(1)=1; f(1)=ceil(0.5)=1
77
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
f (n) = n − 1
• Let f(n1)=f(n2) n1-1=n2-1 n1=n2
• F is 1-1
• b) f (n) = n2 + 1
• Let f(x)=f(y) x^2 + 1 =y^2 +1 x^2 = y^2
• x=1, y=-1. x!=y but x^2=y^2
• F is not 1-1
78
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Solution
a) f (n) = n − 1
This function is one to one. Since n - 1 is always decremental mapping
and is always one to one mapping.
b) f (n) = n2 + 1
This function is not one to one. Since n 2 always map to positive
numbers for both negative and positive [Eg: (-2) 2 and 2 2 map to 4]
so n2 + 1 is not one to one mapping
c) f (n) = n3
This function is one to one. Since n3 is incremental
d) f (n) = n/2
This function is one to one. If we want to obtain the value n, then we
simply need to start with 2n, since f(2n) = 2n/2 = n = n for all n E Z.
79
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Rosen, Section2.3:17
17. Consider these functions from the set of teachers in a school. Under what conditions is the
function one-to-one if it assigns to a teacher his or her
a) office.
b) assigned bus to chaperone in a group of buses taking students on a field trip.
c) salary.
d) social security number
80
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Solution
a) This may be one-to-one (if there are no shared offices) or not (if there are shared
offices).
b) Again, this depends on the policy of the school. Assuming that no bus gets more
than one teacher chaperone, this function will be one-to-one.
c) This is most likely not one-to-one, because two teachers might have the same
salary. On the other hand, it may happen that everyone's salary is different, in which
case it is one-to-one.
d) This is clearly a one-to-one function, because social security numbers are unique--
no two people can have the same social security number
81
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Rosen, Section2.3:27
27.
a) Prove that a strictly decreasing function from R to itself is one-to-one.
b) Give an example of a decreasing function from R to itself that is not one-to-one.
Solution:
c) Let f be the given strictly decreasing function from R to itself. We need to show that
f(a) = f(b) implies a= b for all a, b R. We give an indirect proof by proving the
contrapositive: if a b, then f(a) f(b). There are two cases. Suppose a < b; then
because f is strictly decreasing, it follows that f(a) > f(b). Similarly, if a> b, then f(a)
< f(b). Thus in either case, f(a) f(b).
d) We need to make the function decreasing, but not strictly decreasing, so, for
example, we could take the trivial function f ( x) = 17. If we want the range to be all
of R, we could define f in parts this way: f(x) = -x - l for x < -1; f(x) = 0 for -1<= x<=1;
and f(x) = -x+ 1 for x > 1.
82
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Rosen, Section2.3:26
26.
a) Prove that a strictly increasing function from R to itself is one-
to-one.
b) Give an example of an increasing function from R to itself that
is not one-to-one.
• b) A={1,2,3} f: A A as f(1) = 1, f(2)=1, f(3)=2
• f is increasing function.
• But as f(1)=f(2), f is NOT 1-1.
83
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Onto (Surjective) Functions
A function f:AB is onto or surjective or a surjection
iff its range is equal to its codomain (bB, aA:
f(a)=b).
An onto function maps the set A onto (over, covering)
the entirety of the set B, not just over a piece of it.
e.g., for domain & codomain R,
x3 is onto,
whereas x2 isn’t. (Why not?)
84
•
• • • • • • • •
• • • • • • • •
• • • •
• • • •
• • • • • •
• • • •
Onto Not Onto Both 1-1 1-1 but
(but not 1-1) (or 1-1) and onto not onto
85
Solution:
Because all three elements of the codomain are images
of elements in the domain, we see that f is onto.
88
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Rosen, Section2.3:18
18 Consider these functions from the set of students in a discrete
mathematics class. Specify a codomain for each of the functions. Under what
conditions is each of these functions with the codomain you specified onto? if
it assigns to a student his or her
a) mobile phone number.
b) student identification number.
c) final grade in the class.
d) home town.
89
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Bijections
• A function f is a one-to-one correspondence, or a
bijection, or reversible, or invertible,
iff 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:
The function f is one-to-one and onto. It is one-to-one because no two
values in the domain are assigned the same function value.
It is onto because all four elements of the codomain are images of
elements in the domain.
Hence, f is a bijection.
90
91
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Solution
a) One way to determine whether a function is a bijection is to try to construct its
inverse. This function is a bijection, since its inverse (obtained by solving y = 2x + 1
for x) is the function g(y) = (y - 1) /2. Alternatively, we can argue directly. To show
that the function is one-to-one, note that if 2x + 1 = 2x' + 1, then x = x'. To show
that the function is onto, note that 2( (y - 1) /2) + 1 = y, so every number is in the
range.
b) This function is not a bijection, since its range is the set of real numbers greater
than or equal to 1 (which is sometimes written [1, ∞)), not all of R. (It is not
injective either.)
c) This function is a bijection, since it has an inverse function, namely the function
f(y) = y1/3 (obtained by solving y = x 3 for x).
d) This function is not a bijection. It is easy to see that it is not injective, since x and -x
have the same image, for all real numbers x. A little work shows that the range is
only { y I 0.5 <= y < 1} = [0.5, 1)
92
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Inverse of a Function
• For bijections f:AB, there exists an inverse
of f, written f 1:BA, which is the unique
function such that:
93
Solution:
The function f is invertible because it is a one-to-one
correspondence.
The inverse function f−1 reverses the correspondence given by f ,
so f−1 (1) = c, f−1(2) = a, and f−1 (3) = b.
94
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Example
Let f : Z → Z be such that f (x) = x + 1. Is f invertible, and if it is, what
is its inverse?
Solution:
The function f has an inverse because it is a one-to-one
correspondence.
To reverse the correspondence, suppose that y is the image of x, so
that y = x + 1. Then x = y − 1. This means that y − 1 is the unique
element of Z that is sent to y by f . Consequently, f−1(y) = y − 1.
95
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Rosen, Section2.3: 42
42. 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}).
96
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Solution
a) We want to find the set of all numbers whose floor is 0. Since all numbers
from 0 to 1 (including 0 but not 1) round down to 0,
we conclude that g-1 ( {0}) = { x I 0 <=x < 1} = [0, 1).
b) This is similar to part (a). All numbers from -1 to 2 (including -1 but not 2)
round down to -1, 0, or l;
we conclude that g-1 ({-1,0, 1}) = {x I -1<=x<2} =[-1,2)
c) Since g(x) is always an integer, there are no values of x such that g(x) is
strictly between 0 and 1. Thus the inverse image in this case is the empty
set.
97
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Rosen, Section2.3: 28
28 . Show that the function f (x) = e x from the set of real numbers to the set of real
numbers is not invertible, but if the codomain is restricted to the set of positive real
numbers, the resulting function is invertible.
98
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Rosen, Section2.3: 39
Show that the function f (x) = ax + b from R to R is
invertible, where a and b are constants, with a = 0, and
find the inverse of f .
99
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Solution
We simply solve the equation y = ax + b for x.
This gives x = (y - b) /a, which is well-defined since a 0.
Thus the inverse is f-1 (y) = (y-b)/a.
To check that our work is correct, we must show that f of- 1 (y) = y
for all y R and that f-1◦f(x) = x for all x R.
Both of these are straightforward algebraic manipulations.
For the first, we have f ◦ f-1 (y) = f(f-1 (y)) = f((y- b)/a) = a((y- b)/a) + b = y.
The second is similar.
100
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Rosen, Section2.3: 70
70 . Suppose that f is an invertible function from Y to Z and g is an invertible function
from X to Y . Show that the inverse of the composition f ◦ g is given by
(f ◦ g)−1 = g−1 ◦ f −1.
g−1 ◦ f −1(z) = g−1 (f −1(z)) = g(-1) (y) = x
101
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
The Identity Function
• For any domain A, the identity function I:AA
(variously written, IA, 1, 1A) is the unique
function such that aA: I(a)=a.
• Some identity functions you’ve seen:
– ing with T, ing with F, ing with , ing with
U.
• Note that the identity function is both one-to-
one and onto (bijective).
102
•
• • y
• •
• •
• •
103
104
105
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Solution
65.Draw the graph of the function f (x) = x + x/2 from R to R.
106
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Floor and Ceiling Functions
The floor function assigns to real number x the largest
integer that is less than or equal to x.
The value of the floor function at x is denoted by ⎣x⎦ .
The ceiling function assigns to the real number x the
smallest integer that is greater than or equal to x.
The value of the ceiling function at x is denoted by ⎡x⎤ .
Example
1 .
x x 1.6=1
0
• Note that if xZ, 1 . 1.4= 1
. 1.4
x = x = x. 2 .
1.4= 2
3 3 .. .
3=3= 3
108
109
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Solution
The floor function rounds down and the ceiling function rounds
up.
a) 1
b) 0
c) 0
d) -1
e)3
f)-1
g) 1/2+ 3/2 = 1/2+ 2 = 2 1/2 =2
h) 1/2 . 5/2 = 1/2 . 2= 1 =1
110
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Plots with floor/ceiling: Example
• Plot of graph of function f(x) = x/3:
f(x)
3 +3 x
2
111
113
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Solution
a) This is true. Since x is already an integer, x = x .
115
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Solution
Since a byte is eight bits, all we are asking for in
each case is ⎡f n/8 ⎤ , where n is the number
of bits.
a) ⎡ f7/8 ⎤ = 1
b) ⎡ f17/8 ⎤ = 3
c) ⎡ f1001/8 ⎤ = 126
d) ⎡ f28800/8 ⎤ = 3600
116
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Thank you
117
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956