functions note

Upload: lai-tuan

Post on 14-Apr-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/30/2019 Functions Note

    1/31

    1

    Functions

  • 7/30/2019 Functions Note

    2/31

    2

    On to Functions

    From calculus, you are familiar with the

    concept of a real-valued functionf,

    which assigns to each numberxRa

    particular valuey=f(x), whereyR.But, the notion of a function can also be

    naturally generalized to the concept of

    assigning elements ofany set to elementsofany set.

  • 7/30/2019 Functions Note

    3/31

    3

    Function: Formal Definition

    For any setsA,B, we say that afunction f

    from (or mapping) A to B (f:AB) is aparticular assignment of exactly one

    elementf(x)B to each elementxA.Some further generalizations of this idea:

    Apartial(non-total) functionfassignszero or

    one elements ofB to each elementxA.Functions ofn arguments; relations (ch. 6).

  • 7/30/2019 Functions Note

    4/31

    4

    Graphical Representations

    Functions can be represented graphically in

    several ways:

    AB

    a b

    f

    f

    x

    y

    PlotBipartite Graph

    Like Venn diagrams

    A B

  • 7/30/2019 Functions Note

    5/31

    5

    Functions Weve Seen So Far

    Aproposition can be viewed as a function

    from situations to truth values {T,F}

    A logic system calledsituation theory.

    p=It is raining.;s=our situation here,now

    p(s){T,F}.

    Apropositional operatorcan be viewed asa function from ordered pairs of truth

    values to truth values: ((F,T)) = T.

  • 7/30/2019 Functions Note

    6/31

    6

    More functions so far

    Apredicate can be viewed as a function

    from objects topropositions (or truth

    values): P: is 7 feet tall;

    P(Mike) = Mike is 7 feet tall. = False.A bit string B of length n can be viewed as a

    function from the numbers {1,,n}

    (bitpositions) to the bits {0,1}.E.g., B=101 B(3)=1.

  • 7/30/2019 Functions Note

    7/317

    Aset Sover universe Ucan be viewed as a

    function from the elements ofUto

    {T, F}, saying for each element ofU

    whether it is in S. S={3}; S(0)=F, S(3)=T.Aset operatorsuch as ,, can be

    viewed as a function from pairs of sets

    to sets.Example: (({1,3},{3,4})) = {3}

    Still More Functions

  • 7/30/2019 Functions Note

    8/318

    A Neat Trick

    Sometimes we write YXto denote the setFofallpossible functionsf:XY.

    This notation is especially appropriate,because for finiteX, Y, |F| = |Y||X|.

    If we use representations F0, T1,2

    :

    {0

    ,1

    }={F

    ,T

    }, then a subset T

    Sis just afunction from Sto 2, so the power set ofS(set of all such fns.) is 2S in this notation.

  • 7/30/2019 Functions Note

    9/319

    Some Function Terminology

    Iff:AB, andf(a)=b (where aA & bB),then:

    A is the domain off.

    B is the codomain off.

    b is the image ofa underf.

    a is apre-image ofb underf.

    In general, b may have more than 1 pre-image.The range RB offis {b | a f(a)=b }.

  • 7/30/2019 Functions Note

    10/3110

    Range versus Codomain

    The range of a function might notbe its

    whole codomain.

    The codomain is the set that the function is

    declaredto map all domain values into.

    The range is theparticularset of values in

    the codomain that the function actually

    maps elements of the domain to.

  • 7/30/2019 Functions Note

    11/3111

    Range vs. Codomain - Example

    Suppose I declare to you that: fis a

    function mapping students in this class to

    the set of grades {A,B,C,D,E}.

    At this point, you knowfs codomain is:

    __________, and its range is ________.

    Suppose the grades turn out all As and Bs.

    Then the range offis _________, but its

    codomain is __________________.

  • 7/30/2019 Functions Note

    12/3112

    Operators (general definition)

    An n-ary operatorover the set Sis any

    function from the set of ordered n-tuples of

    elements ofS, to Sitself.

    E.g., ifS={T,F}, can be seen as a unaryoperator, and , are binary operators on S.

    Another example: and are binaryoperators on the set of all sets.

  • 7/30/2019 Functions Note

    13/3113

    Constructing Function Operators

    If (dot) is any operator overB, then wecan extend to also denote an operator overfunctionsf:AB.

    E.g.: Given any binary operator:BBB,and functionsf,g:AB, we define(fg):AB to be the function defined by:

    aA, (fg)(a) =f(a)g(a).

  • 7/30/2019 Functions Note

    14/3114

    Function Operator Example

    , (plus,times) are binary operatorsoverR. (Normal addition & multiplication.)

    Therefore, we can also add and multiply

    functions f,g:RR:(fg):RR, where (fg)(x) =f(x) g(x)

    (fg):RR, where (fg)(x) =f(x) g(x)

  • 7/30/2019 Functions Note

    15/3115

    Function Composition Operator

    For functionsg:AB andf:BC, there is aspecial operator called compose ().

    It composes (creates) a new function out off,g

    by applyingfto the result ofg.(fg):AC, where (fg)(a) =f(g(a)).

    Noteg(a)B, sof(g(a)) is defined and C.

    Note that (like Cartesian , but unlike +,,)is non-commuting. (Generally,fggf.)

  • 7/30/2019 Functions Note

    16/3116

    Images of Sets under Functions

    Givenf:AB, and SA,

    The image ofSunderfis simply the set of

    all images (underf) of the elements ofS.

    f(S) : {f(s) |sS}: {b | sS:f(s)=b}.

    Note the range offcan be defined as simply

    the image (underf) offs domain!

  • 7/30/2019 Functions Note

    17/3117

    One-to-One Functions

    A function is one-to-one (1-1), orinjective, oran injection,

    iff every element of its range has only 1 pre-image.

    Formally: givenf:AB,

    x is injective : (x,y:xy f(x)f(y)).

    Only one element of the domain is mapped to any given

    one element of the range.

    Domain & range have same cardinality. What about codomain?

    Each element of the domain is injected into a differentelement of the range.

    Compare each dose of vaccine is injected into a different patient.

  • 7/30/2019 Functions Note

    18/3118

    One-to-One Illustration

    Bipartite (2-part) graph representations of

    functions that are (or not) one-to-one:

    One-to-one

    Not one-to-one

    Not even a

    function!

  • 7/30/2019 Functions Note

    19/3119

    Sufficient Conditions for 1-1ness

    For functionsfover numbers,

    fisstrictly (ormonotonically) increasingiff

    x>y f(x)>f(y) for allx,y in domain;

    fisstrictly (ormonotonically) decreasingiffx>y f(x)

  • 7/30/2019 Functions Note

    20/3120

    Onto (Surjective) Functions

    A functionf:AB is onto orsurjective orasurjection iff its range is equal to its

    codomain (bB, aA:f(a)=b).An onto function maps the setA onto (over,

    covering) the entirety of the setB, not just

    over a piece of it.E.g., for domain & codomain R, x3 is onto,

    whereasx2 isnt. (Why not?)

  • 7/30/2019 Functions Note

    21/3121

    Illustration of Onto

    Some functions that are or are not onto theircodomains:

    Onto

    (but not 1-1)

    Not Onto

    (or 1-1)

    Both 1-1

    and onto

    1-1 but

    not onto

  • 7/30/2019 Functions Note

    22/31

    22

    Bijections

    A functionfis a one-to-one correspondence,ora bijection, orreversible, orinvertible, iff

    it is both one-to-one and onto.

    For bijectionsf:AB, there exists aninverse of f, writtenf1:BA, which is theunique function such that

    (the identity function)

    Iff 1

  • 7/30/2019 Functions Note

    23/31

    23

    The Identity Function

    For any domainA, the identity functionI:AA (variously written,IA, 1, 1A) is theunique function such that aA:I(a)=a.

    Some identity functions youve seen:ing 0, ing by 1, ing with T, ing with F,

    ing with , ing with U.

    Note that the identity function is both one-

    to-one and onto (bijective).

  • 7/30/2019 Functions Note

    24/31

    24

    The identity function:

    Identity Function Illustrations

    Domain and range x

    y

  • 7/30/2019 Functions Note

    25/31

    25

    Graphs of Functions

    We can represent a functionf:AB as a setof ordered pairs {(a,f(a)) | aA}.

    Note that a, there is only 1 pair (a,f(a)).Later (ch.6): relations loosen this restriction.

    For functions over numbers, we can

    represent an ordered pair (x,y) as a point ona plane. A function is then drawn as a curve

    (set of points) with only oney for eachx.

  • 7/30/2019 Functions Note

    26/31

    26

    Comment About Representations

    You can represent any type of discretestructure (propositions, bit-strings, numbers,sets, ordered pairs, functions) in terms ofvirtually any of the other structures (or

    some combination thereof).Probably none of these structures is truly

    more fundamental than the others (whateverthat would mean). However, strings, logic,

    and sets are often used asthe foundation for all else. E.g. in

  • 7/30/2019 Functions Note

    27/31

    27

    A Couple of Key Functions

    In discrete math, we will frequently use thefollowing functions over real numbers:

    x (floor ofx) is the largest (most positive)

    integerx.x (ceiling ofx) is the smallest (most

    negative) integerx.

  • 7/30/2019 Functions Note

    28/31

    28

    Visualizing Floor & Ceiling

    Real numbers fall to their floor or rise totheir ceiling.

    Note that ifxZ,

    x x &x x

    Note that ifxZ,

    x = x =x.

    0

    1

    1

    2

    3

    2

    3

    ...

    .

    . .

    . . .

    1.6

    1.6=2

    1.4= 2

    1.4

    1.4= 1

    1.6=1

    3

    3=3= 3

  • 7/30/2019 Functions Note

    29/31

    29

    Plots with floor/ceiling

    Note that forf(x)=x, the graph offincludes thepoint (a, 0) for all values ofa such that a0 anda

  • 7/30/2019 Functions Note

    30/31

    30

    Plots with floor/ceiling: Example

    Plot of graph of functionf(x) = x/3:

    x

    f(x)

    Set of points (x,f(x))

    +3

    2

    +2

    3

  • 7/30/2019 Functions Note

    31/31

    Review of2.3 (Functions)

    Function variablesf,g, h,

    Notations:f:AB, f(a),f(A).

    Terms: image, preimage, domain, codomain,

    range, one-to-one, onto, strictly (in/de)creasing,bijective, inverse, composition.

    Function unary operatorf1,

    binary operators , , etc., and.

    The RZ functions x and x.