Chapter 5.4 Functions
Reading: 5.4 Next Class: 5.5
1 Motivation
Different types of relations allow different techniques to be applied efficiently.
Partial orderings permit to represent any ordered set or general sets with precedence constraints. – Derivation of schedules – Design of (parallel) programs
Equivalence relations allow the representation of arbitrary partitions in sets. – Grouping of information in a database – Characterization of specific properties of elements of sets
Functions represent an important class of relations in mathematics or for the correlation of data.
Section 4.4 Functions
1 2 Functions
DEFINITIONS: Let S and T be sets. A function (mapping) f from S to T, f : S T, is a subset of S T, where each member of S appears exactly once as the first component of an ordered pair. S is the domain and T the codomain of the function. If (s, t) belongs to the function, then t is denoted by f(s); t is the image of s under f, s is a preimage of t under f, and f is said to map s to t. For A S, f (A) denotes { f (a) a A}.
f(S) is called the range of f, which is the set of all images written as R. R T
There are three parts to a function:
A set of starting values
A set from which associated values come
The association itself Section 4.4 Functions
3 Functions (cont’d)
The set of starting values is called the domain of the function.
The set from which associated values come is called the codomain of the function.
Here f is a function from S to T, symbolized f: S T. S is the domain and T is the codomain. The association itself is a set of ordered pairs, each of the form (s,t) where s S, t T, and t is the value from T that the function associates with the value s from S; t = f (s).
Section 4.4 Functions
2 4 Functions (cont’d)
A function from S to T is a subset of S T with certain restrictions on the ordered pairs it contains.
By the definition of a function, a binary relation that is one- to-many (or many-to-many) cannot be a function.
Each member of S must be used as a first component.
A function is either one-to-one or many-to-one relation.
Note: There is always exactly ONE image for every x S, but there can be multiple (or no) preimages for a given y T.
The definition of a function includes functions of more than one variable. We can have a function f : S1 S2 ... Sn T that associates with each ordered n-tuple of elements (s1, s2, ... , sn), si Si, a unique element of T.
Section 4.4 Functions
5 Functions (cont’d)
The floor function x associates with each real number x the greatest integer less than or equal to x, i.e., f: R Z, f(x) = x
The ceiling function x associates with each real number x the smallest integer greater than or equal to x.
2.8 = 2, 2.8 = 3. Both the floor function and the ceiling function are functions from R to Z.
For any integer x and any positive integer n, the modulo function, denoted by f (x) = x mod n, associates with x the remainder when x is divided by n. One can write x as x = qn + r, 0 r < n, where q is the quotient and r is the remainder, so the value of x mod n is r.
Eg. 25 mod 2 = 1 since 25 = 12 * 2 + 1, 21 mod 3 = 0 since 21 = 7*3 + 0. -17 mod 5 = 3 since -17 = (-4) * 5 + 3
Section 4.4 Functions
3 6 Functions (cont’d)
Not all functional associations can be described by an equation. Technically, the equation only describes a way to compute associated values.
Depending on the domain and codomain the same equation can have different properties. 3 g: R R, where g(x) = x . 3 f : Z R, given by f (x) = x is not the same function as g. The domain has been changed, which changes the set of ordered pairs.
Section 4.4 Functions
7 Functions (cont’d)
DEFINITION: EQUAL FUNCTIONS Two functions are equal if they have the same domain, the same codomain, and the same association of values of the codomain with values of the domain.
To show that two functions with the same domain and the same codomain are equal, one must show that the associations are the same.
This can be done by showing that, given an arbitrary element of the domain, both functions produce the same associated value for that element; that is, they map it to the same place.
Section 4.4 Functions
4 8 Onto Functions
DEFINITION: A function f: S T is an onto, or surjective, function if the range of f equals the codomain of f.
In every function with range R and codomain T, R T.
To prove that a given function is onto,
Show that T R; then it will be true that R = T.
Show that an arbitrary member of the codomain is a member of the range. 3 Eg. g: R R where g(x) = x is an onto function.
Section 4.4 Functions
9 Onto Functions (cont’d)
For an onto, or surjective, function, every element of the codomain is the image of at least one element in the domain.
Examples:
f: R R, f(x) = 2x + 3. 2 But: f: R R, f(x) = x is not surjective.
Section 4.4 Functions
5 10 One-to-One Functions
DEFINITION: A function f: S T is one-to-one, or injective, if no member of T is the image under f of two distinct elements of S.
The one-to-one idea here is the same as for binary relations in general, except that every element of S must appear as a first component in an ordered pair.
To prove that a function is one-to-one, we assume that there are
elements s1 and s2 of S with f (s1) = f (s2) and then show that s1 = s2. 3 The function g: R R defined by g(x) = x is one-to-one because if x and y are real numbers with g(x) = g(y), then x3 = y3 and x = y.
Section 4.4 Functions
11 One-to-One Functions (cont’d)
For a one-to-one, or injective, function, every element in the codomain is the image of at most one element in the domain.
Examples:
f: N R, f(x) = 2x + 3. 2 But: f: R R, f(x) = x is not injective.
But: f: {Honda, Ford, GM, Toyota} {USA, Japan}, f = {(Honda, Japan), (Ford, USA), (GM, USA), (Toyota, Japan)} is not injective.
Section 4.4 Functions
6 12 Bijections
DEFINITION: A function f:S T is bijective (a bijection) if it is both one-to- one and onto.
3 The function g: R R given by g(x) = x is a bijection.
Section 4.4 Functions
13 Bijections (cont’d)
For a bijection, every element in the domain has exactly one image in the codomain and every element of the codomain is the image of exactly one element in the domain.
Bijections are mappings that uniquely pair one element from the domain and one element of the codomain.
For a bijection, |S| = |T|.
Section 4.4 Functions
7 14 Composition of Functions
If the codomain of a function f is equal to the domain of a function g, then the two functions can be composed leading to a new function. f: S T g: T U
g f: S U, (g f )(s) = g( f (s))
DEFINITION:
Let f: S T and g: T U. Then the composition function, g f, is a function from S to U defined by (g f )(s) = g( f (s)).
Section 4.4 Functions
15 Composition of Functions (cont’d)
The function g f is applied right to left; function f is applied first and then function g.
Function composition preserves the properties of being onto and being one-to-one.
Section 4.4 Functions
8 16 Composition of Functions (cont’d)
Examples: 2 f: R R, f(x) = x , g: R R, g(x) = x 2 g f: R R, (g f) (x) = x 2 (g f)(2.3) = 2.3 = 5.29 = 5 2 f g: R R, (f g) (x) = ( x) 2 2 (f g)(2.3) = ( 2.3) = 2 = 4
Note: Order is important. Even if f g is a valid function, g f is often not valid. Moreover, even if both are valid functions they are often not equivalent.
Examples: 2 f: Z N, f(x) = x , g: N R, g(x) = x1/2
g f: Z R, (g f) (x) = |x|. f g does not exist.
Section 4.4 Functions
17 Composition of Functions (cont’d)
The composition of functions can be visualized using commutative diagrams. – Commutative diagrams represent the connections between domains and codomains established by a given set of functions. Composite functions can be found as “shortcuts” of a sequence of functions. f S T
g f g
U The composition, , of two functions is a binary operation on the set of all functions.
Section 4.4 Functions
9 18 Composition of Functions (cont’d)
The composition of two injective functions is again an injective function.
Proof: see the book.
The composition of two surjective functions is again a surjective function.
Proof: see the book.
THEOREM ON COMPOSING TWO BIJECTIONS The composition of two bijections is a bijection.
Section 4.4 Functions
19 Inverse Functions
Let f: S → T be a bijection. Because f is onto, every t T has a pre-image in S. Because f is one-to-one, that pre- image is unique.
The function that maps each element of a set S to itself, that is, that leaves each element of S unchanged, is called
the identity function on S and denoted by iS.
DEFINITION: Let f be a function, f: S T. If there
exists a function g: T S such that g f = iS and f g = iT, then g is called the inverse function of f, denoted by f -1.
T S f f(s)=t s=g(t) g
Section 4.4 Functions
10 20 Inverse Functions (cont’d)
A function f has an inverse if and only if f is a bijection.
Examples:
f: z z, f(x) = x - 5, f -1: z z, f -1 (x) = x + 5.
THEOREM ON BIJECTIONS AND INVERSE FUNCTIONS Let f: S → T. Then f is a bijection if and only if f -1 exists.
Section 4.4 Functions
21 Exercise
Let S = {1, 2, 3, 4}, T = {1, 2, 3, 4, 5, 6}, and U = {6, 7, 8, 9, 10}. Also let f = {(1, 2), (2, 4), (3, 3), (4, 6)} be a function from S to T, and let g = {(1, 7), (2, 6), (3, 9), (4, 7), (5, 8), (6, 9)} be a function from T to U.
Write the ordered pairs in the function g f .
Section 4.4 Functions
11