Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 15 Functions CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.

Similar presentations


Presentation on theme: "Lecture 15 Functions CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine."— Presentation transcript:

1 Lecture 15 Functions CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine

2 CSCI 1900 Lecture Lecture Introduction Reading –Rosen - Section 2.3 Definition of a function Representation of a function Composition Special types of functions Theorems on functions

3 CSCI 1900 Lecture Review: Dom and Ran of a Relation Given R - a relation from the set A to the set B, then –Domain of R - Dom(R) Subset of A containing elements that are related to some element in B –Range of R - Ran(R) Subset of B containing all second elements of the pairs defining R The same definitions apply to functions

4 CSCI 1900 Lecture Functions A function f is a relation from A to B –f : A → B –Each element of A in the domain of f maps to at most one element in B –Alternatively f (a) = b If an element a is not in the domain of f, – f (a) is undefined –Written as f (a) = 

5 CSCI 1900 Lecture Functions (cont) Functions are also called mappings or transformations –View as rules that assign an element of A to one element of B Elements of A Elements of B

6 CSCI 1900 Lecture Functions (cont) Because f is a relation, it too is a subset of the Cartesian Product A  B Even though there might be multiple sequence pairs that have the same element b, no two sequence pairs may have the same first element a

7 CSCI 1900 Lecture Functions Represented by Formulae It may be possible to represent a function with a formula –Example: f (x) = x 2 (mapping from Z to N) A function is not necessarily represented with a formula –Because a function is a relation It is therefore just a subset of the Cartesian product It may be that a function is represented only as a set of ordered pairs

8 CSCI 1900 Lecture Functions Without Formulae Example: A mapping from one finite set to another –A = { b, c, d, e} and B = {4, 6} –f (a) = {(b, 4), (c, 6), (d, 6), (e, 4)} Example: Membership function –f (a) return 0 if a is even, 1 otherwise –A = Z B = {0,1}

9 CSCI 1900 Lecture Identity Function The identity function is a function on A –Denoted 1 A –Defined by 1 A (a) = a

10 CSCI 1900 Lecture Composition If f : A → B and g : B → C, then the composition of f and g, (written as g  f ), is a function Let a  Dom(g  f). –(g  f )( a ) = g( f ( a ) ) –Because f( a ) maps to exactly one element, say b  B g( f (a ) ) = g( b ) –Because g( b ) maps to exactly one element, say c  C g( f (a) ) = c –Thus for each a  A, (g  f )(a) maps to exactly one element of C –Therefore: g  f is a function

11 CSCI 1900 Lecture Composition A=B=C=Z, f : A → B, and g : B → C f (a) = a+1, g(b)=2b Ex: g  f (3)= g( f(3) ) = g( 4)= 8 g  f(a)= g( f(a) ) = g( a+1) = 2(a+1) =2a +2 A B C f g g  f

12 CSCI 1900 Lecture Special Types of Functions f : A → B is “everywhere defined ” if –Dom(f ) = A f : A → B is “onto” if –Ran(f ) = B f : A → B is “one-to-one” if –It is impossible to have f (a) = f (a') if a  a ' i.e., if f (a) = f (a'), then a = a' f : A → B is “invertible” if –Its inverse, f -1, is also a function (Note, f -1 is simply the reversing of the ordered pairs)

13 CSCI 1900 Lecture Onto Functions If Ran(f)=B, then f is onto a b c d a b c d 5 OntoNOT Onto

14 CSCI 1900 Lecture One-to-One Functions f : A → B is one to one if no two elements of A map to the same element in B –If f(a)=f(b) implies a=b, then f is one to one –If f(a)=f(b) and a  b, then f is not one to one One to One NOT One to One a b c d e a b c d e

15 CSCI 1900 Lecture Bijection If f : A → B is one to one and onto, then f has one to one correspondence between the domain and the range or is bijective a b c d

16 CSCI 1900 Lecture Theorem of Functions If f is –Everywhere defined –One-to-one, –Onto then f is a one-to-one correspondence between A & B Thus f is invertible and f -1 is a one-to-one correspondence between B & A

17 CSCI 1900 Lecture More Theorems of Functions Let f be any function: 1 B  f = f f  1 A = f If f is a one-to-one correspondence between A and B, then f -1  f = 1 A f  f -1 = 1 B

18 CSCI 1900 Lecture More Theorems of Functions (cont) Let f : A → B and g : B → C Further let f and g be invertible (g  f) is invertible (g  f) -1 = (f -1  g -1 )

19 CSCI 1900 Lecture Key Concepts Summary Definition of a function Representation of a function Composition Special types of functions Theorems on functions Reading for next lecture –Kolman - Section 5.2, 5.3


Download ppt "Lecture 15 Functions CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine."

Similar presentations


Ads by Google