Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 Functions

2 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 c  C, denoted f( d ) = c.  d  D  c  C ( f( d ) = c   c’  D ( f( d ) = c’  c = c’ ) )  d  D  !c  C f( d ) = c. If f is a function from D to C, we write f : D  C. Functions are also known as: Mappings Transformations. Functions pass the vertical line test.

3 Copyright © Peter Cappello3 Definition A function is a subset of a Cartesian product: If f : D  C then f  D x C. If f : D  C then: D is f’s domain C is f’s codomain. If f( d ) = c then: c is the image of d d is a pre-image of c. f’s range is { c |  d f( d ) = c }.

4 Copyright © Peter Cappello4 Example Let f : Z  N be f( x ) = x 2. What is f’s domain? What is f’s codomain? What is the image of 4? What is the pre-image of 4? What is f’s range?

5 Copyright © Peter Cappello5 When are functions equal? Let f 1 : D  C and f 2 : D  C. Since –A function is a subset of a Cartesian product. –A Cartesian product is a set. when does f 1 = f 2 ?

6 Copyright © Peter Cappello6 Declaring a function’s domain & codomain The Java statement long square( int x ) { … } The domain of square is? Its codomain is?

7 Copyright © Peter Cappello7 Let f : D  C and S  D. The image of S under f, denoted f( S ) is { c |  s  S, f( s ) = c }. If S is finite, is | S | | f( S ) | ? Let f : N  N, f( n ) = n mod 5. –What is f’s range? –Let O = { n  N | n is odd }. –What is f( O ) ?

8 Copyright © Peter Cappello8 One-to-One (Injective) Functions Let f : D  C. f is one-to-one (injective) when different domain elements have different images:  a  D  b  D ( a  b  f (a )  f( b ) ). Example –Let n: { T, F }  { T, F }, such that n( p ) =  p. –Is n injective? Is f : Z  Z, f( z ) = z 2 injective? Injective functions pass the horizontal line test.

9 Copyright © Peter Cappello9 Onto (Surjective) Functions Let f : D  C. f is onto (surjective) when f’s range equals its codomain:  c  C  d  D ( f( d ) = c ). Example –Let or : { T, F }  { T, F }  { T, F }, such that or( p, q ) = p  q. –Is or surjective? Is f : Z  Z, f( z ) = z 2 surjective? Is f : Z  Z, f( z ) = z mod 5 surjective?

10 Copyright © Peter Cappello10 One-to-One Correspondence (Bijection) Function f is a one-to-one correspondence (bijection) when it is both: –one-to-one (injective) –onto (surjective). Let f : R  R, f( x ) = 2x – 7. Is f a bijection? Let f : D  C be a bijection, where D, C are finite. –Can |D| > |C|? –Can |D| < |C|?

11 Copyright © Peter Cappello11 Inverse Functions Let g : D  C be a bijection. The inverse function of g, denoted g -1, is the function : C  D such that if g( d ) = c, then g -1 ( c ) = d. If g is bijective, g -1 is a function because g is: – onto:  c  C ( c is the image of some element in D ) –1-to-1:  c  C (c is the image of at most 1 element in D ) –Diagram this. If g : D  C is not a bijection, does g -1 exist? Always? Sometimes? Never?

12 Copyright © Peter Cappello12 Composition of Functions Let functions g : B  C and f : A  B. The composition of g and f, denoted g  f, is defined by g  f( a ) = g( f( a ) ). a g(f ( a )) f( a ) AB C

13 Copyright © Peter Cappello13 Example Let f : Q  Q, f( x ) = 2x + 1. Let g : Q  Q, g( x ) = (x – 1)/2. What is (g  f )( 17 )? In general, what is g -1  g ( x ) ?

14 Copyright © Peter Cappello14 Exercise Let S  U. The characteristic function f S : U  { 0, 1 } is such that x  S  f S ( x ) = 1 x  S  f S ( x ) = 0. Show that: f A  B (x) = f A ( x )f B ( x ) f A  B (x) = f A ( x ) + f B ( x ) - f A  B ( x ) 1 2 3 4 AB

15 Copyright © Peter Cappello 201115 End of Lecture

16 Copyright © Peter Cappello 201116 The Java statement long square( int x ) { … } square’s domain is int; its codomain is long. Let f & g be functions from A to R. (f + g)( x ) = f( x ) + g( x ), ( fg )( x ) = f( x )g( x ). Let f( x ) = x 2 and g( x ) = x – x 2. What is f + g? gf?

17 Copyright © Peter Cappello 201117 Graphs of Functions Let f : A  B. The graph of f = { (a, b) | a  A and f( a ) = b }. Example: Let the domain of f be N. Draw: f( x ) = x 2 f( x ) = x mod 2.


Download ppt "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."

Similar presentations


Ads by Google