1 / 20

Discussion #29 Functions

Discussion #29 Functions. Topics. Function Definition Notation Partial Functions Restrictions Overloading Composition Injections, surjections, bijections Inverses. 1. α. 2. β. 3. γ. Function Definition. A function is a special kind of binary relation.

ismet
Download Presentation

Discussion #29 Functions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Discussion #29Functions

  2. Topics • Function Definition • Notation • Partial Functions • Restrictions • Overloading • Composition • Injections, surjections, bijections • Inverses

  3. 1 α 2 β 3 γ Function Definition • A function is a special kind of binary relation. • A binary relation f  A  B is a function if for each a  A there is a unique b  B y x

  4. 1 α 2 β 3 γ NOT Functions f = {(1, α), (2, β)} “For each” violated y Some x’s do not have corresponding y’s x

  5. 1 α 2 β 3 γ NOT Functions f = {(1, α), (2, β), (3, β), (3, γ)} uniqueness violated for 3  appears twice y Uniqueness violated for some x’s x

  6. <1,1> α <1,2> β <1,3> γ Functionswith N-Dimensional Domains An (n+1)-ary relation f  A1  A2  …  An  B is a function if for each < a1, a2, …, an>  A1  A2  …  Anthere is a unique b  B.

  7. Notation for Functions • We can use various notation for functions: for f = {(1, α),(2, β),(3, β)} • In the notation, x is the argument or preimage and y is the image. We can also have the image of a set of arguments. • For functions with n-ary domains, use <x0, x1, …, xn> in place of x.

  8. Function Domain and Range • f : A → B • A is the domain space • same as the domain (since all elements participate) • dom f, dom(f), or domain(f) • B is the range space • may or may not be the same as the range, which is: • {y | x(y=f(x))} • All rhs values in pairs (all that get “hit”) • Bf • ran f, ran(f), range(f) • f : D1  D2  …  Dn→ Z • f : Dn→ Z (when all domains are the same)

  9. <1,1> <1,1> <1,1> α α α <1,2> <1,2> <1,2> β β β <1,3> <1,3> <1,3> γ γ γ Partial Functions Remove the requirement that each a  A must participate. Retain the uniqueness requirement. Partial Function: Partial Function: (A Total Function is also a Partial Function.) NOT a Partial Function: f = {(<1,2>, β),(<1,3>, β),(<1,3>, γ)} <1,3> not unique

  10. Special Functions • Identity Function • IA : A → A • IA = {(x, x) | x A} • Constant Function • C : A → B • C = {(x, c) | x A  c B } • Often A and B are the same • C : A → A • C= {(x, c) | x A c A}

  11. Restrictions It is common to restrict the domain space of partial functions to be the actual domain. • log(x) is partial for R → R but total for R>0→ R • For “number of pregnancies” we may restrict the domain to mothers • Sometimes we restrict for other reasons, e.g. mothers over 40 John 1 Mary 2 Sue Ken 3 John 1 Mary 2 Sue Ken 3

  12. Overloading • Overloading is like overloading in Java. • The same name can be used for different functions depending on the domain. • Examples a – b • Means number subtraction if a and b are numbers • Means set subtraction if a and b are sets a + b • Implemented differently for integers and reals • Could potentially be overridden and implemented by a programmer for very long integers

  13. Composition of Functions • Composition is written “°” • Range space of f = domain space of g g 1 α a f 2 β b 3 4 c

  14. Injection Injection: “one-to-one” or “1-1” • xy(f(x) = f(y)  x = y) • For f : A → B, the elements in B are “hit” at most once Injective NOT Injective a a 1 1 b b 2 2 c c d d 3 3 y y x x

  15. Surjection Surjection: “onto” • yx(y = f(x)) • For f : A → B, the elements in B are all “hit” at least once Surjective NOT Surjective a a 1 1 2 2 b b 3 3 c c 4 4 y y { not “hit” x x

  16. Bijection NOT Surjective NOT injective Bijection: “one-to-one and onto” or “1-1 correspondence” • xy(f(x) = f(y)  x = y)  yx(y = f(x)) • For f : A → B, every B element is “hit” once and only once Bijective NOT Bijective a a 1 1 2 2 b b 3 3 c c 4 y y x x

  17. Notes on Bijection • |A| = |B| • An “extra” B cannot be “hit” (not a surjection) • An “extra” A requires that at least one B must be “hit” twice (not an injection) • If f is a bijection, swapping the elements of the ordered pairs is a function • Called the inverse • Denoted f-1 • Is also a bijection • f-1(f(x)) is the identity function, i.e. f-1(f(x)) = x.

  18. Notes on Bijection (continued …) • The inverse of an injection is a partial function. If f : A →B is an injection, then f-1 is a partial function f f-1 a 1 1 a b b 2 2 c c d 3 3 d • Restricting the range space of an injective function to the range yields a bijection • Remove b

  19. Which is bigger? N or R[0..1]? Assume |N| = |R[0..1]|, then there exists a bijection: 1 0.34234… 2 0.34987… diagonalization 3 0.00040… But now there exists a number in R[0..1] such that d1 = not 3, d2 = not 4, d3 = not 0, … . Hence, not surjective and thus not bijective.

  20. Which is bigger? N or Z? { x odd: (x+1)/−2 x even: x/2 y negative: −2x−1 y positive: 2x f(x) = x y 0 0 1 −1 2 1 3 −2 4 2 { g(y) = Since g = f−1, there is a bijection from N to Z and thus |N| = |Z|. Countable if same cardinality as some subset of N. Alternatively, a set S is countable if there exists an injective function from S to N.

More Related