<<

CSE 1400 Applied Discrete Functions Department of Computer Sciences College of Engineering Florida Tech Fall 2011

Functions 1 Counting Functions 2 Onto Functions 3 One-to-One Functions 3 Cardinality Defined 4 Inverse 4 4 Problems on Functions 5

Abstract A function is a deterministic relation.

Functions In college algebra and pre-calculus, you In college algebra, the function concept is often explained by the have studied functions such as vertical line test: “If every vertical line crosses a graph at most once, = the graph represents a function.” A given value x in the domain y x log x cos x y = x2 y = ex = of a function maps to one and only one value y in the range of the y y = y = sin x function. Functions are denoted by writing

f : X → Y where X is the domain and Y is the co-domain of function f . The range G of f is the of Y for which there is an x ∈ X such that y = f (x). The range of f also called the of X and written

G = f (X) ⊆ Y

To write f is a function from X to Y in predicate logic requires the conjunction of two .

(∀x ∈ X)(∃y ∈ Y)( f (x) = y) cse 1400 applied discrete mathematics functions 2

y Figure 1: The vertical line x = 0.5 crosses√ the circle twice. The relation √ y = ± 1 − x2 between x and y is not a 1 x = 1/2, y = 3/2 function.

1 2

x −1 1 1 − 2

1 − 2 √ x = 1/2, y = − 3/2 −1

x2 + y2 = 1 is relation, but not a function.

and

(∀x ∈ X)(∀y, z ∈ Y)(( f (x) = y ∧ f (x) = z) =⇒ y = z)

The first states that every x in the domain maps to some element y in the range: The function is total. The second predicate states that if x maps to two different names y and z, their values are, in fact, equal. There are several things worth knowing about functions. For instance, it is useful to know The number of different functions from X to Y that can be de- fined.

Basic properties such as onto and one-to-one.

When a function can be inverted.

How functions can be composed using the output of one function as the input to another. And, it is useful to have a collection of functions that occur fre- quently in computing applications.

Counting Functions

It is easy to construct a function. For every x in the domain, choose a single y in the co-domain and include the pair (x, y) in cse 1400 applied discrete mathematics functions 3

function. For instance, you can construct 32 functions from {a, b} to {0, 1, 2}: For x = a choose y = 0, y = 1, or y = 2; For x = b choose y = 0, y = 1, or y = 2. Each of these 9 functions can be represented by one of the 9 sets below.

{(a, 0), (b, 0)}{(a, 0), (b, 1)}{(a, 0), (b, 2)} {(a, 1), (b, 0)}{(a, 1), (b, 1)}{(a, 1), (b, 2)} {(a, 2), (b, 0)}{(a, 2), (b, 1)}{(a, 2), (b, 2)}

Another example: if |X| = 6 and |Y| = 5, then 56 functions from X to Y can be defined. In general, if |X| = n and |Y| = m, there are For each of the six x’s choose one of the five y’s to x to. That’s 5 choices 6 mn = |Y||X| times. functions from X to Y.

Onto Functions

A function f : X → Y is onto when itsco -domain Y is its range. In college algebra, the concept of “onto function” is often f : X → Y is onto when f (X) = Y. explained by the horizontal line test: If every horizontal line crosses Otherwise, f is said to map X into Y. f : X → Y is onto when the graph of the function y = f (x), then f is onto. Another way to visualize the meaning of onto is to fill or not completely fill the (∀y ∈ Y)(∃x ∈ X)( f (x) = y) co-domain in the illustration of a function. 0.5 ) 3 − x )(

2 0 −

f f x )( 1 −

x −0.5 ( x = 4

X Y X Y x

= −1 y

0 0.5 1 1.5 2 2.5 3 x f maps X onto Y f does not map X onto Y The falling power x4 is not onto R.

4 ) 4

It is useful to note that when X has fewer elements than Y it is not − x )( 3 2 −

possible to construct onto functions from X to Y. That is, if |X| < x )( 2 −

|Y|, then x 0 )( 1 − x (∀( f X → Y))( f ) (

: is not onto x −2 = 5 x = y −4 One-to-One Functions 0 1 2 3 4 x The falling power x5 is onto R. Function f is one-to-one when no element y in its range is the image of more than domain element x. In college al- f : X → Y is one-to-one when gebra, this concept is often explained by another horizontal line test: (∀x0, x1 ∈ X)((x0 6= x1) =⇒ f (x0) 6= f (x1) If every horizontal line crosses the graph of y = f (x) at most once cse 1400 applied discrete mathematics functions 4

then f is one-to-one. If the cardinality of X is greater than that of 4 Y, then no (total) one-to-one function can exist. This is known as the 1 pigeonhole principle. You can’t put 10 pigeons in 9 pigeonholes. + 2 x + 2 x + 3 x 0 = y

−2

−1 −0.5 0 0.5 1 x The geometric sum y = x3 + x2 + x + 1 is a one-to-one function.

Cardinality Defined

The cardinalities of two sets X and Y are equal when there is a one-to-one function f that maps X onto Y. In particular, X has cardinality n when its elements can be put onto a one-to-one correspondence with Zn = {0, 1, . . . (n − 1)}.

Inverse Function

A key to cryptology is to find a function f that is easy to compute and all but impossible to invert. The inverse of a relation {(a, b) : a ∼ b} is the set {(b, a) : a ∼ b}. When f is a function from X to Y, that is, when

f = {(a, b) ∈ X × Y : f (a) = b}

simply reversing the order of its pairs will define a relation between Y and X, but the resulting set may not be a function. That is, b may be the image of more that one value a ∈ X. Some b ∈ Y may not be f −1 = {(b, a) : f (a) = b} the image of any value a ∈ X.

may not be a function from Y to X. If f is one-to-one, then f −1 is a . If f is one-to-one and onto, then f −1 is a total function.

Function Composition

Complex functions can be constructed from simple func- tions. The diagram below illustrates composition of functions

f : X → Y g : Y → Z cse 1400 applied discrete mathematics functions 5

and follows an element x mapped by f to y which g maps to z.

y

X f Y g Z z x

The composition of f : X → Y and g : Y → Z is denoted g ◦ f , and

(g ◦ f )(x) = g( f (x))

Problems on Functions

1. Let f : X → Y be a function. Answer the following True or False. Explain your answer. (a) The set X is the range of function f . (b) The set X is the domain of function f . (c) The set Y is the range of function f . (d) The set Y is the domain of function f . 2. Let A = {a, b, c} and B = {0, 1}. Which of the following are functions from A to B.

(a) {(a, 0), (b, 1), (c, 0)} (c) {(a, b), (b, a), (a, c)} (b) {(a, 0), (a, 1), (c, 0)} (d) {(a, 1), (b, 1), (c, 1)}

3. Consider this for constructing a function f from X to Y. For each element x ∈ X choose an element y ∈ Y and place the (x, y) in f . (a) If the cardinality of X is 5, how many times does the algorithm choose an x from X? (b) If the cardinality of Y is 9, how many choice of y are there for each x? (c) True or False: If the |X| = 5 and |Y| = 9, then there are 59 functions f from X to Y. Explain your answer. (d) True or False: If the |X| = 5 and |Y| = 9 then there are 45 functions f from X to Y. Explain your answer. (e) True or False: If the |X| = 5 and |Y| = 9 then there are 95 functions f from X to Y. Explain your answer. (f) If |X| = n and |Y| = m how many functions f can be defined from X to Y?

4. Answer the following True or False. Explain your answer. (a) The domain of a function of one Boolean variable is {0, 1}. (b) The domain of a function of two Boolean variables is {(0, 0), (0, 1), (1, 0), (1, 1)}. (c) The co-domain of a is {0, 1}. 5. How many Boolean functions B(p) in one variable are there? 6. How many Boolean functions B(p, q) in two variables are there? 7. How many Boolean functions B(p, q, r) in three variables are there? cse 1400 applied discrete mathematics functions 6

8. Let f : X → Y be a function. Answer the following True or False. Explain your answer. (a) If for every y ∈ Y there is an x ∈ X such that f (x) = y, then f is one-to-one. (b) If for every y ∈ Y there is an x ∈ X such that f (x) = y, then f is onto.

(c) If for every pair x1, x2 ∈ X, x1 6= x2 implies f (x1) 6= f (x2), then f is one-to-one.

(d) If for every pair x1, x2 ∈ X, x1 6= x2 implies f (x1) = f (x2), then f is onto. 9. Define a function that maps the natural numbers from 0 to 2n − 1 onto the two’s complement numbers −2n−1 to 2n−1 − 1.