/
MCS320IntroductiontoSymbolicComputationSpring2007MapleLecture18.Symbol MCS320IntroductiontoSymbolicComputationSpring2007MapleLecture18.Symbol

MCS320IntroductiontoSymbolicComputationSpring2007MapleLecture18.Symbol - PDF document

giovanna-bartolotta
giovanna-bartolotta . @giovanna-bartolotta
Follow
401 views
Uploaded On 2015-11-09

MCS320IntroductiontoSymbolicComputationSpring2007MapleLecture18.Symbol - PPT Presentation

MCS320IntroductiontoSymbolicComputationSpring2007diffcosttdifferentiationoftheformulacostdiffcostwrongDcostalsowrongDcosdifferentiationofthecosinefunctionThefollowingi ID: 188383

MCS320IntroductiontoSymbolicComputationSpring2007[diff(cos(t) t);#differentiationoftheformulacos(t)[diff(cos t);#wrong![D(cos(t));#alsowrong[D(cos);#differentiationofthecosinefunctionThefollowingi

Share:

Link:

Embed:

Download Presentation from below link

Download Pdf The PPT/PDF document "MCS320IntroductiontoSymbolicComputationS..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

MCS320IntroductiontoSymbolicComputationSpring2007MapleLecture18.SymbolicandAutomaticDi®erentiationThedistinctionbetweenaformulaandafunctionisveryimportantinthislecture.Formulasaredi®erenti-atedsymbolically,whileautomaticdi®erentiation[1]producesderivativefunctions.Numericaldi®erentiationisnotconsideredhere.Thislecturecorrespondsto[2,Chapter9].18.1SymbolicDi®erentiationSymbolicdi®erentiationisthecalculationofthederivativeofaformula,verymuchaccordingtorulesyoulearnedincalculus.TheMaplecommandforsymbolicdi®erentiationisdi®,andits\inert"versionisDi®.�[expsin:=exp(sin(x));The\inert"versionofdi®,theDi®,simplyechoesthecommand,whiledi®executes:�[Diff(expsin,x)=diff(expsin,x);Wecancomputethesecond,third,fourth,...derivativeapplyingdi®repeatedly,butdoingthis25timesiscumbersome.Therefore,Maplehasthedollaroperator:�[x$10;#shortcuttobuildasequence�[diff(expsin,x$10);#herewehavethe10-thderivativeInmanyapplications,whatwewishtoderiveisnotde¯nedexplicitly,butimplicitlybyanequation.Torecallwhatimplicitdi®erentiationis,we¯rstdoitthelongwayontheequationofacirclex2+y2=1.Theequation\circle"relatesytox.We¯rsttellMapleweviewyasafunctionofx:�[alias(y=y(x)):�[circle:=x^2+y^2=1;Togetdi®(y,x),wedi®erentiatethede¯ningequation.Remember:thedi®erentiationofanequationisanequation!(Alsodonotforgetthatdiffusesaremembertable.)�[equ:=diff(circle,x);Nowweneedtosolveforthederivativeofywithrespecttox:�[solve(equ,diff(y,x));Theshortwaygoeslikethis:�[implicitdiff(x^2+z^2=1,z,x);#implicitdifferentiation�[implicitdiff(x^2+z^2=1,z,x$3);#3-rdderivative18.2AutomaticDi®erentiationAutomaticdi®erentiationisthecalculationofthederivativeofafunction;theresultisagainafunction.TheMaplecommandforautomaticdi®erentiationisD.Weneedautomaticdi®erentiationfortworeasons.First:noteveryfunctioncanberepresentedbyaniceformula.Second,evenifthereisaformula,wemayhavetodealwithhugeexpressionswellwhichrenderstheresultofsymbolicdi®erentiationverydi±culttouse.Firstweillustratethedi®erencebetweendi®andD,takingtheexampleexpsinfromabove:�[funexpsin:=unapply(expsin,x);�[derfunexpsin:=D(funexpsin);�[derfunexpsin(1.2);Forafunctionfinseveralvariables,D[2$3](f)givesthefunctionwhichreturnsthethirdderivativewithrespecttothesecondvariable.Itisinstructivetolookatthefollowingcommands:JanVerschelde,March2,2007UIC,DeptofMath,Stat&CSLecture18,page1 MCS320IntroductiontoSymbolicComputationSpring2007�[diff(cos(t),t);#differentiationoftheformulacos(t)�[diff(cos,t);#wrong!�[D(cos(t));#alsowrong�[D(cos);#differentiationofthecosinefunctionThefollowingillustratestheavoidanceofexpressionswellbyautomaticdi®erentiation:�[jf:=z�-z^2+1/4;#aquadraticmap�[f10:=jf@@10;#iteratethemaptentimesThef10isafunctionwhichappliesthemapÄjftentimes.Wecanseetherecipeforthisfunctionsymbolicallybyevaluatingatsomesymbolz:�[sf10:=f10(z);#symbolicformulaExpandingsf10reallyleadstoexpressionswell,sowedonotdothishere,butevendi®erentiationonlyonce,leadstoalargerexpression:�[dsf10:=diff(sf10,z);#symbolicdifferentiation�[fsdf10:=unapply(dsf10,z);#turnformulaintofunction�[fsdf10(0.3);#evaluatethederivativeIfweareonlyinterestedinthevalueofthederivative,thenwebetterapplyautomaticdi®erentiation:�[Df10:=D(f10);#automaticdifferentiation�[Df10(0.3);#evaluatethederivativeVerifytheresultsobtainedbyfsdf10(0.3)andDf10(0.3)andcomparethesizesoftheprocedures:�[eval(fsdf10);eval(Df10);#comparesizes18.3Assignments1.GivetheMaplecommandstogetthevalueofthe7-thderivativeofex10+2atx=1.Alsogivethevalueyouobtained.2.GivetheMaplecommand(s)tocompute@8f@5x@3yforf(x;y)=e2x+cos(y).3.Forf:=(x;y)!cos(xy),computethederivativefunctionwhichreturns@5f@2x@3y.4.Considerthecurvede¯nedbyf(x;y)=3+2x+y+2x2+2xy+3y2=0.Locallyonthecurvewecanviewyasafunctionofx,i.e.:y=y(x).Computeformulasforthe¯rstandsecondderivativeofywithrespecttox.5.Computethederivativeofthefunctionf(x)=min(x2+1;2x+3).ReferencesA.Griewank.EvaluatingDerivatives:PrinciplesandTechniquesofAlgorithmicDi®erentiation.SIAM,2000.[2]A.Heck.IntroductiontoMaple.Springer-Verlag,thirdedition,2003.JanVerschelde,March2,2007UIC,DeptofMath,Stat&CSLecture18,page2