Presentation is loading. Please wait.

Presentation is loading. Please wait.

Functions Goals Introduce the concept of function

Similar presentations


Presentation on theme: "Functions Goals Introduce the concept of function"— Presentation transcript:

1 Functions Goals Introduce the concept of function
Introduce injective, surjective, & bijective functions

2 Copyright © Peter Cappello
Definition Let D & C be nonempty sets. A function f from D to C assigns elements of D to elements of C such that For each d  D, f assigns d to exactly 1 element c  C, denoted f( d ) = c. Equivalently d  D c  C ( f( d ) = c  c’  C ( f( d ) = c’  c = c’ ) ) d  D !c  C f( d ) = c. Copyright © Peter Cappello

3 Copyright © Peter Cappello
If f is a function from D to C, we write f : D  C. Functions also are known as: Mappings - View f as a set of (key, value) pairs { (k, v) | k  D  v = f(k) } Transformations. Functions pass the vertical line test. Copyright © Peter Cappello

4 Copyright © Peter Cappello
Definition A function is a subset of a Cartesian product: If f : D  C then f  D x C (see previous slide) 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  C | d f( d ) = c }. Copyright © Peter Cappello

5 Copyright © Peter Cappello
Example Let f : Z  N be f( x ) = x2. 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? Copyright © Peter Cappello

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

7 When are functions equal?
Let f1: D  C & f2: D  C. Since A function is a subset of a Cartesian product. A Cartesian product is a set. when does f1 = f2 ? Copyright © Peter Cappello

8 Copyright © Peter Cappello
The Image of a Set Let f : D  C and S  D. The image of S under f, denoted f( S ) is { c  C | s  S, f( s ) = c }. If S is finite, can | S | be <, =, or > | 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 ) ? Copyright © Peter Cappello

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

10 Onto (Surjective) Functions
Let f : D  C. f is onto (surjective) when c  C d  D ( f ( d ) = c ). f’s range equals its codomain. 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 ) = z2 surjective? Is f : Z  Z, f( z ) = z mod 5 surjective? Is f : Z  { 0, 1, 2, 3, 4}, f( z ) = z mod 5 surjective? Copyright © Peter Cappello

11 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|? Copyright © Peter Cappello

12 Copyright © Peter Cappello
Inverse Functions Let g : D  C be a bijection. The inverse function of g, denoted g-1, is the map: 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 (as a function)? Always? Sometimes? Never? Copyright © Peter Cappello

13 Composition of Functions
Let functions f : B  C & g: A  B. The composition of f & g, denoted f  g, is defined as f  g( a ) = f( g( a ) ), for a  A a f(g( a )) g( a ) A B C g f Copyright © Peter Cappello

14 Copyright © Peter Cappello
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 ) ? Copyright © Peter Cappello

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

16 Copyright © Peter Cappello 2011
End of Lecture Copyright © Peter Cappello 2011

17 Copyright © Peter Cappello 2011
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 ) = x2 and g( x ) = x – x2. What is f + g? gf? Copyright © Peter Cappello 2011

18 Copyright © Peter Cappello 2011
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 ) = x2 f( x ) = x mod 2. Copyright © Peter Cappello 2011


Download ppt "Functions Goals Introduce the concept of function"

Similar presentations


Ads by Google