Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesFunctions.

Slides:



Advertisements
Similar presentations
Functions Reading: Epp Chp 7.1, 7.2, 7.4
Advertisements

1.6 Functions. Chapter 1, section 6 Functions notation: f: A B x in A, y in B, f(x) = y. concepts: –domain of f, –codomain of f, –range of f, –f maps.
Cryptography and Network Security
Algebraic Structures DEFINITIONS: PROPERTIES OF BINARY OPERATIONS Let S be a set and let  denote a binary operation on S. (Here  does not necessarily.
Functions Section 2.3 of Rosen Fall 2008
Discrete Structures Chapter 5 Relations and Functions Nurul Amelina Nasharuddin Multimedia Department.
1 Discrete Math CS 2800 Prof. Bart Selman Module Basic Structures: Functions and Sequences.
Functions Goals Introduce the concept of function Introduce injective, surjective, & bijective functions.
1 Section 1.8 Functions. 2 Loose Definition Mapping of each element of one set onto some element of another set –each element of 1st set must map to something,
CS 2210 (22C:019) Discrete Structures Sets and Functions Spring 2015 Sukumar Ghosh.
Chapter 7 Functions Dr. Curry Guinn. Outline of Today Section 7.1: Functions Defined on General Sets Section 7.2: One-to-One and Onto Section 7.3: The.
Section 1.8: Functions A function is a mapping from one set to another that satisfies certain properties. We will first introduce the notion of a mapping.
Functions A B f( ) =. This Lecture We will define a function formally, and then in the next lecture we will use this concept in counting. We will also.
Sets Set Operations Functions. 1. Sets 1.1 Introduction and Notation 1.2 Cardinality 1.3 Power Set 1.4 Cartesian Products.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sifth Edition, Mc Graw-Hill, 2007 Chapter 2: Basic Structures: Sets, Functions, Sequences.
2.1 Sets 2.2 Set Operations 2.3 Functions ‒Functions ‒ Injections, Surjections and Bijections ‒ Inverse Functions ‒Composition 2.4 Sequences and Summations.
FUNCTION Discrete Mathematics Asst. Prof. Dr. Choopan Rattanapoka.
Mathematics. Session Set, Relation & Function Session - 3.
2.3 Functions A function is an assignment of each element of one set to a specific element of some other set. Synonymous terms: function, assignment, map.
Foundations of Discrete Mathematics Chapter 3 By Dr. Dalia M. Gil, Ph.D.
February 12, 2015Applied Discrete Mathematics Week 2: Functions and Sequences 1Exercises Question 1: Given a set A = {x, y, z} and a set B = {1, 2, 3,
Chapter 3 Functions Functions provide a means of expressing relationships between variables, which can be numbers or non-numerical objects.
Functions. Copyright © Peter Cappello2 Definition Let D and C be nonempty sets. A function f from D to C, for each element d  D, assigns exactly 1 element.
ICS 253: Discrete Structures I
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Copyright  The McGraw-Hill Companies, Inc. Permission required for reproduction.
Fall 2002CMSC Discrete Structures1 … and the following mathematical appetizer is about… Functions.
10/26/20151 … and the following mathematical appetizer is about… Functions.
1 Annoucement n Skills you need: (1) (In Thinking) You think and move by Logic Definitions Mathematical properties (Basic algebra etc.) (2) (In Exploration)
FUNCTIONS.
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Relations, Functions.
Functions Section 2.3 of Rosen Spring 2012 CSCE 235 Introduction to Discrete Structures Course web-page: cse.unl.edu/~cse235 Questions: Use Piazza.
MSU/CSE 260 Fall Functions Read Section 1.8.
Dr. Eng. Farag Elnagahy Office Phone: King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222.
1 Discrete Structures – CNS 2300 Text Discrete Mathematics and Its Applications (5 th Edition) Kenneth H. Rosen Chapter 1 The Foundations: Logic, Sets,
Chapter 1 SETS, FUNCTIONs, ELEMENTARY LOGIC & BOOLEAN ALGEBRAs BY: MISS FARAH ADIBAH ADNAN IMK.
1.4 Sets Definition 1. A set is a group of objects . The objects in a set are called the elements, or members, of the set. Example 2 The set of positive.
Example Prove that: “IF 3n + 2 is odd, then n is odd” Proof by Contradiction: -p = 3n + 2 is odd, q = n is odd. -Assume that ~(p  q) is true OR -(p 
Chapter 9 Functions Let A and B be nonempty sets. A function f from A to B, written f: A  B is a relation from A to B with the property that every element.
Functions Reading: Chapter 6 (94 – 107) from the text book 1.
Basic Structures: Functions Muhammad Arief download dari
Chapter 5 – Relations and Functions. 5.1Cartesian Products and Relations Definition 5.1: For sets A, B  U, the Cartesian product, or cross product, of.
Agenda Week 10 Lecture coverage: –Functions –Types of Function –Composite function –Inverse of a function.
CompSci 102 Discrete Math for Computer Science January 31, 2012 Prof. Rodger Slides modified from Rosen AB a b c d x y z.
Functions Section 2.3. Section Summary Definition of a Function. – Domain, Cdomain – Image, Preimage Injection, Surjection, Bijection Inverse Function.
11 DISCRETE STRUCTURES DISCRETE STRUCTURES UNIT 5 SSK3003 DR. ALI MAMAT 1.
11 DISCRETE STRUCTURES DISCRETE STRUCTURES UNIT 5 SSK3003 DR. ALI MAMAT 1.
MATH 224 – Discrete Mathematics
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Relations, Functions.
Basic Structures: Sets, Functions, Sequences, and Sums.
Sets Definition: A set is an unordered collection of objects, called elements or members of the set. A set is said to contain its elements. We write a.
Review 2 Basic Definitions Set - Collection of objects, usually denoted by capital letter Member, element - Object in a set, usually denoted by lower.
CSNB 143 Discrete Mathematical Structures
1 Functions CS 202 Epp section ??? Aaron Bloomfield.
FUNCTIONS COSC-1321 Discrete Structures 1. Function. Definition Let X and Y be sets. A function f from X to Y is a relation from X to Y with the property.
Relations and Functions ORDERED PAIRS AND CARTESIAN PRODUCT An ordered pair consists of two elements, say a and b, in which one of them, say a is designated.
Discrete Mathematics 3. MATRICES, RELATIONS, AND FUNCTIONS Lecture 6 Dr.-Ing. Erwin Sitompul
1 Lecture 5 Functions. 2 Functions in real applications Curve of a bridge can be described by a function Converting Celsius to Fahrenheit.
Section 2.3. Section Summary  Definition of a Function. o Domain, Cdomain o Image, Preimage  One-to-one (Injection), onto (Surjection), Bijection 
Chapter 2 1. Chapter Summary Sets The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions and sequences.
FUNCTIONS.
“It is impossible to define every concept.” For example a “set” can not be defined. But Here are a list of things we shall simply assume about sets. A.
Discrete Mathematics Functions
Relations, Functions, and Matrices
Chapter 2 Sets and Functions.
Chapter 3 Relation and Function Homework 4 For each of the following relations on set A = { 1,2,3,4 }, check each of them whether they are reflexive, irreflexive,
Functions Section 2.3.
CS201: Data Structures and Discrete Mathematics I
Functions CS 202 Epp section 7.1.
Ch 5 Functions Chapter 5: Functions
Functions Section 2.3.
Presentation transcript:

Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesFunctions

Functions A function (f) from a set S to a set T is a correspondence that associates with each element x of S a unique element y of T. The mapping (association) from S to T may be a many- to-one mapping. That is, several elements in S can map to a single element in T Example: If S = Z, T = N, s 1 = -5 and s 2 = 5, f (x) = x 2 then both s 1 and s 2 map to the same element (25) in T A function is a special case of binary relation. Section 4.4Functions1

Section 4.4Functions2 DEFINITIONS: TERMINOLOGY FOR FUNCTIONS 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}. There are three parts to a function: A set of starting values A set from which associated values come The association itself

Section 4.4Functions3 In a function from S to T the starting set S is called the domain of the function and T is the codomain. For f a function from S to T we write f: S  T. A function identifies a set of ordered pairs (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). We say that t is the image of s. The set of all t’s that are associated with values from S is the range of the function.

Section 4.4Functions4 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. ** The definition of a function includes functions of more than one variable. We can have a function f : S 1  S 2 ...  S n  T that associates with each ordered n-tuple of elements (s 1, s 2,..., s n ), s i  S i, a unique element of T. The floor function  x  associates with each real number x the greatest integer less than or equal to 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.

Section 4.4Functions5 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. Not all functional associations can be described by an equation. Technically, the equation only describes a way to compute associated values. RR g: R  R, where g(x) = x 3. ZR f : Z  R, given by f (x) = x 3 is not the same function as g. The domain has been changed, which changes the set of ordered pairs.

Section 4.4Functions6 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.4Functions7 Onto Functions DEFINITION: ONTO (SURJECTIVE) FUNCTION 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. g: R  R where g(x) = x 3 is an onto function.

Section 4.4Functions8 One-to-One Functions DEFINITION: ONE-TO-ONE (INJECTIVE) FUNCTION 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 s 1 and s 2 of S with f (s 1 ) = f (s 2 ) and then show that s 1 = s 2. The function g: R  R defined by g(x) = x 3 is one-to- one because if x and y are real numbers with g(x) = g(y), then x 3 = y 3 and x = y.

Section 4.4Functions9 Bijections DEFINITION: BIJECTIVE FUNCTION A function f:S  T is bijective (a bijection) if it is both one-to-one and onto. The function g: R  R given by g(x) = x 3 is a bijection.

Section 4.4Functions10 Composition of Functions DEFINITION: COMPOSITION FUNCTION 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)). The function g  f is applied right to left; function f is applied first and then function g. Example: Let __ ______ f(x) = 1 + x 2, g(x) =  y, then g(f(x)) =  1 + x 2 Function composition preserves the properties of being onto and being one-to-one.

Section 4.4Functions11 Composition of Functions THEOREM ON COMPOSING TWO BIJECTIONS The composition of two bijections is a bijection. Let f: S → T be a bijection. Because f is onto, every t  T has a preimage in S. Therefore, every u  U has a preimage in S. Because f is one-to-one, that preimage is unique.

Section 4.4Functions12 Inverse Functions Let f: S → T be a bijection. Because f is onto, every t  T has a preimage in S. Because f is one-to-one, that preimage 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 i S. DEFINITION: INVERSE FUNCTION Let f be a function, f: S  T. If there exists a function g: T  S such that g  f = i S and f  g i T, then g is called the inverse function of f, denoted by f -1. THEOREM ON BIJECTIONS AND INVERSE FUNCTIONS Let f: S → T. Then f is a bijection if and only if f -1 exists.

Section 4.4Functions13 Permutation Functions DEFINITION: PERMUTATIONS OF A SET For a given set A, S A = { f  f: A  A and f is a bijection}. S A is thus the set of all bijections of set A into (and therefore onto) itself; such functions are called permutations of A. If f and g both belong to S A, then they each have domain = range = A. If A = {1, 2, 3, 4}, one permutation function of A, call it f, is given by f = {(1,2), (2,3), (3,1), (4,4)}. A shorter way to describe the permutation f is to use cycle notation and write f = (1, 2, 3), understood to mean that f maps each element listed to the one on its right, the last element listed to the first, and an element of the domain not listed to itself.

Section 4.4Functions14 Permutation Functions If we were to compute f  g (1, 2, 3)  (2,3), we would get (1,2). If, however, f and g are members of SA and f and g are disjoint cycles—the cycles have no elements in common—then f  g = g  f. The permutation that maps each element of A to itself is the identity function on A, i A, also called the identity permutation. A permutation on a set that maps no element to itself is called a derangement.

Section 4.4Functions15 How Many Functions? THEOREM ON THE NUMBER OF FUNCTIONS WITH FINITE DOMAINS AND CODOMAINS If  S  = m and  T  = n, then: 1. The number of functions f: S  T is n m. 2. The number of one-to-one functions f: S  T, assuming m > n, is n!/(n  m)! 3. The number of onto functions f: S  T, assuming m  n, is n m  C(n, 1)(n  1) m + C(n, 2)(n  2) m  C(n, 3)(n  3) m (  1) n  1 C(n, n  1)(1) m For example, let S = {A, B, C} and T = {a, b}. Find the number of functions from S onto T. 23  C(2, 1)(1) 3 = 8  2  1 = 6

Section 4.4Functions16 How Many Functions? If A is a set with  A  = n, then the number of permutations of A is n! This number can be obtained by any of three methods: A combinatorial argument (each of the n elements in the domain must map to one of the n elements in the range with no repetitions) Thinking of such functions as permutations on a set with n elements and noting that P(n,n) = n! Using result (2) in the previous theorem with m = n

Section 4.4Functions17 Equivalent Sets DEFINITIONS: EQUIVALENT SETS AND CARDINALITY A set S is equivalent to a set T if there exists a bijection f: S  T. Two sets that are equivalent have the same cardinality. The notion of equivalent sets allows us to extend our definition of cardinality from finite to infinite sets. If S is equivalent to T, then all the members of S and T are paired off by f in a one-to-one correspondence. CANTOR’S THEOREM For any set S, S and ℘ (S) are not equivalent.

Section 4.4Functions18 Order of Magnitude of Functions Order of magnitude is a way of comparing the “rate of growth” of different functions. For instance, if we compute f (x) = x and g(x) = x 2 for increasing values of x, the g-values will be larger than the f-values by an ever increasing amount. This difference in the rate of increase cannot be overcome by simply multiplying the f-values by some large constant; DEFINITION: ORDER OF MAGNITUDE Let f and g be functions mapping nonnegative reals into nonnegative reals. Then f is the same order of magnitude as g, written f=Θ(g), if there exist positive constants n 0, c 1, and c 2 such that for x  n 0, c 1 g(x)  f (x)  c 2 g(x).

Section 4.4Functions19 Order of Magnitude of Functions For example, say f = Θ (x 2 ) and g = Θ (x 2 ). A polynomial is always the order of magnitude of its highest-degree term; lower-order terms and all coefficients can be ignored. Order of magnitude is important in analysis of algorithms. Usually the number of times such tasks must be done in executing the algorithm will depend on the size of the input. Rather than compute the exact functions for the amount of work done, it is easier and often just as useful to settle for order-of-magnitude information.

Section 4.4Functions20 Order of Magnitude of Functions

Section 4.4Functions21 Order of Magnitude of Functions DEFINITION: BIG OH Let f and g be functions mapping nonnegative reals into nonnegative reals. Then f is big oh of g, written f = O(g), if there exist positive constants n 0 and c such that for x  n 0, f (x)  cg(x). If f (n) represents the work done by an algorithm on an input of size n, it may be difficult to find a simple function g such that f = Θ (g). We may still be able to find a function g that serves as an upper bound for f. In other words, while f may not have the same shape as g, f will never grow significantly faster than g. The big oh notation f = O(g) says that f grows at the same rate or at a slower rate than g.

Section 4.4Functions22 Order of Magnitude of Functions If we know that f definitely grows at a slower rate than g, then we can say something stronger. This is the little oh of g, written f = o(g). The relationship between big oh and little oh is this: If f = O(g), then either f= Θ (g) or f = o(g).