SlideShare uma empresa Scribd logo
1 de 21
Baixar para ler offline
Relations, Functions, and Matrices




                     Mathematical
                     Structures for
                   Computer Science
                                Chapter 4




     Section 4.4 © 2006 W.H. Freeman & Co.
      Copyright                               MSCS Slides
   
          
                                                                 Functions   Functions
Tuesday, March 23, 2010
Functions
         ●     DEFINITIONS: TERMINOLOGY FOR FUNCTIONS
               Let S and T be sets. A function (mapping) f from S to T, f :
               S → T, is a subset of S × T, where each member of S
               appears exactly once as the first component of an ordered
               pair. S is the domain and T the codomain of the function.
               If (s,t) belongs to the function, then t is denoted by f(s); t is
               the image of s under f, s is a preimage of t under f, and f is
               said to map s to t. For A ⊆ S, f (A) denotes { f (a) ⏐ a ∈ A}.
         ●     There are three parts to a function:
                 A set of starting values
                   ■



                 A set from which associated values come
                   ■



                 The association itself
                   ■




     Section 4.4                              Functions                        2
Tuesday, March 23, 2010
Functions
         ●     The set of starting values is called the domain of the
               function.
         ●     The set from which associated values come is called
               the codomain of the function.
         ●     Here f is a function from S to T, symbolized f: S → T. S is
               the domain and T is the codomain. The association itself is
               a set of ordered pairs, each of the form (s,t) where s ∈ S, t
               ∈ T, and t is the value from T that the function associates
               with the value s from S; t = f (s).




     Section 4.4                             Functions                         3
Tuesday, March 23, 2010
Functions
         ●     A function from S to T is a subset of S × T with certain
               restrictions on the ordered pairs it contains.
                   ■
                       By the definition of a function, a binary relation that is one-to-
                       many (or many-to-many) cannot be a function.
                   ■
                       Each member of S must be used as a first component.
         ●     The definition of a function includes functions of more than one
               variable. We can have a function f : S1 × S2 × ... × Sn → T that
               associates with each ordered n-tuple of elements (s1, s2, ... , sn), si
               ∈ Si, a unique element of T.
         ●     The floor function ⎣x⎦ associates with each real number x the
               greatest integer less than or equal to x.
         ●     The ceiling function ⎡x⎤ associates with each real number x the
               smallest integer greater than or equal to x.
         ●     ⎣2.8⎦ = 2, ⎡2.8⎤ = 3, 4. Both the floor function and the ceiling
               function are functions from R to Z.

     Section 4.4                                       Functions                           4
Tuesday, March 23, 2010
Functions

         ●     For any integer x and any positive integer n, the modulo
               function, denoted by f (x) = x mod n, associates with x the
               remainder when x is divided by n. One can write x as x =
               qn + r, 0 ≤ r ≤ n, where q is the quotient and r is the
               remainder, so the value of x mod n is r.
         ●     Not all functional associations can be described by an
               equation. Technically, the equation only describes a way to
               compute associated values.
         ●     g: R → R, where g(x) = x3.
         ●     f : Z → R, given by f (x) = x3 is not the same function as g.
               The domain has been changed, which changes the set of
               ordered pairs.



     Section 4.4                             Functions                         5
Tuesday, March 23, 2010
Functions
         ●     DEFINITION: EQUAL FUNCTIONS
               Two functions are equal if they have the same
               domain, the same codomain, and the same association
               of values of the codomain with values of the domain.
         ●     To show that two functions with the same domain and
               the same codomain are equal, one must show that the
               associations are the same.
         ●     This can be done by showing that, given an arbitrary
               element of the domain, both functions produce the
               same associated value for that element; that is, they
               map it to the same place.



     Section 4.4                         Functions                     6
Tuesday, March 23, 2010
Onto Functions
         ●     DEFINITION: ONTO (SURJECTIVE) FUNCTION
               A function f: S → T is an onto, or surjective, function if
               the range of f equals the codomain of f.
         ●     In every function with range R and codomain T, R ⊆ T.
         ●     To prove that a given function is onto,
         ●     Show that T ⊆ R; then it will be true that R = T.
         ●     Show that an arbitrary member of the codomain is a
               member of the range.
         ●     g: R → R where g(x) = x3 is an onto function.




     Section 4.4                            Functions                       7
Tuesday, March 23, 2010
One-to-One Functions
         ●     DEFINITION: ONE-TO-ONE (INJECTIVE)
               FUNCTION A function f: S → T is one-to-one, or
               injective, if no member of T is the image under f of two
               distinct elements of S.
         ●     The one-to-one idea here is the same as for binary
               relations in general, except that every element of S
               must appear as a first component in an ordered pair.
         ●     To prove that a function is one-to-one, we assume that
               there are elements s1 and s2 of S with f (s1) = f (s2) and
               then show that s1 = s2.
         ●     The function g: R → R defined by g(x) = x3 is one-to-
               one because if x and y are real numbers with g(x) = g
               (y), then x3 = y3 and x = y.
     Section 4.4                            Functions                       8
Tuesday, March 23, 2010
Bijections
         ●     DEFINITION: BIJECTIVE FUNCTION
               A function f:S → T is bijective (a bijection) if it is both
               one-to-one and onto.
         ●     The function g: R → R given by g(x) = x3 is a bijection.




     Section 4.4                           Functions                    9
Tuesday, March 23, 2010
Composition of Functions
         ●     DEFINITION: COMPOSITION FUNCTION
               Let f: S → T and g: T → U. Then the composition function, g ° f,
               is a function from S to U defined by (g ° f )(s) = g( f (s)).
         ●     The function g ° f is applied right to left; function f is applied first
               and then function g.
         ●     Function composition preserves the properties of being onto and
               being one-to-one.
         ●     THEOREM ON COMPOSING TWO BIJECTIONS The
               composition of two bijections is a bijection.




     Section 4.4                                 Functions                          10
Tuesday, March 23, 2010
Inverse Functions
         ●     Let f: S T be a bijection. Because f is onto, every t ∈ T
               has a preimage in S. Because f is one-to-one, that preimage
               is unique.
         ●     The function that maps each element of a set S to itself,
               that is, that leaves each element of S unchanged, is called
               the identity function on S and denoted by iS.
         ●     DEFINITION: INVERSE FUNCTION Let f be a
               function, f: S → T. If there exists a function g: T → S such
               that g ° f = iS and f ° g = iT, then g is called the inverse
               function of f, denoted by f -1.
         ●     THEOREM ON BIJECTIONS AND INVERSE
               FUNCTIONS
               Let f: S T. Then f is a bijection if and only if f -1 exists.

     Section 4.4                             Functions                         11
Tuesday, March 23, 2010
Permutation Functions
         ●     DEFINITION: PERMUTATIONS OF A SET For a
               given set A, SA = { f ⏐ f: A → A and f is a bijection}.
               SA is thus the set of all bijections of set A into (and
               therefore onto) itself; such functions are called
               permutations of A.
         ●     If f and g both belong to SA, then they each have
               domain = range = A.
         ●     If A = {1, 2, 3, 4}, one permutation function of A, call
               it f, is given by f = {(1,2), (2,3), (3,1), (4,4)}.
         ●     A shorter way to describe the permutation f is to use
               cycle notation and write f = (1, 2, 3), understood to
               mean that f maps each element listed to the one on its
               right, the last element listed to the first, and an element
               of the domain not listed to itself.
     Section 4.4                           Functions                    12
Tuesday, March 23, 2010
Permutation Functions

         ●     If we were to compute f ° g (1, 2, 3) ° (2,3), we would
               get (1,2).
         ●     If, however, f and g are members of SA and f and g are
               disjoint cycles—the cycles have no elements in
               common—then f ° g = g ° f.
         ●     The permutation that maps each element of A to itself
               is the identity function on A, iA, also called the
               identity permutation.
         ●     A permutation on a set that maps no element to itself
               is called a derangement.




     Section 4.4                          Functions                    13
Tuesday, March 23, 2010
How Many Functions?
         ●         THEOREM ON THE NUMBER OF FUNCTIONS
                   WITH FINITE DOMAINS AND CODOMAINS
         	

       If ⏐S⏐ = m and ⏐T⏐ = n, then:
                   1.   The number of functions f: S → T is nm.
                   !    The number of one-to-one functions f: S → T, assuming m
                        > n, is n!/(n − m)!
                   !    The number of onto functions f: S → T, assuming m ≤ n, is
                        nm − C(n, 1)(n − 1)m + C(n, 2)(n − 2)m − C(n, 3)(n − 3)m
                         +...+ (−1)n − 1C(n, n − 1)(1)m


         ●         For example, let S = {A, B, C} and T = {a, b}. Find the
                   number of functions from S onto T.
         ●         23 − C(2, 1)(1)3 = 8 − 2 • 1 = 6

     Section 4.4                                  Functions                         14
Tuesday, March 23, 2010
How Many Functions?
         ●     If A is a set with ⏐A⏐= n, then the number of permutations
               of A is n!
         ●     This number can be obtained by any of three methods:
                   ■
                       A combinatorial argument (each of the n elements in the
                       domain must map to one of the n elements in the range with
                       no repetitions)
                   ■
                       Thinking of such functions as permutations on a set with n
                       elements and noting that P(n,n) = n!
                   ■
                       Using result (2) in the previous theorem with m = n




     Section 4.4                                  Functions                         15
Tuesday, March 23, 2010
Equivalent Sets
         ●     DEFINITIONS: EQUIVALENT SETS AND
               CARDINALITY
               A set S is equivalent to a set T if there exists a bijection f:
               S → T. Two sets that are equivalent have the same
               cardinality.
         ●     The notion of equivalent sets allows us to extend our
               definition of cardinality from finite to infinite sets.
         ●     If S is equivalent to T, then all the members of S and T
               are paired off by f in a one-to-one correspondence.
         ●     CANTOR’S THEOREM
               For any set S, S and ℘(S) are not equivalent.



     Section 4.4                              Functions                          16
Tuesday, March 23, 2010
Order of Magnitude of Functions

         ●     Order of magnitude is a way of comparing the “rate of
               growth” of different functions.
         ●     For instance, if we compute f (x) = x and g(x) = x2 for
               increasing values of x, the g-values will be larger than the
               f-values by an ever increasing amount.
         ●     This difference in the rate of increase cannot be overcome
               by simply multiplying the f-values by some large constant;
         ●     DEFINITION: ORDER OF MAGNITUDE
               Let f and g be functions mapping nonnegative reals into
               nonnegative reals. Then f is the same order of magnitude
               as g, written f=Θ(g), if there exist positive constants n0, c1,
               and c2 such that for x ≥ n0, c1 g(x) ≤ f (x) ≤ c2 g(x).



     Section 4.4                             Functions                       17
Tuesday, March 23, 2010
Order of Magnitude of Functions

         ●     For example, say f = Θ(x2) and g =Θ(x2). A
               polynomial is always the order of magnitude of its
               highest-degree term; lower-order terms and all
               coefficients can be ignored.
         ●     Order of magnitude is important in analysis of
               algorithms.
         ●     Usually the number of times such tasks must be done
               in executing the algorithm will depend on the size of
               the input.
         ●     Rather than compute the exact functions for the
               amount of work done, it is easier and often just as
               useful to settle for order-of-magnitude information.



     Section 4.4                          Functions                    18
Tuesday, March 23, 2010
Order of Magnitude of Functions




     Section 4.4                          Functions         19
Tuesday, March 23, 2010
Order of Magnitude of Functions

         ●     DEFINITION: BIG OH
               Let f and g be functions mapping nonnegative reals
               into nonnegative reals. Then f is big oh of g, written f
               = O(g), if there exist positive constants n0 and c such
               that for x ≥ n0, f (x) ≤ cg(x).
         ●     If f (n) represents the work done by an algorithm on an
               input of size n, it may be difficult to find a simple
               function g such that f = Θ(g).
         ●     We may still be able to find a function g that serves as
               an upper bound for f. In other words, while f may not
               have the same shape as g, f will never grow
               significantly faster than g.
               The big oh notation f = O(g) says that f grows at the
               same rate or at a slower rate than g.
     Section 4.4                          Functions                   20
Tuesday, March 23, 2010
Order of Magnitude of Functions

         ●     If we know that f definitely grows at a slower rate than
               g, then we can say something stronger.
         ●     This is the little oh of g, written f = o(g). The
               relationship between big oh and little oh is this: If f =
               O(g), then either f= Θ(g) or f = o(g).




     Section 4.4                          Functions                    21
Tuesday, March 23, 2010

Mais conteúdo relacionado

Mais procurados

Introduction to Fourier transform and signal analysis
Introduction to Fourier transform and signal analysisIntroduction to Fourier transform and signal analysis
Introduction to Fourier transform and signal analysis宗翰 謝
 
Basic Calculus 11 - Derivatives and Differentiation Rules
Basic Calculus 11 - Derivatives and Differentiation RulesBasic Calculus 11 - Derivatives and Differentiation Rules
Basic Calculus 11 - Derivatives and Differentiation RulesJuan Miguel Palero
 
DSP, Differences between Fourier series ,Fourier Transform and Z transform
DSP, Differences between  Fourier series ,Fourier Transform and Z transform DSP, Differences between  Fourier series ,Fourier Transform and Z transform
DSP, Differences between Fourier series ,Fourier Transform and Z transform Naresh Biloniya
 
Ml mle_bayes
Ml  mle_bayesMl  mle_bayes
Ml mle_bayesPhong Vo
 
Optics Fourier Transform Ii
Optics Fourier Transform IiOptics Fourier Transform Ii
Optics Fourier Transform Iidiarmseven
 
Multiplicative Interaction Models in R
Multiplicative Interaction Models in RMultiplicative Interaction Models in R
Multiplicative Interaction Models in Rhtstatistics
 
Intro probability 4
Intro probability 4Intro probability 4
Intro probability 4Phong Vo
 
From L to N: Nonlinear Predictors in Generalized Models
From L to N: Nonlinear Predictors in Generalized ModelsFrom L to N: Nonlinear Predictors in Generalized Models
From L to N: Nonlinear Predictors in Generalized Modelshtstatistics
 
Optics Fourier Transform I
Optics Fourier Transform IOptics Fourier Transform I
Optics Fourier Transform Idiarmseven
 
Dsp U Lec06 The Z Transform And Its Application
Dsp U   Lec06 The Z Transform And Its ApplicationDsp U   Lec06 The Z Transform And Its Application
Dsp U Lec06 The Z Transform And Its Applicationtaha25
 
Time Series Analysis
Time Series AnalysisTime Series Analysis
Time Series AnalysisAmit Ghosh
 
03 convexfunctions
03 convexfunctions03 convexfunctions
03 convexfunctionsSufyan Sahoo
 
Functional analysis in mechanics 2e
Functional analysis in mechanics  2eFunctional analysis in mechanics  2e
Functional analysis in mechanics 2eSpringer
 
Functional analysis in mechanics
Functional analysis in mechanicsFunctional analysis in mechanics
Functional analysis in mechanicsSpringer
 
Bachelor_Defense
Bachelor_DefenseBachelor_Defense
Bachelor_DefenseTeja Turk
 
Numerical analysis convexity, concavity
Numerical analysis  convexity, concavityNumerical analysis  convexity, concavity
Numerical analysis convexity, concavitySHAMJITH KM
 
Matrix Models of 2D String Theory in Non-trivial Backgrounds
Matrix Models of 2D String Theory in Non-trivial BackgroundsMatrix Models of 2D String Theory in Non-trivial Backgrounds
Matrix Models of 2D String Theory in Non-trivial BackgroundsUtrecht University
 
Derivatives and their Applications
Derivatives and their ApplicationsDerivatives and their Applications
Derivatives and their Applicationsusmancp2611
 

Mais procurados (20)

smtlecture.7
smtlecture.7smtlecture.7
smtlecture.7
 
Introduction to Fourier transform and signal analysis
Introduction to Fourier transform and signal analysisIntroduction to Fourier transform and signal analysis
Introduction to Fourier transform and signal analysis
 
Basic Calculus 11 - Derivatives and Differentiation Rules
Basic Calculus 11 - Derivatives and Differentiation RulesBasic Calculus 11 - Derivatives and Differentiation Rules
Basic Calculus 11 - Derivatives and Differentiation Rules
 
DSP, Differences between Fourier series ,Fourier Transform and Z transform
DSP, Differences between  Fourier series ,Fourier Transform and Z transform DSP, Differences between  Fourier series ,Fourier Transform and Z transform
DSP, Differences between Fourier series ,Fourier Transform and Z transform
 
Ml mle_bayes
Ml  mle_bayesMl  mle_bayes
Ml mle_bayes
 
Optics Fourier Transform Ii
Optics Fourier Transform IiOptics Fourier Transform Ii
Optics Fourier Transform Ii
 
Multiplicative Interaction Models in R
Multiplicative Interaction Models in RMultiplicative Interaction Models in R
Multiplicative Interaction Models in R
 
Intro probability 4
Intro probability 4Intro probability 4
Intro probability 4
 
From L to N: Nonlinear Predictors in Generalized Models
From L to N: Nonlinear Predictors in Generalized ModelsFrom L to N: Nonlinear Predictors in Generalized Models
From L to N: Nonlinear Predictors in Generalized Models
 
Optics Fourier Transform I
Optics Fourier Transform IOptics Fourier Transform I
Optics Fourier Transform I
 
Lesson 5: Continuity
Lesson 5: ContinuityLesson 5: Continuity
Lesson 5: Continuity
 
Dsp U Lec06 The Z Transform And Its Application
Dsp U   Lec06 The Z Transform And Its ApplicationDsp U   Lec06 The Z Transform And Its Application
Dsp U Lec06 The Z Transform And Its Application
 
Time Series Analysis
Time Series AnalysisTime Series Analysis
Time Series Analysis
 
03 convexfunctions
03 convexfunctions03 convexfunctions
03 convexfunctions
 
Functional analysis in mechanics 2e
Functional analysis in mechanics  2eFunctional analysis in mechanics  2e
Functional analysis in mechanics 2e
 
Functional analysis in mechanics
Functional analysis in mechanicsFunctional analysis in mechanics
Functional analysis in mechanics
 
Bachelor_Defense
Bachelor_DefenseBachelor_Defense
Bachelor_Defense
 
Numerical analysis convexity, concavity
Numerical analysis  convexity, concavityNumerical analysis  convexity, concavity
Numerical analysis convexity, concavity
 
Matrix Models of 2D String Theory in Non-trivial Backgrounds
Matrix Models of 2D String Theory in Non-trivial BackgroundsMatrix Models of 2D String Theory in Non-trivial Backgrounds
Matrix Models of 2D String Theory in Non-trivial Backgrounds
 
Derivatives and their Applications
Derivatives and their ApplicationsDerivatives and their Applications
Derivatives and their Applications
 

Semelhante a Cpsc125 Ch4 Sec4

Functions
FunctionsFunctions
FunctionsGaditek
 
function on mathematics
function on mathematicsfunction on mathematics
function on mathematicsAkashDas124
 
Function and Recursively defined function
Function and Recursively defined functionFunction and Recursively defined function
Function and Recursively defined functionNANDINI SHARMA
 
5.1 Defining and visualizing functions. A handout.
5.1 Defining and visualizing functions. A handout.5.1 Defining and visualizing functions. A handout.
5.1 Defining and visualizing functions. A handout.Jan Plaza
 
Functions and graphs
Functions and graphsFunctions and graphs
Functions and graphsSujata Tapare
 
functions
 functions  functions
functions Gaditek
 
4.1 Inverse Functions
4.1 Inverse Functions4.1 Inverse Functions
4.1 Inverse Functionssmiller5
 
4.1 Inverse Functions
4.1 Inverse Functions4.1 Inverse Functions
4.1 Inverse Functionssmiller5
 
Vector differentiation, the ∇ operator,
Vector differentiation, the ∇ operator,Vector differentiation, the ∇ operator,
Vector differentiation, the ∇ operator,Tarun Gehlot
 
5.1 Defining and visualizing functions. Dynamic slides.
5.1 Defining and visualizing functions. Dynamic slides.5.1 Defining and visualizing functions. Dynamic slides.
5.1 Defining and visualizing functions. Dynamic slides.Jan Plaza
 
Domain-and-Range-of-a-Function
Domain-and-Range-of-a-FunctionDomain-and-Range-of-a-Function
Domain-and-Range-of-a-FunctionEmeraldAcaba
 
Composition and inverse of functions
Composition  and inverse of functionsComposition  and inverse of functions
Composition and inverse of functionsCharliez Jane Soriano
 
Function and Relation.pdf
Function and Relation.pdfFunction and Relation.pdf
Function and Relation.pdfAngelaClarito1
 
5.6 Function inverse. A handout.
5.6 Function inverse. A handout.5.6 Function inverse. A handout.
5.6 Function inverse. A handout.Jan Plaza
 
New Method for Finding an Optimal Solution of Generalized Fuzzy Transportatio...
New Method for Finding an Optimal Solution of Generalized Fuzzy Transportatio...New Method for Finding an Optimal Solution of Generalized Fuzzy Transportatio...
New Method for Finding an Optimal Solution of Generalized Fuzzy Transportatio...BRNSS Publication Hub
 

Semelhante a Cpsc125 Ch4 Sec4 (20)

Functions
FunctionsFunctions
Functions
 
function on mathematics
function on mathematicsfunction on mathematics
function on mathematics
 
Function and Recursively defined function
Function and Recursively defined functionFunction and Recursively defined function
Function and Recursively defined function
 
5.1 Defining and visualizing functions. A handout.
5.1 Defining and visualizing functions. A handout.5.1 Defining and visualizing functions. A handout.
5.1 Defining and visualizing functions. A handout.
 
Functions and graphs
Functions and graphsFunctions and graphs
Functions and graphs
 
Inverse function
Inverse function Inverse function
Inverse function
 
functions
 functions  functions
functions
 
Functional programming java
Functional programming javaFunctional programming java
Functional programming java
 
Introductory calculus
Introductory calculusIntroductory calculus
Introductory calculus
 
4.1 Inverse Functions
4.1 Inverse Functions4.1 Inverse Functions
4.1 Inverse Functions
 
7 functions
7   functions7   functions
7 functions
 
4.1 Inverse Functions
4.1 Inverse Functions4.1 Inverse Functions
4.1 Inverse Functions
 
Vector differentiation, the ∇ operator,
Vector differentiation, the ∇ operator,Vector differentiation, the ∇ operator,
Vector differentiation, the ∇ operator,
 
5.1 Defining and visualizing functions. Dynamic slides.
5.1 Defining and visualizing functions. Dynamic slides.5.1 Defining and visualizing functions. Dynamic slides.
5.1 Defining and visualizing functions. Dynamic slides.
 
Domain-and-Range-of-a-Function
Domain-and-Range-of-a-FunctionDomain-and-Range-of-a-Function
Domain-and-Range-of-a-Function
 
Calc 5.3
Calc 5.3Calc 5.3
Calc 5.3
 
Composition and inverse of functions
Composition  and inverse of functionsComposition  and inverse of functions
Composition and inverse of functions
 
Function and Relation.pdf
Function and Relation.pdfFunction and Relation.pdf
Function and Relation.pdf
 
5.6 Function inverse. A handout.
5.6 Function inverse. A handout.5.6 Function inverse. A handout.
5.6 Function inverse. A handout.
 
New Method for Finding an Optimal Solution of Generalized Fuzzy Transportatio...
New Method for Finding an Optimal Solution of Generalized Fuzzy Transportatio...New Method for Finding an Optimal Solution of Generalized Fuzzy Transportatio...
New Method for Finding an Optimal Solution of Generalized Fuzzy Transportatio...
 

Mais de David Wood

Internet of Things (IoT) two-factor authentication using blockchain
Internet of Things (IoT) two-factor authentication using blockchainInternet of Things (IoT) two-factor authentication using blockchain
Internet of Things (IoT) two-factor authentication using blockchainDavid Wood
 
Returning to Online Privacy?
Returning to Online Privacy?Returning to Online Privacy?
Returning to Online Privacy?David Wood
 
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...David Wood
 
BlockSW 2019 Keynote
BlockSW 2019 KeynoteBlockSW 2019 Keynote
BlockSW 2019 KeynoteDavid Wood
 
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221David Wood
 
Privacy in the Smart City
Privacy in the Smart CityPrivacy in the Smart City
Privacy in the Smart CityDavid Wood
 
Controlling Complexities in Software Development
Controlling Complexities in Software DevelopmentControlling Complexities in Software Development
Controlling Complexities in Software DevelopmentDavid Wood
 
Privacy Concerns related to Verifiable Claims
Privacy Concerns related to Verifiable ClaimsPrivacy Concerns related to Verifiable Claims
Privacy Concerns related to Verifiable ClaimsDavid Wood
 
Implementing the Verifiable Claims data model
Implementing the Verifiable Claims data modelImplementing the Verifiable Claims data model
Implementing the Verifiable Claims data modelDavid Wood
 
So You Wanna be a Startup CTO 20170301
So You Wanna be a Startup CTO 20170301So You Wanna be a Startup CTO 20170301
So You Wanna be a Startup CTO 20170301David Wood
 
Functional manipulations of large data graphs 20160601
Functional manipulations of large data graphs 20160601Functional manipulations of large data graphs 20160601
Functional manipulations of large data graphs 20160601David Wood
 
When Metaphors Kill
When Metaphors KillWhen Metaphors Kill
When Metaphors KillDavid Wood
 
Secularism in Australia
Secularism in AustraliaSecularism in Australia
Secularism in AustraliaDavid Wood
 
Meditations on Writing in Paradoxes, Oxymorons, and Pleonasms
Meditations on Writing in Paradoxes, Oxymorons, and PleonasmsMeditations on Writing in Paradoxes, Oxymorons, and Pleonasms
Meditations on Writing in Paradoxes, Oxymorons, and PleonasmsDavid Wood
 
Building a writer's platform with social media
Building a writer's platform with social mediaBuilding a writer's platform with social media
Building a writer's platform with social mediaDavid Wood
 
Summary of the Hero's Journey
Summary of the Hero's JourneySummary of the Hero's Journey
Summary of the Hero's JourneyDavid Wood
 
Open by Default
Open by DefaultOpen by Default
Open by DefaultDavid Wood
 
Lod Then, Now and Next 20110926
Lod Then, Now and Next 20110926Lod Then, Now and Next 20110926
Lod Then, Now and Next 20110926David Wood
 
Linked Data ROI 20110426
Linked Data ROI 20110426Linked Data ROI 20110426
Linked Data ROI 20110426David Wood
 
Introduction to Linked Data: RDF Vocabularies
Introduction to Linked Data: RDF VocabulariesIntroduction to Linked Data: RDF Vocabularies
Introduction to Linked Data: RDF VocabulariesDavid Wood
 

Mais de David Wood (20)

Internet of Things (IoT) two-factor authentication using blockchain
Internet of Things (IoT) two-factor authentication using blockchainInternet of Things (IoT) two-factor authentication using blockchain
Internet of Things (IoT) two-factor authentication using blockchain
 
Returning to Online Privacy?
Returning to Online Privacy?Returning to Online Privacy?
Returning to Online Privacy?
 
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...
 
BlockSW 2019 Keynote
BlockSW 2019 KeynoteBlockSW 2019 Keynote
BlockSW 2019 Keynote
 
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221
 
Privacy in the Smart City
Privacy in the Smart CityPrivacy in the Smart City
Privacy in the Smart City
 
Controlling Complexities in Software Development
Controlling Complexities in Software DevelopmentControlling Complexities in Software Development
Controlling Complexities in Software Development
 
Privacy Concerns related to Verifiable Claims
Privacy Concerns related to Verifiable ClaimsPrivacy Concerns related to Verifiable Claims
Privacy Concerns related to Verifiable Claims
 
Implementing the Verifiable Claims data model
Implementing the Verifiable Claims data modelImplementing the Verifiable Claims data model
Implementing the Verifiable Claims data model
 
So You Wanna be a Startup CTO 20170301
So You Wanna be a Startup CTO 20170301So You Wanna be a Startup CTO 20170301
So You Wanna be a Startup CTO 20170301
 
Functional manipulations of large data graphs 20160601
Functional manipulations of large data graphs 20160601Functional manipulations of large data graphs 20160601
Functional manipulations of large data graphs 20160601
 
When Metaphors Kill
When Metaphors KillWhen Metaphors Kill
When Metaphors Kill
 
Secularism in Australia
Secularism in AustraliaSecularism in Australia
Secularism in Australia
 
Meditations on Writing in Paradoxes, Oxymorons, and Pleonasms
Meditations on Writing in Paradoxes, Oxymorons, and PleonasmsMeditations on Writing in Paradoxes, Oxymorons, and Pleonasms
Meditations on Writing in Paradoxes, Oxymorons, and Pleonasms
 
Building a writer's platform with social media
Building a writer's platform with social mediaBuilding a writer's platform with social media
Building a writer's platform with social media
 
Summary of the Hero's Journey
Summary of the Hero's JourneySummary of the Hero's Journey
Summary of the Hero's Journey
 
Open by Default
Open by DefaultOpen by Default
Open by Default
 
Lod Then, Now and Next 20110926
Lod Then, Now and Next 20110926Lod Then, Now and Next 20110926
Lod Then, Now and Next 20110926
 
Linked Data ROI 20110426
Linked Data ROI 20110426Linked Data ROI 20110426
Linked Data ROI 20110426
 
Introduction to Linked Data: RDF Vocabularies
Introduction to Linked Data: RDF VocabulariesIntroduction to Linked Data: RDF Vocabularies
Introduction to Linked Data: RDF Vocabularies
 

Cpsc125 Ch4 Sec4

  • 1. Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Section 4.4 © 2006 W.H. Freeman & Co. Copyright MSCS Slides Functions Functions Tuesday, March 23, 2010
  • 2. Functions ● DEFINITIONS: TERMINOLOGY FOR FUNCTIONS Let S and T be sets. A function (mapping) f from S to T, f : S → T, is a subset of S × T, where each member of S appears exactly once as the first component of an ordered pair. S is the domain and T the codomain of the function. If (s,t) belongs to the function, then t is denoted by f(s); t is the image of s under f, s is a preimage of t under f, and f is said to map s to t. For A ⊆ S, f (A) denotes { f (a) ⏐ a ∈ A}. ● There are three parts to a function: A set of starting values ■ A set from which associated values come ■ The association itself ■ Section 4.4 Functions 2 Tuesday, March 23, 2010
  • 3. Functions ● The set of starting values is called the domain of the function. ● The set from which associated values come is called the codomain of the function. ● Here f is a function from S to T, symbolized f: S → T. S is the domain and T is the codomain. The association itself is a set of ordered pairs, each of the form (s,t) where s ∈ S, t ∈ T, and t is the value from T that the function associates with the value s from S; t = f (s). Section 4.4 Functions 3 Tuesday, March 23, 2010
  • 4. Functions ● A function from S to T is a subset of S × T with certain restrictions on the ordered pairs it contains. ■ By the definition of a function, a binary relation that is one-to- many (or many-to-many) cannot be a function. ■ Each member of S must be used as a first component. ● The definition of a function includes functions of more than one variable. We can have a function f : S1 × S2 × ... × Sn → T that associates with each ordered n-tuple of elements (s1, s2, ... , sn), si ∈ Si, a unique element of T. ● The floor function ⎣x⎦ associates with each real number x the greatest integer less than or equal to x. ● The ceiling function ⎡x⎤ associates with each real number x the smallest integer greater than or equal to x. ● ⎣2.8⎦ = 2, ⎡2.8⎤ = 3, 4. Both the floor function and the ceiling function are functions from R to Z. Section 4.4 Functions 4 Tuesday, March 23, 2010
  • 5. Functions ● For any integer x and any positive integer n, the modulo function, denoted by f (x) = x mod n, associates with x the remainder when x is divided by n. One can write x as x = qn + r, 0 ≤ r ≤ n, where q is the quotient and r is the remainder, so the value of x mod n is r. ● Not all functional associations can be described by an equation. Technically, the equation only describes a way to compute associated values. ● g: R → R, where g(x) = x3. ● f : Z → R, given by f (x) = x3 is not the same function as g. The domain has been changed, which changes the set of ordered pairs. Section 4.4 Functions 5 Tuesday, March 23, 2010
  • 6. Functions ● DEFINITION: EQUAL FUNCTIONS Two functions are equal if they have the same domain, the same codomain, and the same association of values of the codomain with values of the domain. ● To show that two functions with the same domain and the same codomain are equal, one must show that the associations are the same. ● This can be done by showing that, given an arbitrary element of the domain, both functions produce the same associated value for that element; that is, they map it to the same place. Section 4.4 Functions 6 Tuesday, March 23, 2010
  • 7. Onto Functions ● DEFINITION: ONTO (SURJECTIVE) FUNCTION A function f: S → T is an onto, or surjective, function if the range of f equals the codomain of f. ● In every function with range R and codomain T, R ⊆ T. ● To prove that a given function is onto, ● Show that T ⊆ R; then it will be true that R = T. ● Show that an arbitrary member of the codomain is a member of the range. ● g: R → R where g(x) = x3 is an onto function. Section 4.4 Functions 7 Tuesday, March 23, 2010
  • 8. One-to-One Functions ● DEFINITION: ONE-TO-ONE (INJECTIVE) FUNCTION A function f: S → T is one-to-one, or injective, if no member of T is the image under f of two distinct elements of S. ● The one-to-one idea here is the same as for binary relations in general, except that every element of S must appear as a first component in an ordered pair. ● To prove that a function is one-to-one, we assume that there are elements s1 and s2 of S with f (s1) = f (s2) and then show that s1 = s2. ● The function g: R → R defined by g(x) = x3 is one-to- one because if x and y are real numbers with g(x) = g (y), then x3 = y3 and x = y. Section 4.4 Functions 8 Tuesday, March 23, 2010
  • 9. Bijections ● DEFINITION: BIJECTIVE FUNCTION A function f:S → T is bijective (a bijection) if it is both one-to-one and onto. ● The function g: R → R given by g(x) = x3 is a bijection. Section 4.4 Functions 9 Tuesday, March 23, 2010
  • 10. Composition of Functions ● DEFINITION: COMPOSITION FUNCTION Let f: S → T and g: T → U. Then the composition function, g ° f, is a function from S to U defined by (g ° f )(s) = g( f (s)). ● The function g ° f is applied right to left; function f is applied first and then function g. ● Function composition preserves the properties of being onto and being one-to-one. ● THEOREM ON COMPOSING TWO BIJECTIONS The composition of two bijections is a bijection. Section 4.4 Functions 10 Tuesday, March 23, 2010
  • 11. Inverse Functions ● Let f: S T be a bijection. Because f is onto, every t ∈ T has a preimage in S. Because f is one-to-one, that preimage is unique. ● The function that maps each element of a set S to itself, that is, that leaves each element of S unchanged, is called the identity function on S and denoted by iS. ● DEFINITION: INVERSE FUNCTION Let f be a function, f: S → T. If there exists a function g: T → S such that g ° f = iS and f ° g = iT, then g is called the inverse function of f, denoted by f -1. ● THEOREM ON BIJECTIONS AND INVERSE FUNCTIONS Let f: S T. Then f is a bijection if and only if f -1 exists. Section 4.4 Functions 11 Tuesday, March 23, 2010
  • 12. Permutation Functions ● DEFINITION: PERMUTATIONS OF A SET For a given set A, SA = { f ⏐ f: A → A and f is a bijection}. SA is thus the set of all bijections of set A into (and therefore onto) itself; such functions are called permutations of A. ● If f and g both belong to SA, then they each have domain = range = A. ● If A = {1, 2, 3, 4}, one permutation function of A, call it f, is given by f = {(1,2), (2,3), (3,1), (4,4)}. ● A shorter way to describe the permutation f is to use cycle notation and write f = (1, 2, 3), understood to mean that f maps each element listed to the one on its right, the last element listed to the first, and an element of the domain not listed to itself. Section 4.4 Functions 12 Tuesday, March 23, 2010
  • 13. Permutation Functions ● If we were to compute f ° g (1, 2, 3) ° (2,3), we would get (1,2). ● If, however, f and g are members of SA and f and g are disjoint cycles—the cycles have no elements in common—then f ° g = g ° f. ● The permutation that maps each element of A to itself is the identity function on A, iA, also called the identity permutation. ● A permutation on a set that maps no element to itself is called a derangement. Section 4.4 Functions 13 Tuesday, March 23, 2010
  • 14. How Many Functions? ● THEOREM ON THE NUMBER OF FUNCTIONS WITH FINITE DOMAINS AND CODOMAINS If ⏐S⏐ = m and ⏐T⏐ = n, then: 1. The number of functions f: S → T is nm. ! The number of one-to-one functions f: S → T, assuming m > n, is n!/(n − m)! ! The number of onto functions f: S → T, assuming m ≤ n, is nm − C(n, 1)(n − 1)m + C(n, 2)(n − 2)m − C(n, 3)(n − 3)m +...+ (−1)n − 1C(n, n − 1)(1)m ● For example, let S = {A, B, C} and T = {a, b}. Find the number of functions from S onto T. ● 23 − C(2, 1)(1)3 = 8 − 2 • 1 = 6 Section 4.4 Functions 14 Tuesday, March 23, 2010
  • 15. How Many Functions? ● If A is a set with ⏐A⏐= n, then the number of permutations of A is n! ● This number can be obtained by any of three methods: ■ A combinatorial argument (each of the n elements in the domain must map to one of the n elements in the range with no repetitions) ■ Thinking of such functions as permutations on a set with n elements and noting that P(n,n) = n! ■ Using result (2) in the previous theorem with m = n Section 4.4 Functions 15 Tuesday, March 23, 2010
  • 16. Equivalent Sets ● DEFINITIONS: EQUIVALENT SETS AND CARDINALITY A set S is equivalent to a set T if there exists a bijection f: S → T. Two sets that are equivalent have the same cardinality. ● The notion of equivalent sets allows us to extend our definition of cardinality from finite to infinite sets. ● If S is equivalent to T, then all the members of S and T are paired off by f in a one-to-one correspondence. ● CANTOR’S THEOREM For any set S, S and ℘(S) are not equivalent. Section 4.4 Functions 16 Tuesday, March 23, 2010
  • 17. Order of Magnitude of Functions ● Order of magnitude is a way of comparing the “rate of growth” of different functions. ● For instance, if we compute f (x) = x and g(x) = x2 for increasing values of x, the g-values will be larger than the f-values by an ever increasing amount. ● This difference in the rate of increase cannot be overcome by simply multiplying the f-values by some large constant; ● DEFINITION: ORDER OF MAGNITUDE Let f and g be functions mapping nonnegative reals into nonnegative reals. Then f is the same order of magnitude as g, written f=Θ(g), if there exist positive constants n0, c1, and c2 such that for x ≥ n0, c1 g(x) ≤ f (x) ≤ c2 g(x). Section 4.4 Functions 17 Tuesday, March 23, 2010
  • 18. Order of Magnitude of Functions ● For example, say f = Θ(x2) and g =Θ(x2). A polynomial is always the order of magnitude of its highest-degree term; lower-order terms and all coefficients can be ignored. ● Order of magnitude is important in analysis of algorithms. ● Usually the number of times such tasks must be done in executing the algorithm will depend on the size of the input. ● Rather than compute the exact functions for the amount of work done, it is easier and often just as useful to settle for order-of-magnitude information. Section 4.4 Functions 18 Tuesday, March 23, 2010
  • 19. Order of Magnitude of Functions Section 4.4 Functions 19 Tuesday, March 23, 2010
  • 20. Order of Magnitude of Functions ● DEFINITION: BIG OH Let f and g be functions mapping nonnegative reals into nonnegative reals. Then f is big oh of g, written f = O(g), if there exist positive constants n0 and c such that for x ≥ n0, f (x) ≤ cg(x). ● If f (n) represents the work done by an algorithm on an input of size n, it may be difficult to find a simple function g such that f = Θ(g). ● We may still be able to find a function g that serves as an upper bound for f. In other words, while f may not have the same shape as g, f will never grow significantly faster than g. The big oh notation f = O(g) says that f grows at the same rate or at a slower rate than g. Section 4.4 Functions 20 Tuesday, March 23, 2010
  • 21. Order of Magnitude of Functions ● If we know that f definitely grows at a slower rate than g, then we can say something stronger. ● This is the little oh of g, written f = o(g). The relationship between big oh and little oh is this: If f = O(g), then either f= Θ(g) or f = o(g). Section 4.4 Functions 21 Tuesday, March 23, 2010