ebook img

Numerical Methods in Engineering With Python PDF

433 Pages·2005·1.781 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 Numerical Methods in Engineering With Python

P1:KIC CB904-FM CB904/Kiusalaas 0521852870 May23,2005 19:15 Numerical Methods in Engineering with Python NumericalMethodsinEngineeringwithPythonisatextforengineer- ingstudentsandareferenceforpracticingengineers,especiallythose whowishtoexplorethepowerandefficiencyofPython.Thechoiceof numericalmethodswasbasedontheirrelevancetoengineeringprob- lems.Everymethodisdiscussedthoroughlyandillustratedwithprob- lems involving both hand computation and programming. Computer codeaccompanieseachmethodandisavailableonthebookwebsite. Thiscodeismadesimpleandeasytounderstandbyavoidingcomplex book-keepingschemes,whilemaintainingtheessentialfeaturesofthe methodPythonwaschosenastheexamplelanguagebecauseitisele- gant,easytolearnanddebug,anditsfacilitiesforhandlingarraysare unsurpassed.Moreover,itisanopen-sourcesoftwarepackagethatcan bedownloadedfreelyontheweb.Pythonisagreatlanguageforteaching scientificcomputation. JaanKiusalaasisaProfessorEmeritusintheDepartmentofEngineer- ingScienceandMechanicsatthePennsylvaniaStateUniversity.Hehas taughtcomputermethods,includingfiniteelementandboundaryele- mentmethods,forover30years.Heisalsotheco-authoroffourother books—EngineeringMechanics:Statics,EngineeringMechanics:Dynam- ics,MechanicsofMaterials,andanalternateversionofthisworkwith ® MATLAB code. i P1:KIC CB904-FM CB904/Kiusalaas 0521852870 May23,2005 19:15 ii P1:KIC CB904-FM CB904/Kiusalaas 0521852870 May23,2005 19:15 NUMERICAL METHODS IN ENGINEERING WITH Python Jaan Kiusalaas ThePennsylvaniaStateUniversity iii    Cambridge, New York, Melbourne, Madrid, Cape Town, Singapore, São Paulo Cambridge University Press The Edinburgh Building, Cambridge  , UK Published in the United States of America by Cambridge University Press, New York www.cambridge.org Information on this title: www.cambridg e.org /9780521852876 ©JaanKiusalaas2005 This publication is in copyright. Subject to statutory exception and to the provision of relevant collective licensing agreements, no reproduction of any part may take place without the written permission of Cambridge University Press. First published in print format 2005 - ---- eBook (NetLibrary) - --- eBook (NetLibrary) - ---- hardback - --- hardback Cambridge University Press has no responsibility for the persistence or accuracy of s for external or third-party internet websites referred to in this publication, and does not guaranteethatanycontentonsuchwebsitesis,orwillremain,accurateorappropriate. P1:KIC CB904-FM CB904/Kiusalaas 0521852870 May23,2005 19:15 Contents Preface.........vii 1. IntroductiontoPython.............................. 1 2. SystemsofLinearAlgebraicEquations............. 27 3. InterpolationandCurveFitting.....................103 4. RootsofEquations...................................142 5. NumericalDifferentiation...........................181 6. NumericalIntegration...............................198 7. InitialValueProblems...............................248 8. Two-PointBoundaryValueProblems...............295 9. SymmetricMatrixEigenvalueProblems............324 10. IntroductiontoOptimization.......................381 Appendices....409 Index...........419 v P1:KIC CB904-FM CB904/Kiusalaas 0521852870 May23,2005 19:15 vi P1:KIC CB904-FM CB904/Kiusalaas 0521852870 May23,2005 19:15 Preface This book is targeted primarily toward engineers and engineering students of ad- vanced standing (sophomores, seniors and graduate students). Familiarity with a computerlanguageisrequired;knowledgeofbasicengineeringmechanicsisuseful, butnotessential. Thetextattemptstoplaceemphasisonnumericalmethods,notprogramming. Mostengineersarenotprogrammers,butproblemsolvers.Theywanttoknowwhat methodscanbeappliedtoagivenproblem,whataretheirstrengthsandpitfallsand howtoimplementthem.Engineersarenotexpectedtowritecomputercodeforbasic tasksfromscratch;theyaremorelikelytoutilizefunctionsandsubroutinesthathave beenalreadywrittenandtested.Thusprogrammingbyengineersislargelyconfined toassemblingexistingpiecesofcodeintoacoherentpackagethatsolvestheproblem athand. The“piece”ofcodeisusuallyafunctionthatimplementsaspecifictask.Forthe userthedetailsofthecodeareunimportant.Whatmattersistheinterface(whatgoes inandwhatcomesout)andanunderstandingofthemethodonwhichthealgorithm isbased.Sincenonumericalalgorithmisinfallible,theimportanceofunderstanding theunderlyingmethodcannotbeoveremphasized;itis,infact,therationalebehind learningnumericalmethods. This book attempts to conform to the views outlined above. Each numerical methodisexplainedindetailanditsshortcomingsarepointedout.Theexamplesthat followindividualtopicsfallintotwocategories:handcomputationsthatillustratethe innerworkingsofthemethodandsmallprogramsthatshowhowthecomputercodeis utilizedinsolvingaproblem.Problemsthatrequireprogrammingaremarkedwith(cid:1). The material consists of the usual topics covered in an engineering course on numericalmethods:solutionofequations,interpolationanddatafitting,numerical differentiationandintegration,solutionofordinarydifferentialequationsandeigen- valueproblems.Thechoiceofmethodswithineachtopicistiltedtowardrelevance toengineeringproblems.Forexample,thereisanextensivediscussionofsymmetric, vii P1:KIC CB904-FM CB904/Kiusalaas 0521852870 May23,2005 19:15 viii Preface sparsely populated coefficient matrices in the solution of simultaneous equations. Inthesamevein,thesolutionofeigenvalueproblemsconcentratesonmethodsthat efficientlyextractspecificeigenvaluesfrombandedmatrices. Animportantcriterionusedintheselectionofmethodswasclarity.Algorithms requiringoverlycomplexbookkeepingwererejectedregardlessoftheirefficiencyand robustness.Thisdecision,whichwastakenwithgreatreluctance,isinkeepingwith theintenttoavoidemphasisonprogramming. Theselectionofalgorithmswasalsoinfluencedbycurrentpractice.Thisdisqual- ifiedseveralwell-knownhistoricalmethodsthathavebeenovertakenbymorerecent developments. For example, the secant method for finding roots of equations was omittedashavingnoadvantagesoverBrent’smethod.Forthesamereason,themul- tistepmethodsusedtosolvedifferentialequations(e.g.,MilneandAdamsmethods) wereleftoutinfavoroftheadaptiveRunge–KuttaandBulirsch–Stoermethods. Notablyabsentisachapteronpartialdifferentialequations.Itwasfeltthatthis topicisbesttreatedbyfiniteelementorboundaryelementmethods,whichareoutside thescopeofthisbook.Thefinitedifferencemodel,whichiscommonlyintroduced in numerical methods texts, is just too impractical in handling multidimensional boundaryvalueproblems. Asusual,thebookcontainsmorematerialthancanbecoveredinathree-credit course.Thetopicsthatcanbeskippedwithoutlossofcontinuityaretaggedwithan asterisk(*). TheprogramslistedinthisbookweretestedwithPython2.2.2and2.3.4under WindowsXPandRedHatLinux.Thesourcecodecanbedownloadedfromthebook’s websiteat www.cambridge.org/0521852870 The author wishes to express his gratitude to the anonymous reviewers and Professor Andrew Pytel for their suggestions for improving the manuscript. Credit isalsoduetotheauthorsofNumericalRecipes(CambridgeUniversityPress)whose presentationofnumericalmethodswasinspirationalinwritingthisbook. P1:JzG CB904-01 CB904/Kiusalaas 0521852870 April29,2005 4:41 1 Introduction to Python 1.1 General Information Quick Overview This chapter is not a comprehensive manual of Python. Its sole aim is to provide sufficientinformationtogiveyouagoodstartifyouareunfamiliarwithPython.Ifyou knowanothercomputerlanguage,andpresumablyyoudo,itisnotdifficulttopick uptherestasyougo. Python is an object-oriented language that was developed in late 1980s as a scripting language (the name is derived from the British television show Monty Python’s Flying Circus). Although Python is not as well known in engineering cir- cles as some other languages, it has a considerable following in the programming community—infact,PythonisconsiderablymorewidespreadthanFortran.Python may be viewed as an emerging language, since it is still being developed and re- fined. In the current state, it is an excellent language for developing engineering applications—itpossessesasimpleelegancethatotherprogramminglanguagescan- notmatch. Pythonprogramsarenotcompiledintomachinecode,butarerunbyaninter- preter1.Thegreatadvantageofaninterpretedlanguageisthatprogramscanbetested anddebuggedquickly,allowingtheusertoconcentratemoreontheprinciplesbe- hindtheprogramandlessonprogrammingitself.Sincethereisnoneedtocompile, linkandexecuteaftereachcorrection,Pythonprogramscanbedevelopedinamuch shortertimethanequivalentFortranorCprograms.Onthenegativeside,interpreted programsdonotproducestand-aloneapplications.ThusaPythonprogramcanbe runonlyoncomputersthathavethePythoninterpreterinstalled. 1 ThePythoninterpreteralsocompilesbytecode,whichhelpstospeedupexecutionsomewhat. 1

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.