Ex 2.3 Functions
Ex 2.3 Functions
•f:Z→Z
•f(x) = x2
Example
• What is the domain and codomain of the function
int floor(float real){…}?
Solution:
domain: the set of real numbers
codomain: the set of integer numbers
Functions
DEFINITION 2
If f is a function from A to B, we say that A is the domain of f and B is the
codomain of f. If f(a) = b, we say that b is the image of a and a is a preimage
of b. The range of f is the set of all images of elements of A. Also, if f is a
function from A to B, we say that f maps A to B.
• When we define a function, we specify its domain, its codomain, and the
mapping of elements of the domain to elements in the codomain. Two
functions are equal when they have the same domain and codomain, and
map elements of their common domain to the same elements in their
common codomain. If we change either the domain or the codomain of a
function, we obtain a different function. If we change the mapping of
elements, we also obtain a different function.
Functions
DEFINITION 3
If f1 and f2 be functions from A to R. Then f1 + f2 and f1 f2 are also functions
from A to R defined by
(f1 + f2 )(x) = f1(x) + f2 (x)
(f1 f2 ) (x) = f1(x) f2 (x)
Example
• Example: Let f1 and f2 be functions from R to R such that
f1(x) =x2 and
f2 (x) = x – x2.
What are the functions f1 + f2 and f1 f2 ?
Solution:
(f1 + f2 )(x) = f1(x) + f2 (x) = x2 + (x – x2) = x
(f1 f2 ) (x) = f1(x) f2 (x) = x2(x – x2) = x3 – x4
Example
•f1(x) = 3x, f2(x) = x + 5
•(f1 + f2)(x) = f1(x) + f2(x) = 3x + x + 5 = 4x + 5
•(f1f2)(x) = f1(x) f2(x) = 3x (x + 5) = 3x2 + 15x
Functions
•We already know that the range of a function f:A→B is
the set of all images of elements aA.
Solution: Yes.
Example
•f:R→R
•f(x) = x2
•Disproof by counterexample:
•f(3) = f(-3), but 3 -3, so f is not one-to-one.
Example
•f:R→R
•f(x) = 3x
•One-to-one ?
Onto Functions
DEFINITION 7
A function f from A to B is called onto, or surjective, if and only
if for every element b B there is an element a A with f(a) = b.
A function f is called a surjection if it is onto.