ebook img

Programming Mathematics Using MATLAB PDF

273 Pages·2020·7.443 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Programming Mathematics Using MATLAB

PROGRAMMING MATHEMATICS ® USING MATLAB PROGRAMMING MATHEMATICS USING ® MATLAB LISAA.OBERBROECKLING DepartmentofMathematicsandStatistics LoyolaUniversityMaryland Baltimore,MD,UnitedStates AcademicPressisanimprintofElsevier 125LondonWall,LondonEC2Y5AS,UnitedKingdom 525BStreet,Suite1650,SanDiego,CA92101,UnitedStates 50HampshireStreet,5thFloor,Cambridge,MA02139,UnitedStates TheBoulevard,LangfordLane,Kidlington,OxfordOX51GB,UnitedKingdom Copyright©2021ElsevierInc.Allrightsreserved. MATLAB®isatrademarkofTheMathWorks,Inc.andisusedwithpermission. TheMathWorksdoesnotwarranttheaccuracyofthetextorexercisesinthisbook. Thisbook’suseordiscussionofMATLAB®softwareorrelatedproductsdoesnotconstituteendorsementor sponsorshipbyTheMathWorksofaparticularpedagogicalapproachorparticularuseoftheMATLAB®software. Nopartofthispublicationmaybereproducedortransmittedinanyformorbyanymeans,electronicor mechanical,includingphotocopying,recording,oranyinformationstorageandretrievalsystem,without permissioninwritingfromthepublisher.Detailsonhowtoseekpermission,furtherinformationaboutthe Publisher’spermissionspoliciesandourarrangementswithorganizationssuchastheCopyrightClearanceCenter andtheCopyrightLicensingAgency,canbefoundatourwebsite:www.elsevier.com/permissions. ThisbookandtheindividualcontributionscontainedinitareprotectedundercopyrightbythePublisher(other thanasmaybenotedherein). Notices Knowledgeandbestpracticeinthisfieldareconstantlychanging.Asnewresearchandexperiencebroadenour understanding,changesinresearchmethods,professionalpractices,ormedicaltreatmentmaybecomenecessary. Practitionersandresearchersmustalwaysrelyontheirownexperienceandknowledgeinevaluatingandusingany information,methods,compounds,orexperimentsdescribedherein.Inusingsuchinformationormethodsthey shouldbemindfuloftheirownsafetyandthesafetyofothers,includingpartiesforwhomtheyhaveaprofessional responsibility. Tothefullestextentofthelaw,neitherthePublishernortheauthors,contributors,oreditors,assumeanyliability foranyinjuryand/ordamagetopersonsorpropertyasamatterofproductsliability,negligenceorotherwise,or fromanyuseoroperationofanymethods,products,instructions,orideascontainedinthematerialherein. LibraryofCongressCataloging-in-PublicationData AcatalogrecordforthisbookisavailablefromtheLibraryofCongress BritishLibraryCataloguing-in-PublicationData AcataloguerecordforthisbookisavailablefromtheBritishLibrary ISBN:978-0-12-817799-0 ForinformationonallAcademicPresspublications visitourwebsiteathttps://www.elsevier.com/books-and-journals Publisher:KateyBirtcher EditorialProjectManager:RafaelG.Trombaco ProductionProjectManager:BeulaChristopher Designer:BridgetHoette TypesetbyVTeX To Rob and James, for the support, patience (especially when teaching MATLAB), and laughter. To Christos Xenophontos for your encouragement and for introducing me to MATLAB. Contents Preface xiii Introduction xv Part1. MATLAB® 1. IntroductiontoMATLAB® 3 1.1. BasicMATLAB®information 3 1.1.1. StartingMATLAB 3 1.1.2. Goodcommandstoknow 3 1.2. Basicmathematics 4 1.2.1. Built-inmathematicalfunctions 5 1.2.2. Precedencerules 6 1.2.3. Formats 8 1.3. Variables 9 1.4. Diariesandscriptfiles 10 1.5. Exercises 12 2. VectorsandMatrices(Arrays) 15 2.1. One-dimensionalarrays(vectors) 15 2.1.1. Constantspacedvectors 15 2.1.2. Equallyspacedvectors 16 2.2. Two-dimensionalarrays(matrices) 17 2.3. Addressingelementsofvectors/arrays 18 2.4. Component-wisecalculations 22 2.5. Randomnumbers 25 2.6. Exercises 28 3. PlottinginMATLAB® 33 3.1. Basic2Dplots 33 3.2. Baddomainexamples 34 3.3. Axissettings 35 3.4. Multipleplots 40 3.5. Color,line,andmarkermodifications 43 3.5.1. Clf/closeall 46 3.5.2. Subplots 46 3.6. Other2Dplots 49 3.6.1. Parametriccurves 49 3.6.2. Polarcurves 50 3.7. Exercises 52 4. Three-DimensionalPlots 59 4.1. Vectorfunctionsorspacecurves 59 vii viii Contents 4.2. Plottingsurfaces 62 4.2.1. Themeshgridcommand 63 4.2.2. Domainissues 64 4.2.3. Levelcurves 65 4.2.4. Multipleplotsandmodifyingcolors 66 4.3. Viewcommand 68 4.4. Axissettings,revisited 70 4.5. Othercoordinatesystemsand3Dgraphs 72 4.5.1. Thesphereandcylindercommands 72 4.5.2. Cylindricalcoordinates 75 4.5.3. Sphericalcoordinates 77 4.6. Exercises 78 5. Functions 83 5.1. Thelookforandhelpcommands 83 5.2. Fileformat 84 5.3. Functionexamples 86 5.3.1. Basicfunctionexamples 86 5.3.2. Morefunctionexamples–multipleinputs 86 5.3.3. Multipleoutputs 87 5.3.4. Badexamples 89 5.4. Exercises 90 6. ControlFlow 93 6.1. Relationalandlogicaloperators 93 6.2. Ifstatements 97 6.3. Switch/case 99 6.4. Useofcharacteristicfunctions 99 6.5. Forloops 100 6.6. Whileloops 102 6.7. Usefulcommandsbreak,continue,return,anderror 103 6.8. Optionalinputsandoutputsoffunctions 104 6.9. Exercises 107 7. MiscellaneousCommandsandCodeImprovement 115 7.1. Miscellaneouscommands 115 7.1.1. Thefprintfcommand 115 7.1.2. Thesprintfcommand 117 7.1.3. Formatsrevisited 118 7.1.4. Thesave/loadcommands 118 7.1.5. Thetic/toccommands 119 7.1.6. Thefillcommand 119 7.1.7. Thecommandalpha 122 7.1.8. Thesyms,diff,int,andsubscommands 125 7.1.9. Commandsforpolynomials 127 Contents ix 7.2. Codeimprovement 129 7.2.1. Vectorizationofcode 130 7.2.2. Preallocation 131 Part2. MathematicsandMATLAB® 8. TransformationsandFernFractals 135 8.1. Lineartransformations 135 8.2. Affinetransformations 139 8.3. Fernfractals 140 8.4. Exercises 141 9. ComplexNumbersandFractals 147 9.1. Complexnumbers 147 9.1.1. Addingcomplexnumbers 147 9.1.2. Multiplicationbyarealnumbers(scalars) 147 9.1.3. MultiplicationanddeMoivre’stheorem/formula 147 9.1.4. PlottingcomplexnumbersinMATLAB® 150 9.1.5. Creatinglinesegmentswithcomplexnumbers 151 9.2. TheChaosGame 153 9.3. Linereplacementfractals 154 9.3.1. Snowflakefractals 154 9.3.2. GosperIsland 155 9.4. Geometricseries 156 9.5. Exercises 158 10.SeriesandTaylorPolynomials 167 10.1. Reviewofseries 167 10.2. Powerseries 169 10.3. TaylorpolynomialsandTaylorseries 173 10.4. Exercises 177 11.NumericalIntegration 183 11.1. Approximatingintegrals/numericalintegration 183 11.2. Riemannsums 183 11.3. Errorbounds 185 11.4. Simpson’srule 186 11.5. Exercises 189 12.TheGram–SchmidtProcess 193 12.1. Generalvectorspacesandsubspaces 193 12.1.1. Vectorspaces 193 12.1.2. Subspaces 194 12.2. Linearcombinationsofvectors 195 12.3. Linearindependenceandbases 196 x Contents 12.3.1. Linearindependence 196 12.3.2. Bases 197 12.4. Rank 200 12.5. OrthonormalvectorsandtheGram–Schmidtprocess 201 12.5.1. Orthogonalandorthonormalvectors 201 12.5.2. TheGram–Schmidtprocess 204 12.6. Answerstoexampleproblems 210 12.7. Exercises 211 A. PublishingandLiveScripts 215 A.1. Livescripts 215 A.2. BasicscriptsorM-files 215 A.3. PublishingM-files 216 A.4. Usingsections 216 A.4.1. Usingsectionsforpublishing 217 A.4.2. Usingsectionsforrunning/debuggingfiles 222 A.5. Formattingtext 223 A.5.1. Basictextformatting 223 A.5.2. Lists 224 A.5.3. HTMLlinks 225 A.5.4. Insertingimages 225 A.5.5. Pre-formattedtext 226 A.5.6. InsertingHTMLcode 227 A.5.7. InsertingLATEXequations 227 B. FinalProjects 229 B.1. Ciphers 229 B.1.1. Substitutioncipher 229 B.1.2. Columnartranspositioncipher 230 B.2. GameofPig 231 B.3. LinearizationandNewton’smethod 232 B.3.1. Linearization 232 B.3.2. Newton’smethod 232 B.4. DiskandShellmethod 234 B.5. Powerballdata 235 C. LinearAlgebraProjects 237 C.1. Matrixcalculationsandlinearsystems 237 C.1.1. Firsthandout 237 C.1.2. Exercises 239 C.2. TheHillcipher 243 C.2.1. Usefulcommands 245 C.2.2. Exercises 251 C.3. Least-squaressolutions 252 C.3.1. Briefoverview 252

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.