1. Discrete Mathematics
Functions
Ordered tuples and Cartesian Product
Function and Representations
Types of Functions
Composition and Inverse of Function
Numeric Functions
Imdadullah Khan
Imdadullah Khan (LUMS) Functions 1 / 17
2. Types of functions: Review
A function f : X 7→ Y is one-to-one (or injective) iff
∀ x1, x2 ∈ X (f (x1) = f (x2) → x1 = x2)
A function f : X 7→ Y is onto (or surjective) iff
for every element y ∈ Y there is an element x ∈ X with f (x) = y
A function f : X 7→ Y is one-to-one correspondence (or bijective) iff
it is both one-to-one and onto
Imdadullah Khan (LUMS) Functions 2 / 17
3. Inverse of a function
If f : X 7→ Y is a bijection, then if we reverse the arrows we get a
bijection too
x1
x2
x3
x4
A
B
C
F
bijection
onto
one-to-one
x1
x2
x3
x4
A
B
C
F
Imdadullah Khan (LUMS) Functions 3 / 17
4. Inverse of a function
If f : X 7→ Y is a bijection, then if we reverse the arrows we get a
bijection too
ICP 5-24 Can we say this when f is not one-to-one? a) Yes b) No
x1
x2
x3
x4
x5
A
B
C
F
Not bijection
onto
not one-to-one
x1
x2
x3
x4
x5
A
B
C
F
Imdadullah Khan (LUMS) Functions 4 / 17
5. Inverse of a function
If f : X 7→ Y is a bijection, then if we reverse the arrows we get a
bijection too
ICP 5-25 Can we say this when f is not onto? a) Yes b) No
x1
x2
x3
x4
A
B
C
F
D
Not bijection
not onto
one-to-one
x1
x2
x3
x4
A
B
C
F
D
Imdadullah Khan (LUMS) Functions 5 / 17
6. Inverse of a function
If f : X 7→ Y is a bijection, then if we reverse the arrows we get a
bijection too
ICP 5-26 Can we say this when f is neither? a) Yes b) No
x1
x2
x3
x4
x5
A
B
C
F
Not bijection
not onto
not one-to-one
x1
x2
x3
x4
x5
A
B
C
F
Imdadullah Khan (LUMS) Functions 6 / 17
7. Inverse of function
If f : X 7→ Y is a bijection, then if we reverse the arrows we get a
bijection too
Imdadullah Khan (LUMS) Functions 7 / 17
8. Inverse of function
If f : X 7→ Y is a bijection, then if we reverse the arrows we get a
bijection too
If f : X 7→ Y is a bijection, f −1 : Y 7→ X is the inverse function such that
f −1(b) = a, when f (a) = b
If an inverse exists, then
f (a) = b ↔ f −1
(b) = a
Imdadullah Khan (LUMS) Functions 7 / 17
9. Inverse of function
Let f : R 7→ R be f (x) = 2x − 3
Is f a bijection? What is f −1?
Imdadullah Khan (LUMS) Functions 8 / 17
10. Inverse of function
Let f : R 7→ R be f (x) = 2x − 3
Is f a bijection? What is f −1?
For any y ∈ R, since y+3/2 ∈ R and f (y+3/2) = y
so f is onto
Imdadullah Khan (LUMS) Functions 8 / 17
11. Inverse of function
Let f : R 7→ R be f (x) = 2x − 3
Is f a bijection? What is f −1?
For any y ∈ R, since y+3/2 ∈ R and f (y+3/2) = y
so f is onto
f (x1) = f (x2) → 2(x1) − 3 = 2(x2) − 3 → x1 = x2
so f is one-to-one
Hence, f is a bijection
Imdadullah Khan (LUMS) Functions 8 / 17
12. Inverse of function
Let f : R 7→ R be f (x) = 2x − 3
Is f a bijection? What is f −1?
For any y ∈ R, since y+3/2 ∈ R and f (y+3/2) = y
so f is onto
f (x1) = f (x2) → 2(x1) − 3 = 2(x2) − 3 → x1 = x2
so f is one-to-one
Hence, f is a bijection
Let f −1(y) = x
Let y = 2x − 3 and solve for x
f −1(y) = y+3/2
Imdadullah Khan (LUMS) Functions 8 / 17
13. Inverse of function
Let f : R− 7→ R+ be f (x) = x2
Is f a bijection? What is f −1?
R− = {x ∈ R | x ≤ 0} and R+ = {x ∈ R | x ≥ 0}
Imdadullah Khan (LUMS) Functions 9 / 17
14. Inverse of function
Let f : R− 7→ R+ be f (x) = x2
Is f a bijection? What is f −1?
R− = {x ∈ R | x ≤ 0} and R+ = {x ∈ R | x ≥ 0}
f −1(y) = −
√
y
Imdadullah Khan (LUMS) Functions 9 / 17
15. Composing functions
The output of one function can be used as input to another function
Restriction on range and domain
Imdadullah Khan (LUMS) Functions 10 / 17
16. Composing functions
The output of one function can be used as input to another function
Restriction on range and domain
Let g : A 7→ B and let f : B 7→ C
The composition of the functions f and g is a function, (f ◦ g) : A 7→ C is
(f ◦ g)(a) = f (g(a))
The output of g is input to f
Range of g (actual outputs) must be a subset of domain of f
Imdadullah Khan (LUMS) Functions 10 / 17
17. Composition
Let f : R 7→ R be f (x) := x3
Let g : Z 7→ Z be g(x) := x2
Imdadullah Khan (LUMS) Functions 11 / 17
18. Composition
Let f : R 7→ R be f (x) := x3
Let g : Z 7→ Z be g(x) := x2
(f ◦ g)(x) : Z 7→ R
Imdadullah Khan (LUMS) Functions 11 / 17
19. Composition
Let f : R 7→ R be f (x) := x3
Let g : Z 7→ Z be g(x) := x2
(f ◦ g)(x) : Z 7→ R
(f ◦ g)(x) = f (g(x)) = f (x2) = (x2)3 = x6
What will be (g ◦ f ) ?
Imdadullah Khan (LUMS) Functions 11 / 17
20. Composition
Let f : Z 7→ Z be f (x) := x3
Let g : Z 7→ Z be g(x) := x2
Imdadullah Khan (LUMS) Functions 12 / 17
21. Composition
Let f : Z 7→ Z be f (x) := x3
Let g : Z 7→ Z be g(x) := x2
(f ◦ g)(x) : Z 7→ Z
Imdadullah Khan (LUMS) Functions 12 / 17
22. Composition
Let f : Z 7→ Z be f (x) := x3
Let g : Z 7→ Z be g(x) := x2
(f ◦ g)(x) : Z 7→ Z
(f ◦ g)(x) = f (g(x)) = f (x2) = (x2)3 = x6
Imdadullah Khan (LUMS) Functions 12 / 17
23. Composition
Let f : Z 7→ Z be f (x) := x3
Let g : Z 7→ Z be g(x) := x2
(f ◦ g)(x) : Z 7→ Z
(f ◦ g)(x) = f (g(x)) = f (x2) = (x2)3 = x6
(g ◦ f )(x) : Z 7→ Z
(g ◦ f )(x) = g(f (x)) = g(x3) = (x3)2 = x6
Imdadullah Khan (LUMS) Functions 12 / 17
24. Composition
Let f : Z 7→ Z be f (x) := x2
Let g : Z 7→ Z be g(x) := 2x
Imdadullah Khan (LUMS) Functions 13 / 17
25. Composition
Let f : Z 7→ Z be f (x) := x2
Let g : Z 7→ Z be g(x) := 2x
(f ◦ g)(x) : Z 7→ Z
(f ◦ g)(x) = f (g(x)) = f (2x) = (2x)2 = 4x2
Imdadullah Khan (LUMS) Functions 13 / 17
26. Composition
Let f : Z 7→ Z be f (x) := x2
Let g : Z 7→ Z be g(x) := 2x
(f ◦ g)(x) : Z 7→ Z
(f ◦ g)(x) = f (g(x)) = f (2x) = (2x)2 = 4x2
(g ◦ f )(x) : Z 7→ Z
(g ◦ f )(x) = g(f (x)) = g(x2) = 2(x2) = 2x2
Imdadullah Khan (LUMS) Functions 13 / 17
27. Composition
Let f : Z 7→ Z be f (x) := x2
Let g : Z 7→ Z be g(x) := 2x
(f ◦ g)(x) : Z 7→ Z
(f ◦ g)(x) = f (g(x)) = f (2x) = (2x)2 = 4x2
(g ◦ f )(x) : Z 7→ Z
(g ◦ f )(x) = g(f (x)) = g(x2) = 2(x2) = 2x2
(f ◦ g)(·) is not necessarily the same as (g ◦ f )(·)
Sometimes, the other side of composition may not even be possible
Imdadullah Khan (LUMS) Functions 13 / 17
28. Composing function with itself
A function can be composed with itself
Imdadullah Khan (LUMS) Functions 14 / 17
29. Composing function with itself
A function can be composed with itself
f : Z 7→ Z be f (x) = x + 1
(f ◦ f )(x) = f (f (x)) = f (x + 1) = (x + 1) + 1 = x + 2
Imdadullah Khan (LUMS) Functions 14 / 17
30. Composing function with itself repeatedly
A function can be composed with itself multiple times
Imdadullah Khan (LUMS) Functions 15 / 17
31. Composing function with itself repeatedly
A function can be composed with itself multiple times
f : Z 7→ Z be f (x) = x + 1
(f ◦ (f ◦ f ))(x) = f (f (f (x))) = f (f (x + 1)) = f ((x + 2) = x + 3
Imdadullah Khan (LUMS) Functions 15 / 17
32. Composing function with itself repeatedly
A function can be composed with itself multiple times
f : Z 7→ Z be f (x) = x + 1
(f ◦ (f ◦ f ))(x) = f (f (f (x))) = f (f (x + 1)) = f ((x + 2) = x + 3
father(father(father(x))) = great grand father of x
Imdadullah Khan (LUMS) Functions 15 / 17
33. Composing function with it’s inverse
When a function is invertible (when it’s a bijection), then it can be
composed with it’s inverse
Imdadullah Khan (LUMS) Functions 16 / 17
34. Composing function with it’s inverse
When a function is invertible (when it’s a bijection), then it can be
composed with it’s inverse
If f = g−1
, then (f ◦ g)(x) = f (g(x)) = g−1
(g(x)) = x
Imdadullah Khan (LUMS) Functions 16 / 17
35. Composing function with it’s inverse
When a function is invertible (when it’s a bijection), then it can be
composed with it’s inverse
If f = g−1
, then (f ◦ g)(x) = f (g(x)) = g−1
(g(x)) = x
f : Z 7→ Z be f (x) = x + 1
Let g : Z 7→ Z be g(x) = x − 1
f = g−1
Imdadullah Khan (LUMS) Functions 16 / 17
36. Composing function with it’s inverse
When a function is invertible (when it’s a bijection), then it can be
composed with it’s inverse
If f = g−1
, then (f ◦ g)(x) = f (g(x)) = g−1
(g(x)) = x
f : Z 7→ Z be f (x) = x + 1
Let g : Z 7→ Z be g(x) = x − 1
f = g−1
f ◦ g(x) = f (g(x)) = f (x − 1) = (x − 1) + 1 = x
Imdadullah Khan (LUMS) Functions 16 / 17
37. Function inverse and composition: Summary
If f : X 7→ Y is a bijection, then if we reverse the arrows we get a
bijection too
If f : X 7→ Y is a bijection, f −1 : Y 7→ X is the inverse function such
that f −1(b) = a, when f (a) = b
Let g : A 7→ B and let f : B 7→ C. The composition of the functions
f and g is a function, (f ◦ g) : A 7→ C is (f ◦ g)(a) = f (g(a))
Function can be composed with itself (multiple times) and with it’s
inverse
Imdadullah Khan (LUMS) Functions 17 / 17