FUNCTION 030513122 - Discrete Mathematics Asst. Prof. Dr. Choopan Rattanapoka.

Slides:



Advertisements
Similar presentations
Functions Section 2.3 of Rosen Fall 2008
Advertisements

Lecture 3 Set Operations & Set Functions. Recap Set: unordered collection of objects Equal sets have the same elements Subset: elements in A are also.
CSE115/ENGR160 Discrete Mathematics 02/16/12 Ming-Hsuan Yang UC Merced 1.
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,
Functions.
Functions. Let A and B be sets A function is a mapping from elements of A to elements of B and is a subset of AxB i.e. can be defined by a set of tuples!
Discrete Structures Functions Dr. Muhammad Humayoun Assistant Professor COMSATS Institute of Computer Science, Lahore.
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.
Sets Set Operations Functions. 1. Sets 1.1 Introduction and Notation 1.2 Cardinality 1.3 Power Set 1.4 Cartesian Products.
2.1 Sets 2.2 Set Operations 2.3 Functions ‒Functions ‒ Injections, Surjections and Bijections ‒ Inverse Functions ‒Composition 2.4 Sequences and Summations.
Mathematics. Session Set, Relation & Function Session - 3.
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,
ICS 253: Discrete Structures I
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesFunctions.
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)
Discrete Mathematics CS 2610 September 12, Agenda Last class Functions  Vertical line rule  Ordered pairs  Graphical representation  Predicates.
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,
Functions1 Elementary Discrete Mathematics Jim Skon.
Chapter 1 SETS, FUNCTIONs, ELEMENTARY LOGIC & BOOLEAN ALGEBRAs BY: MISS FARAH ADIBAH ADNAN IMK.
321 Section, Week 3 Natalie Linnell. Functions A function from A to B is an assignment of exactly one element of B to each element of A. We write f(a)
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 
Functions Reading: Chapter 6 (94 – 107) from the text book 1.
Basic Structures: Functions Muhammad Arief download dari
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.
Functions. L62 Agenda Section 1.8: Functions Domain, co-domain, range Image, pre-image One-to-one, onto, bijective, inverse Functional composition and.
11 DISCRETE STRUCTURES DISCRETE STRUCTURES UNIT 5 SSK3003 DR. ALI MAMAT 1.
11 DISCRETE STRUCTURES DISCRETE STRUCTURES UNIT 5 SSK3003 DR. ALI MAMAT 1.
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.
CSC102 - Discrete Structures Functions
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.
1 Discrete Mathematical Functions Examples.
Functions CSRU1400 Spring 2008Ellen Zhang 1 CISC1400, Fall 2010 Ellen Zhang.
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.
Discrete Mathematics Functions
Functions 7/7/2016COCS - Discrete Structures1. Functions A function f from a set A to a set B is an assignment of exactly one element of B to each element.
Functions Section 2.3.
Applied Discrete Mathematics Week 2: Functions and Sequences
Functions.
… and the following mathematical appetizer is about…
Functions.
Functions Section 2.3.
Functions.
CSE15 Discrete Mathematics 02/27/17
CS100: Discrete structures
… and the following mathematical appetizer is about…
Functions CS 202 Epp section 7.1.
Functions.
ICS 253: Discrete Structures I
… and the following mathematical appetizer is about…
Functions Rosen 6th ed., §2.3.
Functions Rosen 2.3, 2.5 f( ) = A B Lecture 5: Oct 1, 2.
Functions Section 2.3.
Presentation transcript:

FUNCTION Discrete Mathematics Asst. Prof. Dr. Choopan Rattanapoka

Outline  Definitions & terminology  function, domain, co-domain, image, preimage (antecedent), range, image of a set, strictly increasing, strictly decreasing, monotonic  Properties  One-to-one (injective)  Onto (surjective)  One-to-one correspondence (bijective)  Exercices (5)  Inverse functions (examples)  Operators  Composition, Equality  Important functions  identity, absolute value, floor, ceiling, factorial

บทนำ  รูปแบบของฟังก์ชันที่น่าจะเคยเห็นกันมาบ้างแล้ว เช่น  f(x,y) = x+y  f(x) = x  f(x) = sin(x)  แต่ในวิชานี้จะเรียนเกี่ยวกับการนนิยาม domains และ ranges  เพราะฉะนั้นเราอาจจะไม่จำเป็นต้องเขียนฟังก์ชันในอยู่ ในรูปแบบสวยหรูเหมือนข้างต้น

คำนิยามของ Function  คำนิยาม : ฟังก์ชัน f  จาก set A ไป set B  คือการกำหนดค่าของสมาชิก B เพียงค่าเฉพาะค่าเดียว (exactly one) ไปยังแต่ละสมาชิกของ A  เราสามารถเขียน f(a) = b ถ้า b เป็นค่าเฉพาะที่เป็น สมาชิกของ B ที่ถูกกำหนดโดยฟังก์ชันของค่า a เมื่อ a  A.  รูปแบบสัญลักษณ์ : f: A  B อ่านได้ว่า ‘f maps A to B’  ข้อควรจำ  สมาชิกทุกตัวของ A จะมีการ mapping เพียงค่าเดียว ( single mapping )  แต่ละสมาชิกใน B อาจจะถูก map โดยสมาชิกใน A หลายตัว หรือไม่โดนจับคู่เลยก็ได้

Terminology  Let f: A  B and f(a)=b. Then we use the following terminology:  A is the domain of f, denoted dom(f)  B is the co-domain of f  b is the image of a  a is the preimage (antecedent) of b  The range of f is the set of all images of elements of A, denoted rng(f)

Function: Visualization A function, f: A  B A B a b f DomainCo-Domain PreimageImage, f(a)=b Range

More Definitions (1)  Definition: Let f 1 and f 2 be two functions from a set A to R. Then f 1 +f 2 and f 1 f 2 are also function from A to R defined by:  (f 1 +f 2 )(x) = f 1 (x) + f 2 (x)  f 1 f 2 (x)= f 1 (x)f 2 (x)  Example: Let f 1 (x)=x 4 +2x 2 +1 and f 2 (x)=2-x 2  (f 1 +f 2 )(x) = x 4 +2x x 2 = x 4 +x 2 +3  f 1 f 2 (x) = (x 4 +2x 2 +1)(2-x 2 )= -x 6 +3x 2 +2

More Definitions (2)  Definition: Let f: A  B and S  A. The image of the set S is the subset of B that consists of all the images of the elements of S. We denote the image of S by f(S), so that f(S)={ f(s) |  s  S }  Note there that the image of S is a set and not an element.

Image of a set: Example  Let:  A = {a 1,a 2,a 3,a 4,a 5 }  B = {b 1,b 2,b 3,b 4,b 5 }  f={(a 1,b 2 ), (a 2,b 3 ), (a 3,b 3 ), (a 4,b 1 ), (a 5,b 4 )}  S={a 1,a 3 }  Draw a diagram for f  What is the:  Domain, co-domain, range of f?  Image of S, f(S)?

More Definitions (3)  Definition: A function f whose domain and codomain are subsets of the set of real numbers ( R ) is called  strictly increasing if f(x)<f(y) whenever x<y and x and y are in the domain of f.  strictly decreasing if f(x)>f(y) whenever x<y and x and y are in the domain of f.  A function that is increasing or decreasing is said to be monotonic

Outline Definitions & terminology Properties – One-to-one (injective) – Onto (surjective) – One-to-one correspondence (bijective) – Exercices (5) Inverse functions (examples) Operators Important functions

Definition: Injection  Definition: A function f is said to be one-to-one or injective (or an injection) if  x and y in in the domain of f, f(x)=f(y)  x=y  Intuitively, an injection simply means that each element in the range has at most one preimage (antecedent)  It is useful to think of the contrapositive of this definition x  y  f(x)  f(y)

Definition: Surjection  Definition: A function f: A  B is called onto or surjective (or an surjection) if  b  B,  a  A with f(a)=b  Intuitively, a surjection means that every element in the codomain is mapped into (i.e., it is an image, has an antecedent)  Thus, the range is the same as the codomain

Definition: Bijection  Definition: A function f is a one-to-one correspondence (or a bijection), if is both one-to-one (injective) and onto (surjective)  One-to-one correspondences are important because they endow a function with an inverse.  They also allow us to have a concept cardinality for infinite sets  Let’s look at a few examples to develop a feel for these definitions…

Functions: Example 1  Is this a function? Why? a1a1 a2a2 a3a3 a4a4 b1b1 b2b2 b3b3 b4b4 AB No, because each of a 1, a 2 has two images

Functions: Example 2  Is this a function  One-to-one (injective)? Why?  Onto (surjective)? Why? a1a1 a2a2 a3a3 a4a4 b1b1 b2b2 b3b3 b4b4 AB No, b 1 has 2 preimages No, b 4 has no preimage

Functions: Example 3  Is this a function  One-to-one (injective)? Why?  Onto (surjective)? Why? a1a1 a2a2 a3a3 b1b1 b2b2 b3b3 b4b4 AB Yes, no b i has 2 preimages No, b 4 has no preimage

Functions: Example 4 a1a1 a2a2 a3a3 a4a4 b1b1 b2b2 b3b3 AB  Is this a function  One-to-one (injective)? Why?  Onto (surjective)? Why? No, b 3 has 2 preimages Yes, every b i has a preimage

Functions: Example 5 a1a1 a2a2 a3a3 a4a4 b1b1 b2b2 b3b3 b4b4 AB  Is this a function  One-to-one (injective)?  Onto (surjective)? Thus, it is a bijection or a one-to-one correspondence

Exercice 1  Let f: Z  Z be defined by f(x)=2x-3  What is the domain, codomain, range of f?  Is f one-to-one (injective)?  Is f onto (surjective)?  Clearly, dom(f)= Z. To see what the range is, note that: b  rng(f)  b=2a-3, with a  Z  b=2(a-2)+1  b is odd

Exercise 1 (cont’d)  Thus, the range is the set of all odd integers  Since the range and the codomain are different (i.e., rng(f)  Z ), we can conclude that f is not onto (surjective)  However, f is one-to-one injective. Using simple algebra, we have: f(x 1 ) = f(x 2 )  2x 1 -3 = 2x 2 -3  x 1 = x 2 QED

Exercise 2  Let f be as before f(x)=2x-3 but now we define f: N  N  What is the domain and range of f?  Is f onto (surjective)?  Is f one-to-one (injective)? By changing the domain and codomain of f, f is not even a function anymore. Indeed, f(1)=2  1-3=-1  N

Exercice 3  Let f: Z  Z be defined by f(x) = x 2 - 5x + 5  Is this function  One-to-one?  Onto?

Exercice 3: Answer  It is not one-to-one (injective) f(x 1 )=f(x 2 )  x x 1 +5=x x 2 +5  x x 1 = x x 2  x x 2 2 = 5x 1 - 5x 2  (x 1 - x 2 )(x 1 + x 2 ) = 5(x 1 - x 2 )  (x 1 + x 2 ) = 5 Many x 1,x 2  Z satisfy this equality. There are thus an infinite number of solutions. In particular, f(2)=f(3)=-1  It is also not onto (surjective). The function is a parabola with a global minimum at (5/2,-5/4). Therefore, the function fails to map to any integer less than -1  What would happen if we changed the domain/codomain?

Exercice 4  Let f: Z  Z be defined by f(x) = 2x 2 + 7x  Is this function  One-to-one (injective)?  Onto (surjective)?  Again, this is a parabola, it cannot be onto (where is the global minimum?)

Exercice 4: Answer  f(x) is one-to-one! Indeed: f(x 1 )=f(x 2 )  2x x 1 =2x x 2  2x x 2 2 = 7x 2 - 7x 1  2(x 1 - x 2 )(x 1 + x 2 ) = 7(x 2 - x 1 )  2(x 1 + x 2 ) = -7  (x 1 + x 2 ) = -7  (x 1 + x 2 ) = -7/2 But -7/2  Z. Therefore it must be the case that x 1 = x 2. It follows that f is a one-to-one function. QED  f(x) is not surjective because f(x)=1 does not exist 2x 2 +7x=1  x(2x +7)=1 the product of two integers is 1 if both integers are 1 or -1 x=1  (2x+7)=1  9 =1, impossible x=-1  -1(-2+7)=1  -5=1, impossible

Exercise 5  Let f: Z  Z be defined by f(x) = 3x 3 – x  Is this function  One-to-one (injective)?  Onto (surjective)?

Exercice 5: f is one-to-one  To check if f is one-to-one, again we suppose that for x 1,x 2  Z we have f(x 1 )=f(x 2 ) f(x 1 )=f(x 2 )  3x 1 3 -x 1 =3x 2 3 -x 2  3x x 2 3 = x 1 - x 2  3 (x 1 - x 2 )(x 1 2 +x 1 x 2 +x 2 2 )= (x 1 - x 2 )  (x 1 2 +x 1 x 2 +x 2 2 )= 1/3 which is impossible because x 1,x 2  Z thus, f is one-to-one

Exercice 5: f is not onto  Consider the counter example f(a)=1  If this were true, we would have 3a 3 – a=1  a(3a 2 – 1)=1 where a and (3a 2 – 1)  Z  The only time we can have the product of two integers equal to 1 is when they are both equal to 1 or -1  Neither 1 nor -1 satisfy the above equality Thus, we have identified 1  Z that does not have an antecedent and f is not onto (surjective)

Outline Definitions & terminology – function, domain, co-domain, image, preimage (antecedent), range, image of a set, strictly increasing, strictly decreasing, monotonic Properties – One-to-one (injective), onto (surjective), one-to-one correspondence (bijective) – Exercices (5) Inverse functions (examples) Operators – Composition, Equality Important functions – identity, absolute value, floor, ceiling, factorial

Inverse Functions (1)  Definition: Let f: A  B be a bijection. The inverse function of f is the function that assigns to an element b  B the unique element a  A such that f(a)=b  The inverse function is denote f -1.  When f is a bijection, its inverse exists and f(a)=b  f -1 (b)=a

Inverse Functions (2)  Note that by definition, a function can have an inverse if and only if it is a bijection. Thus, we say that a bijection is invertible  Why must a function be bijective to have an inverse?  Consider the case where f is not one-to-one (not injective). This means that some element b  B has more than one antecedent in A, say a 1 and a 2. How can we define an inverse? Does f -1 (b)=a 1 or a 2 ?  Consider the case where f is not onto (not surjective). This means that there is some element b  B that does not have any preimage a  A. What is then f -1 (b)?

Inverse Functions: Representation A function and its inverse A B a b f(a) DomainCo-Domain f -1 (b)

Inverse Functions: Example 1  Let f: R  R be defined by f(x) = 2x – 3  What is f -1 ? 1. We must verify that f is invertible, that is, is a bijection. We prove that is one-to-one (injective) and onto (surjective). It is. 2. To find the inverse, we use the substitution Let f -1 (y)=x And y=2x-3, which we solve for x. Clearly, x= (y+3)/2 So, f -1 (y)= (y+3)/2

Inverse Functions: Example 2  Let f(x)=x 2. What is f -1 ?  No domain/codomain has been specified.  Say f: R  R  Is f a bijection? Does its inverse exist? – Answer: No Say we specify that f: A  B where A={x  R |x  0} and B={y  R | y  0} – Is f a bijection? Does its inverse exist? – Answer: Yes, the function becomes a bijection and thus, has an inverse

Inverse Functions: Example 2 (cont’)  To find the inverse, we let  f -1 (y)=x  y=x 2, which we solve for x  Solving for x, we get x=  y, but which one is it?  Since dom(f) is all nonpositive and rng(f) is nonnegative, thus x must be nonpositive and f -1 (y)= -  y  From this, we see that the domains/codomains are just as important to a function as the definition of the function itself

Inverse Functions: Example 3  Let f(x)=2 x  What should the domain/codomain be for this function to be a bijection?  What is the inverse?  The function should be f: R  R +  Let f -1 (y)=x and y=2 x, solving for x we get x=log 2 (y). Thus, f -1 (y)=log 2 (y)  What happens when we include 0 in the codomain?  What happens when restrict either sets to Z ?

Function Composition (1)  The value of functions can be used as the input to other functions  Definition: Let g:A  B and f:B  C. The composition of the functions f and g is (f  g) (x)=f(g(x))  f  g is read as ‘f circle g’, or ‘f composed with g’, ‘f following g’, or just ‘f of g’  In LaTeX: $\circ$

Function Composition (2)  Because (f  g)(x)=f(g(x)), the composition f  g cannot be defined unless the range of g is a subset of the domain of f f  g is defined  rng(g)  dom(f)  The order in which you apply a function matters: you go from the inner most to the outer most  It follows that f  g is in general not the same as g  f

Composition: Graphical Representation The composition of two functions co- domain(g) a g(a) f(g(a)) (f  g)(a) domain(f)domain(g) g(a) rng(g)

Composition: Graphical Representation The composition of two functions A B a g(a) C f(g(a)) (f  g)(a)

Composition: Example 1  Let f, g be two functions on R  R defined by f(x) = 2x – 3 g(x) = x  What are f  g and g  f?  We note that  f is bijective, thus dom(f)=rng(f)= codomain(f)= R  For g, dom(g)= R but rng(g)={x  R | x  1}  R +  Since rng(g)={x  R | x  1}  R +  dom(f) =R, f  g is defined  Since rng(f)= R  dom(g) =R, g  f is defined

Composition: Example 1 (cont’)  Given f(x) = 2x – 3 and g(x) = x  (f  g)(x) = f(g(x)) = f(x 2 +1) = 2(x 2 +1)-3 = 2x  (g  f)(x) = g(f(x)) = g(2x-3) = (2x-3) 2 +1 = 4x x + 10

Function Equality  Although it is intuitive, we formally define what it means for two functions to be equal  Lemma: Two functions f and g are equal if and only  dom(f) = dom(g)   a  dom(f) (f(a) = g(a))

Associativity  The composition of function is not commutative (f  g  g  f), it is associative  Lemma: The composition of functions is an associative operation, that is (f  g)  h = f  (g  h)

Outline Definitions & terminology – function, domain, co-domain, image, preimage (antecedent), range, image of a set, strictly increasing, strictly decreasing, monotonic Properties – One-to-one (injective), onto (surjective), one-to-one correspondence (bijective) – Exercices (5) Inverse functions (examples) Operators – Composition, Equality Important functions – identity, absolute value, floor, ceiling, factorial

Important Functions: Identity  Definition: The identity function on a set A is the function  : A  A $\iota$ defined by  (a)=a for all a  A.  One can view the identity function as a composition of a function and its inverse:  (a) = (f  f -1 )(a) = (f -1  f)(a)  Moreover, the composition of any function f with the identity function is itself f: (f   )(a) = (   f)(a) = f(a)

Inverses and Identity  The identity function, along with the composition operation, gives us another characterization of inverses when a function has an inverse  Theorem: The functions f: A  B and g: B  A are inverses if and only if (g  f) =  A and (f  g) =  B where the  A and  B are the identity functions on sets A and B. That is,  a  A, b  B ( (g(f(a)) = a)  (f(g(b)) = b) )

Important Functions: Absolute Value  Definition: The absolute value function, denoted  x , f f: R  {y  R | y  0}. Its value is defined by x if x  0  x  = -x if x  0

Important Functions: Floor & Ceiling Definitions: – The floor function, denoted  x , is a function R  Z. Its values is the largest integer that is less than or equal to x – The ceiling function, denoted  x , is a function R  Z. Its values is the smallest integer that is greater than or equal to x In LaTex: $\lceil$, $\rceil$, $\rfloor$, $\lfloor$

Important Functions: Floor x y

Important Functions: Ceiling x

Important Function: Factorial  The factorial function gives us the number of permutations (that is, uniquely ordered arrangements) of a collection of n objects  Definition: The factorial function, denoted n , is a function N  N +. Its value is the product of the n positive integers n  =  i=1 i=n i = 1  2  3  (n-1)  n

Factorial Function & Stirling’s Approximation  The factorial function is defined on a discrete domain  In many applications, it is useful a continuous version of the function (say if we want to differentiate it)  To this end, we have the Stirling’s formula n  = SquareRoot(2  n) (n/e) n

Summary  Definitions & terminology  function, domain, co-domain, image, preimage (antecedent), range, image of a set, strictly increasing, strictly decreasing, monotonic  Properties  One-to-one (injective), onto (surjective), one-to-one correspondence (bijective)  Exercices (5)  Inverse functions (examples)  Operators  Composition, Equality  Important functions  identity, absolute value, floor, ceiling, factorial