functions - research.engineering.wustl.edubaruah/teaching/2018-2fa/lecs/... · functions given a...
TRANSCRIPT
©2019McGraw-HillEducation
Functions
Givenafunctionf:A→B:• WesayfmapsAtoBorfisamappingfromAtoB.
• Aiscalledthedomainoff.
• Biscalledthecodomainoff.
• Iff(a)=b,• thenbiscalledtheimageofaunderf.
• aiscalledthepreimageofb.
• TherangeoffisthesetofallimagesofpointsinAunderf.Wedenoteitbyf(A).
• Twofunctionsareequalwhentheyhavethesamedomain,thesamecodomainandmapeachelementofthedomaintothesameelementofthecodomain.
©2019McGraw-HillEducation
Questions
f(a)=? z
Theimageofdis? z
Thedomainoffis? A
Thecodomainoffis? B
Thepreimageofyis? b
f(A)=? {y,z}–thisistherangeoff
Thepreimage(s)ofzis(are)? {a,c,d}
©2019McGraw-HillEducation
RepresentingFunctions
Functionsmaybespecifiedindifferentways
• Anexplicitstatementoftheassignment
Exampleonpreviousslide
• Aformula
( ) 1f x x= +
• Acomputerprogram
• AJavaprogramthatwhengivenanintegern,producesthenthFibonacciNumber
©2019McGraw-HillEducation
Injections
Definition:Afunctionfissaidtobeone-to-one,orinjective,ifandonlyiff(a)=f(b)impliesthata=bforallaandbinthedomainoff.Afunctionissaidtobeaninjectionifitisone-to-one.
©2019McGraw-HillEducation
Surjections
Definition:AfunctionffromAtoBiscalledontoorsurjective,ifandonlyifforevery b B∈thereisanelement a A∈ with ( ) .f a b=Afunctionfiscalledasurjectionifitisonto.
©2019McGraw-HillEducation
Showingthatfisone-to-oneoronto1
Supposethatf:A→B.
ToshowthatfisinjectiveShowthatiff(x)=f(y)forarbitraryx,y∈A,thenx=y.
ToshowthatfisnotinjectiveFindparticularelementsx,y∈Asuchthatx≠yandf(x)=f(y).
ToshowthatfissurjectiveConsideranarbitraryelementy∈Bandfindanelementx∈Asuchthatf(x)=y.
ToshowthatfisnotsurjectiveFindaparticulary∈Bsuchthatf(x)≠yforallx∈A.
©2019McGraw-HillEducation
Bijections
Definition:Afunctionfisaone-to-onecorrespondence,orabijection,ifitisbothone-to-oneandonto(surjectiveandinjective).
©2019McGraw-HillEducation
InverseFunctions1
Definition:LetfbeabijectionfromAtoB.Thentheinverseoff,denoted 1,f − isthefunctionfromBtoAdefinedas ( ) ( )1 iff f y x f x y− = =
Noinverseexistsunlessfisabijection.(Why?)
©2019McGraw-HillEducation
Questions1
Example1:Letfbethefunctionfrom{a,b,c}to{1,2,3}suchthatf(a)=2,f(b)=3,andf(c)=1.Isfinvertibleandifsowhatisitsinverse?
Solution:Thefunctionfisinvertiblebecauseitisaone-to-onecorrespondence.Theinversefunctionf−1reversesthecorrespondencegivenbyf,sof−1(1)=c,f−1(2)=a,andf−1(3)=b.
©2019McGraw-HillEducation
Questions2
Example2:Letf:Z→Zbesuchthatf(x)=x+1.Isfinvertible,andifso,whatisitsinverse?
Solution:Thefunctionfisinvertiblebecauseitisaone-to-onecorrespondence.Theinversefunctionf−1reversesthecorrespondencesof−1(y)=y−1.
©2019McGraw-HillEducation
Questions3
Example3:Letf:R→Rbesuchthat( ) 2f x x=
Isfinvertible,andifso,whatisitsinverse?
Solution:Thefunctionfisnotinvertiblebecauseitneitherone-to-onenoronto.
©2019McGraw-HillEducation
Composition1
Definition:Letf:B→C,g:A→B.Thecompositionoffwithg,denoted f go isthefunctionfromAtoCdefinedby
( ) ( )( )f g x f g x=o
©2019McGraw-HillEducation
Composition2
©2019McGraw-HillEducation
Composition3
Example1:If
( ) ( )
( )( ) ( )
( )( )
2
2
2
and 2 1,then
2 1
and
2 1
f x x g x x
f g x x
g f x x
= = +
= +
= +
©2019McGraw-HillEducation
CompositionQuestions1
Example2:Letgbethefunctionfromtheset{a,b,c}toitselfsuchthatg(a)=b,g(b)=c,andg(c)=a.Letfbethefunctionfromtheset{a,b,c}totheset{1,2,3}suchthatf(a)=3,f(b)=2,andf(c)=1.Whatisthecompositionoffandg,andwhatisthecompositionofgandf?Solution:Thecompositionf∘gisdefinedby
( ) ( )( ) ( )( ) ( )( ) ( )( ) ( )( ) ( )
2.
1.
3.
g
g
f g a f a f b
f g b f b f c
f g c f ag c f
= = =
= = =
= = =
o
o
o
Thecompositiong∘fisnotdefined,becausetherangeoffisnotasubsetofthedomainofg.
©2019McGraw-HillEducation
GraphsofFunctionsLetfbeafunctionfromthesetAtothesetB.Thegraphofthefunctionfisthesetoforderedpairs( ) ( ){ }, and .|a b a A f a b∈ =
Graphoff(n)=2n+1fromZtoZ
Graphoff(x)=x2fromZtoZ
©2019McGraw-HillEducation
SomeImportantFunctions
Thefloorfunction,denoted
( )f x x= ⎣ ⎦
isthelargestintegerlessthanorequaltox.Theceilingfunction,denoted
( )f x x= ⎡ ⎤
isthesmallestintegergreaterthanorequaltoxExample: 3.5 3.5
1.5 1.5
⎡ ⎤ = 4 ⎣ ⎦ = 3
⎡− ⎤ = −1 ⎣− ⎦ = −2
©2019McGraw-HillEducation
FloorandCeilingFunctions2TABLE1UsefulPropertiesoftheFloorandCeilingFunctions.(nisaninteger,xisarealnumber)( )( )( )( )
1a if and only if 1
1b if and only if 1
1c if and only if 1
1d if and only if 1
x n n x n
x n n x n
x n x n x
x n x n x
⎣ ⎦ = = < +
⎡ ⎤ = − < =
⎣ ⎦ = − < =
⎡ ⎤ = = < +
( )2 1 1x x x x x− ⎣ ⎦ ≤ ≤ ⎡ ⎤ +< <
( )( )3a
3b
x x
x x
⎣− ⎦ = − ⎡ ⎤
⎡− ⎤ = − ⎣ ⎦
( )( )4a
4b
x n x n
x n x n
⎣ + ⎦ = ⎣ ⎦ +
⎡ + ⎤ = ⎡ ⎤ +
©2019McGraw-HillEducation
ProvingPropertiesofFunctions
Example:TrueorFalse?Ifxisarealnumber,then(Page159) ⌊2x⌋=⌊x⌋+⌊x+1/2⌋
Solution:Letx=n+ε,wherenisanintegerand0≤ε<1.Case1:ε<½• 2x=2n+2εand⌊2x⌋=2n,since0≤2ε<1.• ⌊x+1/2⌋=n,sincex+½=n+(1/2+ε)and0≤½+ε<1.• Hence,⌊2x⌋=2nand⌊x⌋+⌊x+1/2⌋=n+n=2n.
Case2:ε≥½• 2x=2n+2ε=(2n+1)+(2ε−1)and⌊2x⌋=2n+1,since0≤2ε−1<1.• ⌊x+1/2⌋=⌊n+(1/2+ε)⌋=⌊n+1+(ε–1/2)⌋=n+1since0≤ε−
1/2<1.• Hence,⌊2x⌋=2n+1and⌊x⌋+⌊x+1/2⌋=n+(n+1)=2n+1.
©2019McGraw-HillEducation
ProvingPropertiesofFunctions
Example:Proveordisprove:(Example32,p160) ⌊x+y⌋=⌊x⌋+⌊y⌋forallrealnumbersxandy
©2019McGraw-HillEducation
FactorialFunction
Definition:f:N→Z+,denotedbyf(n)=n!istheproductofthefirstnpositiveintegerswhennisanonnegativeinteger.
( ) ( ) ( ) 1 2 –1 , 0 0! 1f nn n f= ⋅ ⋅ ⋅ ⋅ ⋅ = =
Examples:( )( )( )( )
1 1! 1 2 2! 1 2 2 6 6! 1 2 3 4 5 6 720 20 2,432,902,008,176,640,000.
ffff
= =
= = ⋅ =
= = ⋅ ⋅ ⋅ ⋅ ⋅ =
=
Stirling’sApproximation: n!∼ 2πn n / e( )
n
f n( ) ∼ g n( ) ! limn →∞f n( ) / g n( ) =1
©2019McGraw-HillEducation
Sequences
• Definition¬ation
• Arithmeticprogressions
• Geometricprogressions
• Recurrencerelations
• TheFibonaccisequence
• Closedformofarecurrencerelation
• Summationsofsequences
©2019McGraw-HillEducation
Introduction
Sequencesareorderedlistsofelements.
• 1,2,3,5,8
• 1,3,9,27,81,…….
Sequencesarisethroughoutmathematics,computerscience,andinmanyotherdisciplines,rangingfrombotanytomusic.
Wewillintroducetheterminologytorepresentsequencesandsumsofthetermsinthesequences.
©2019McGraw-HillEducation
Sequences1
Definition:Asequenceisafunctionfromasubsetoftheintegers(usuallyeithertheset{0,1,2,3,4,…..}or{1,2,3,4,….})toasetS.
Thenotationanisusedtodenotetheimageoftheintegern.Wecanthinkofanastheequivalentoff(n)wherefisafunctionfrom{0,1,2,…..}toS.
Wecallanaterm(often,thenthterm)ofthesequence.
©2019McGraw-HillEducation
Sequences2
Example:Considerthesequence{an}where
{ } { }1 2 31 , , ...
1 1 11, , ,2 3 4
n na a a a an
= =
©2019McGraw-HillEducation
ArithmeticProgression
Definition:Anarithmeticprogressionisasequenceoftheform: , , 2 ,..., ,...a a d a d a nd+ + +wheretheinitialtermaandthecommondifferencedarerealnumbers.
{ } { } { }
{ } { } { }
{ } { } { }
0 1 2 3 4
0 1 2 3 4
0 1 2 3 4
1. Let 1and 4 :, , , , ,... 1, 1, 1, 1, 1,...
2. Let 7and 3 :, , , , ,... 7, 4, 1, 2, 5,...
3. Let 1and 2 :, , , , ,... 1, 3, 5, 7, 9,...
n
n
n
a ds s s s s sa d
t t t t t ta d
u u u u u u
= − =
= = − −
= = −
= = − −
= =
= =
Examples :Discreteversionofthelinearfunctionf(x)=a+dx
©2019McGraw-HillEducation
GeometricProgression
Definition:Ageometricprogressionisasequenceoftheform: 2, , , ,na ar ar… …wheretheinitialtermaandthecommonratiorarerealnumbers.
{ } { } { }
{ } { } { }
{ } { }
0 1 2 3 4
0 1 2 3 4
0 1 2 3 4
1. Let 1and 1. Then :, , , , ,... 1, 1, 1, 1, 1,...
2. Let 2and 5. Then :, , , , ,... 2, 10, 50, 250, 1250,...
3. Let 6and 1/ 3. Then :2 2 2, , , , ,... 6, 2, , , ,...3 9 27
n
n
n
a rb b b b b ba r
c c c c c ca r
d d d d d d
= = −
= = − −
= =
= =
= =
⎧ ⎫= = ⎨ ⎬⎩
Examples :
⎭
Discreteversionoftheexponentialfunctionf(x)=adx
©2019McGraw-HillEducation
RecurrenceRelations
Definition:Arecurrencerelationforthesequence{an}isanequationthatexpressesanintermsofoneormoreoftheprevioustermsofthesequence,namely,a0,a1,…,an−1,forallintegersnwithn≥n0,wheren0isanonnegativeinteger.
Asequenceiscalledasolutionofarecurrencerelationifitstermssatisfytherecurrencerelation.
Theinitialconditionsforasequencespecifythetermsthatprecedethefirsttermwheretherecurrencerelationtakeseffect.
©2019McGraw-HillEducation
FibonacciSequence
Definition:DefinetheFibonaccisequence,f0,f1,f2,…,by:• InitialConditions:f0=0,f1=1• RecurrenceRelation:fn=fn−1+fn−2Example:Findf2,f3,f4,f5andf6.
2 1 0
3 2 1
4 3 2
5 4 3
6 5 4
1 0 1, 1 1 2,
2 1 3,3 2 5,5 3 8.
f f ff f ff f ff f ff f f
= + = + =
= + = + =
= + = + =
= + = + =
= + = + =
Answer :