DingyüXue DifferentialEquationSolutionswithMATLAB® Also of Interest Fractional-OrderControlSystems,FundamentalsandNumerical Implementations DingyüXue,2017 ISBN978-3-11-049999-5,e-ISBN(PDF)978-3-11-049797-7, e-ISBN(EPUB)978-3-11-049719-9 CalculusProblemSolutionswithMATLAB® DingyüXue,2020 ISBN978-3-11-066362-4,e-ISBN(PDF)978-3-11-066697-7, e-ISBN(EPUB)978-3-11-066375-4 MATLAB®Programming,MathematicalProblemSolutions DingyüXue,2020 ISBN978-3-11-066356-3,e-ISBN(PDF)978-3-11-066695-3, e-ISBN(EPUB)978-3-11-066370-9 LinearAlgebraandMatrixComputationswithMATLAB® DingyüXue,2020 ISBN978-3-11-066363-1,e-ISBN(PDF)978-3-11-066699-1, e-ISBN(EPUB)978-3-11-066371-6 SolvingOptimizationProblemswithMATLAB® DingyüXue,2020 ISBN978-3-11-066364-8,e-ISBN(PDF)978-3-11-066701-1, e-ISBN(EPUB)978-3-11-066369-3 Dingyü Xue Differential Equation Solutions ® with MATLAB | Author Prof.DingyüXue SchoolofInformationScienceandEngineering NortheasternUniversity WenhuaRoad3rdStreet 110819Shenyang China [email protected] MATLABandSimulinkareregisteredtrademarksofTheMathWorks,Inc.Seewww.mathworks.com/ trademarksforalistofadditionaltrademarks.TheMathWorksPublisherLogoidentifiesbooksthat containMATLABandSimulinkcontent.Usedwithpermission.TheMathWorksdoesnotwarrantthe accuracyofthetextorexercisesinthisbook.Thisbook’suseordiscussionofMATLABandSimulink softwareorrelatedproductsdoesnotconstituteendorsementorsponsorshipbyTheMathWorksof aparticularuseoftheMATLABandSimulinksoftwareorrelatedproducts.ForMATLAB®and Simulink®productinformation,orinformationonotherrelatedproducts,pleasecontact: TheMathWorks,Inc. 3AppleHillDrive Natick,MA,01760-2098USA Tel:508-647-700 Fax:508-647-7001 E-mail:[email protected] Web:www.mathworks.com ISBN978-3-11-067524-5 e-ISBN(PDF)978-3-11-067525-2 e-ISBN(EPUB)978-3-11-067531-3 LibraryofCongressControlNumber:2020931439 BibliographicinformationpublishedbytheDeutscheNationalbibliothek TheDeutscheNationalbibliothekliststhispublicationintheDeutscheNationalbibliografie; detailedbibliographicdataareavailableontheInternetathttp://dnb.dnb.de. ©2020TsinghuaUniversityPressLimitedandWalterdeGruyterGmbH,Berlin/Boston Coverimage:DingyüXue Typesetting:VTeXUAB,Lithuania Printingandbinding:CPIbooksGmbH,Leck www.degruyter.com Preface Scientificcomputingiscommonlyandinevitablyencounteredincourselearning,sci- entificresearchandengineeringpracticeforeachscientificandengineeringstudent andresearcher.Forthestudentsandresearchersinthedisciplineswhicharenotpure mathematics,itisusuallynotawisethingtolearnthoroughlylow-leveldetailsofre- latedmathematicalproblems,andalsoitisnotasimplethingtofindsolutionsofcom- plicatedproblemsbyhand.Itisaneffectivewaytotacklescientificproblems,with highefficiencyandin accurateand creativemanner,withthe mostadvancedcom- putertools.Thismethodisespeciallyusefulinsatisfyingtheneedsforthoseinthe areaofscienceandengineering. Theauthorhadmadesomeefforttowardsthisgoalbyaddressingdirectlytheso- lutionmethodsforvariousbranchesinmathematicsinasinglebook.Suchabook, entitled“MATLABbasedsolutionstoadvancedappliedmathematics”,waspublished firstin2004byTsinghuaUniversityPress.Severalneweditionswerepublishedafter- wards:in2015,thesecondeditioninEnglishbyCRCPress,andin2018,thefourth editioninChinesewerepublished.BasedonthelatestChineseedition,abrandnew MOOCprojectwasreleasedin2018,1 andreceivedsignificantattention.Thenumber ofregisteredstudentswasaround14000inthefirstroundoftheMOOCcourse,and reachedtensofthousandsinlaterrounds.Thetextbookhasbeencitedtensofthou- sandstimesbyjournalpapers,books,anddegreetheses. Theauthorhasover30yearsofextensiveexperienceofusingMATLABinscientific researchandeducation.Significantamountofmaterialsandfirst-handknowledgehas beenaccumulated,whichcannotbecoveredinasinglebook.Aseriesentitled“Profes- sorXueDingyü’sLectureHall”ofsuchworksarescheduledwithTsinghuaUniversity Press,andtheEnglisheditionsareincludedintheDGSTEMserieswithDeGruyter. Thesebooksareintendedtoprovidesystematic,extensiveanddeepexplorationsin scientificcomputingskillswiththeuseofMATLABandrelatedtools.Theauthorwants toexpresshissinceregratitudetohissupervisor,ProfessorDerekAthertonofSussex University,whofirstbroughthimintotheparadiseofMATLAB. TheMATLABseriesisnotasimplerevisionoftheexistingbooks.Withdecadesof experienceandmaterialaccumulation,theideaof“revisiting”isadoptedinauthor- ingtheseries,incontrasttoothermathematicsandotherMATLAB-richbooks.The viewpointofanengineeringprofessorisestablishedandthefocusinonsolvingvar- iousappliedmathematicalproblemswithtools.Manyinnovativeskillsandgeneral- purposesolversareprovidedtosolveproblemswithMATLAB,whichisnotpossible byanyotherexistingsolvers,soastobetterillustratetheapplicationsofcomputer toolsinsolvingmathematicalproblemsineverymathematicsbranch.Italsohelps thereadersbroadentheirviewpointsinsolvingscientificcomputing,andevenfind 1 MOOCaddress:https://www.icourse163.org/learn/NEU-1002660001 https://doi.org/10.1515/9783110675252-201 VI | Preface innovativesolutionsbythemselvestoscientificcomputingwhichcannotbesolvedby anyotherexistingmethods. ThefirsttitleintheMATLABseries,“MATLABProgramming”,canbeusedasan entry-level textbook or reference book to MATLAB programming, so as to establish asolidfoundationanddeepunderstandingfortheapplicationofMATLABinscien- tificcomputing.Eachsubsequentvolumetriestocoverabranchortopicinmathe- maticalcourses.Bearinginmindthe“computationalthinking”inauthoringthese- ries,deepunderstandingandexplorationsaremadeforeachmathematicsbranchin- volved.TheseMATLABbooksaresuitableforthereaderswhohavealreadylearntthe relatedmathematicalcourses,andrevisitthecoursestolearnhowtosolvetheprob- lemsbyusingcomputertools.Itcanalsobeusedasacompanioninsynchronizing thelearningofrelatedmathematicscourses,andviewingthecoursefromadifferent angle,sothatthereadersmayexpandtheirknowledgeinlearningtherelatedcourses, soastobetterlearn,understandandpracticethematerialsinthecourses. ThisbookisthefifthoneintheMATLABseriesandfullydevotedtothesolutions of various differential equations, with extensive use of MATLAB. The analytical so- lutionsofordinarydifferentialequationsarestudiedfirst,followedbynumericalso- lutionstoinitialvalueproblemsofvariousordinarydifferentialequations,including conventionalandspecialequations,delaydifferentialequations,andfractionaldif- ferentialequations.Somepropertyanalysistasksarealsocoveredinthisbook,and blockdiagram-basedpatternstovariousdifferentialequationsareaddressed.Discus- sionsarealsomadetothenumericalsolutionapproachestoboundaryvalueproblems andpartialdifferentialequations. Atthetimethebooksarepublished,theauthorwishestoexpresshissinceregrati- tudetohiswife,ProfessorYangJun.Herloveandselflesscareoverthedecadesprovide theauthorimmensepower,whichsupportstheauthors’academicresearch,teaching, andwriting. September2019 XueDingyü Contents Preface|V 1 Anintroductiontodifferentialequations|1 1.1 Introductiontodifferentialequationmodeling|1 1.1.1 Modelingofanelectriccircuit|1 1.1.2 Modelinginmechanicalsystems|3 1.1.3 Modelsinsocialsystems|4 1.2 Abriefhistoryofdifferentialequations|6 1.3 Outlineandmaintopicsinthebook|8 1.4 Exercises|10 2 Analyticalsolutionsofordinarydifferentialequations|11 2.1 Analyticalsolutionsoffirst-orderdifferentialequations|11 2.1.1 Differentialequationsolvablebysimpleintegrals|12 2.1.2 Homogeneousdifferentialequations|13 2.1.3 Inhomogeneouslineardifferentialequations|14 2.1.4 Nonlineardifferentialequationswithseparablevariables|15 2.2 Specialfunctionsandsecond-orderdifferentialequations|17 2.2.1 Gammafunction|17 2.2.2 Hypergeometricfunctions|19 2.2.3 Besseldifferentialequations|20 2.2.4 Legendredifferentialequationsandfunctions|22 2.2.5 Airyfunctions|23 2.3 Solutionsoflineardifferentialequationswithconstant coefficients|25 2.3.1 Mathematicalmodelingoflinearconstant-coefficientdifferential equations|25 2.3.2 Laplacetransform-basedsolutions|26 2.3.3 Solutionsofinhomogeneousdifferentialequations|28 2.3.4 Solutionsofdifferentialequationswithnonzeroinitialvalues|29 2.4 Analyticalsolutionsofordinarydifferentialequations|32 2.4.1 Analyticalsolutionsofsimpledifferentialequations|32 2.4.2 Analyticalsolutionsofhigh-orderlineardifferentialequationswith constantcoefficients|35 2.4.3 Analyticalsolutionsoflineartime-varyingdifferentialequations|38 2.4.4 Solutionsoftime-varyingdifferentialequationsets|40 2.4.5 Solutionsofboundaryvalueproblems|41 2.5 Solutionsoflinearmatrixdifferentialequations|42 2.5.1 Analyticalsolutionsoflinearstatespaceequations|43 2.5.2 Directsolutionsofstatespacemodels|45 VIII | Contents 2.5.3 SolutionofSylvesterdifferentialequation|46 2.5.4 Kroneckerproduct-basedsolutionsofSylvesterdifferential equations|47 2.6 Analyticalsolutionstospecialnonlineardifferentialequations|48 2.6.1 Solvablenonlineardifferentialequations|48 2.6.2 Nonlineardifferentialequationswhereanalyticalsolutionsarenot available|50 2.7 Exercises|51 3 Initialvalueproblems|55 3.1 Initialvaluedescriptionsforfirst-orderexplicitdifferential equations|55 3.1.1 Mathematicalformsofinitialvalueproblems|55 3.1.2 Existenceanduniquenessofsolutions|56 3.2 Implementationoffixed-stepnumericalalgorithms|57 3.2.1 Euler’smethod|57 3.2.2 Second-orderRunge–Kuttaalgorithm|60 3.2.3 Fourth-orderRunge–Kuttaalgorithm|62 3.2.4 Gill’salgorithm|64 3.2.5 ThemthorderRunge–Kuttaalgorithm|65 3.2.6 Multistepalgorithmsandimplementation|68 3.3 Variable-stepnumericalalgorithmsandimplementations|70 3.3.1 Measurestoincreaseefficiency|71 3.3.2 Anintroductiontovariable-stepalgorithms|72 3.3.3 The4/5thorderRunge–Kuttavariable-stepalgorithm|73 3.3.4 ThedifferentialequationsolverprovidedinMATLAB|74 3.3.5 Solutionsofdifferentialequationswithadditionalparameters|80 3.3.6 Avoidingtheuseofadditionalparameters|82 3.4 Validationsofnumericalsolutions|83 3.4.1 Validationofthecomputationresults|83 3.4.2 Dynamicmanipulationofintermediateresults|86 3.4.3 Moreaccuratesolvers|87 3.4.4 Step-sizesandfixed-stepdisplay|88 3.4.5 Demonstrationsofhigh-ordernonlineardifferentialequations|91 3.5 Exercises|93 4 Standardformconversionsofordinarydifferentialequations|99 4.1 Conversionmethodforasinglehigh-orderdifferentialequation|99 4.1.1 Conversionofexplicitequations|100 4.1.2 Solutionsoftime-varyingdifferentialequations|104 4.1.3 Singularitiesindifferentialequations|106 4.1.4 Stateaugmentationforconstantparameters|108 Contents | IX 4.2 Conversionsofcomplicatedhigh-orderdifferentialequations|109 4.2.1 Equationscontainingthesquareofthehighest-orderderivative|110 4.2.2 Equationscontainingoddpowers|112 4.2.3 Equationscontainingnonlinearoperations|113 4.3 Conversionsofdifferentialequationsets|114 4.3.1 Simpleexplicitdifferentialequationsets|115 4.3.2 Limitationswithfixed-stepmethods|122 4.3.3 Simpleimplicitdifferentialequations|124 4.3.4 Evenmorecomplicatednonlineardifferentialequations|127 4.4 Conversionsformatrixdifferentialequations|129 4.4.1 Conversionandsolutionsofdifferentialequationsinmatrix form|129 4.4.2 Sylvesterdifferentialequations|132 4.4.3 Riccatidifferentialequations|133 4.5 ConversionsofaclassofVolterraintegro-differentialequations|135 4.6 Exercises|139 5 Specialdifferentialequations|145 5.1 Stiffdifferentialequations|145 5.1.1 Timeconstantsinlineardifferentialequations|146 5.1.2 Demonstrationsofstiffphenomena|146 5.1.3 Directsolutionofstiffdifferentialequations|149 5.1.4 Stiffnessdetection|152 5.1.5 Fixed-stepsolutionofstiffdifferentialequations|157 5.2 Implicitdifferentialequations|158 5.2.1 Mathematicaldescriptionofimplicitdifferentialequations|159 5.2.2 Consistentinitialvaluetransformation|160 5.2.3 Directsolutionofimplicitdifferentialequations|163 5.2.4 Implicitdifferentialequationswithmultiplesolutions|166 5.3 Differential-algebraicequations|168 5.3.1 Generalformofdifferential-algebraicequations|168 5.3.2 Indicesofdifferential-algebraicequations|169 5.3.3 Semi-explicitdifferential-algebraicequations|169 5.3.4 Limitationsofthedirectsolver|173 5.3.5 Implicitsolversfordifferential-algebraicequations|175 5.3.6 Indexreductionfordifferential-algebraicequations|180 5.4 Switcheddifferentialequations|183 5.4.1 Linearswitcheddifferentialequations|183 5.4.2 Zero-crossingdetectionandeventhandling|185 5.4.3 Nonlinearswitcheddifferentialequations|188 5.4.4 Discontinuousdifferentialequations|190 5.5 Linearstochasticdifferentialequations|191