10 Functions
10 Functions
ICS141:
Discrete Mathematics for
Computer Science I
Dept. Information & Computer Sci., University of Hawaii
Jan Stelovsky
based on slides by Dr. Baek and Dr. Still
Originals by Dr. M. P. Frank and Dr. J.L. Gross
Provided by McGraw-Hill
Lecture 10
Chapter 2. Basic Structures
2.3 Functions
n 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?
Illustration
n g: A → B, f : B → C
Example
n g: A → B, f : B → C
Example
n Example 20: Let g: {a, b, c} → {a, b, c} such that
g(a) = b, g(b) = c, g(c) = a.
Let f : {a, b, c} → {1, 2, 3} such that
f(a) = 3, f(b) = 2, f(c) = 1.
What is the composition of f and g, and what
is the composition of g and f ?
n f◦g: {a, b, c} → {1, 2, 3} such that
(f◦g)(a) = 2, (f◦g)(b) = 1, (f◦g)(c) = 3.
(f◦g)(a) = f(g(a)) = f(b) = 2
(f◦g)(b) = f(g(b)) = f(c) = 1
(f◦g)(c) = f(g(c)) = f(a) = 3
n g◦f is not defined (why?)
ICS 141: Discrete Mathematics I – Fall 2011 10-12
Function Composition: University of Hawaii
Example
n If f(x) = x2 and g(x) = 2x + 1, then what is the
composition of f and g, and what is the
composition of g and f ?
n (f◦g)(x) = f(g(x))
= f(2x+1)
= (2x+1)2
(g◦f)(x) = g(f(x))
n
= g(x2)
= 2x2 + 1
Note that f◦g ≠ g◦f. (4x2+4x+1 ≠ 2x2+1)
ICS 141: Discrete Mathematics I – Fall 2011 10-13
Images of Sets under Functions
University of Hawaii
1–1ness
n For functions f over numbers, we say:
n f is strictly (or monotonically) increasing