Web-Books
im Austria-Forum
Austria-Forum
Web-Books
Informatik
Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Seite - XVII -
  • Benutzer
  • Version
    • Vollversion
    • Textversion
  • Sprache
    • Deutsch
    • English - Englisch

Seite - XVII - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition

Bild der Seite - XVII -

Bild der Seite - XVII - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition

Text der Seite - XVII -

Contents xvii 4.1.5 Callinga FunctionDefinedwith PositionalParameters . . . 83 4.1.6 A FunctionwithTwoReturnValues . . . . . . . . . . . . . . . . . . . 85 4.1.7 Callinga FunctionDefinedwith KeywordParameters . . . . 85 4.1.8 A FunctionwithAnotherFunctionas InputArgument . . . . 86 4.1.9 LambdaFunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 4.1.10 A FunctionwithSeveralReturnStatements . . . . . . . . . . . . . 87 4.2 ProgrammingasaStep-Wise Strategy . . . . . . . . . . . . . . . . . . . . . . . . . 88 4.2.1 Makinga TimesTablesTest . . . . . . . . . . . . . . . . . . . . . . . . . . 89 4.2.2 The1stVersionofOurCode . . . . . . . . . . . . . . . . . . . . . . . . . 90 4.2.3 The2ndVersionofOurCode. . . . . . . . . . . . . . . . . . . . . . . . . 91 4.2.4 The3rdVersionofOurCode . . . . . . . . . . . . . . . . . . . . . . . . . 93 4.3 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 5 Some MorePythonEssentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 5.1 Lists andTuples:Alternatives toArrays . . . . . . . . . . . . . . . . . . . . . . . 103 5.2 ExceptionHandling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 5.2.1 TheFourthVersionofOurTimesTablesProgram.. . . . . . . 106 5.3 SymbolicComputations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 5.3.1 NumericalVersusSymbolicComputations. . . . . . . . . . . . . . 111 5.3.2 SymPy:SomeBasic Functionality. . . . . . . . . . . . . . . . . . . . . 112 5.3.3 SymbolicCalculationswithSomeOtherTools . . . . . . . . . . 112 5.4 MakingOurOwnModule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 5.4.1 A NaiveImport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 5.4.2 A Module forVerticalMotion . . . . . . . . . . . . . . . . . . . . . . . . 115 5.4.3 ModuleorProgram? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 5.5 Files: ReadandWrite. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 5.6 MeasuringExecutionTime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 5.6.1 ThetimeitModule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 5.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 6 ComputingIntegralsand Testing Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 6.1 Basic IdeasofNumerical Integration . . . . . . . . . . . . . . . . . . . . . . . . . . 132 6.2 TheCompositeTrapezoidalRule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 6.2.1 TheGeneralFormula . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 6.2.2 A General Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 6.2.3 A Specific Implementation:What’s the Problem? . . . . . . . . 139 6.3 TheCompositeMidpointMethod. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 6.3.1 TheGeneralFormula . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 6.3.2 A General Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 6.3.3 Comparing theTrapezoidaland the MidpointMethods . . . 145 6.4 Vectorizing theFunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 6.4.1 Vectorizing the MidpointRule . . . . . . . . . . . . . . . . . . . . . . . . 146 6.4.2 Vectorizing the TrapezoidalRule . . . . . . . . . . . . . . . . . . . . . . 147 6.4.3 SpeedupGainedwithVectorization . . . . . . . . . . . . . . . . . . . 148 6.5 Rate ofConvergence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 6.6 TestingCode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 6.6.1 Problemswith BriefTestingProcedures . . . . . . . . . . . . . . . . 150 6.6.2 ProperTest Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
zurück zum  Buch Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition"
Programming for Computations – Python A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Titel
Programming for Computations – Python
Untertitel
A Gentle Introduction to Numerical Simulations with Python 3.6
Band
Second Edition
Autoren
Svein Linge
Hans Petter Langtangen
Verlag
Springer Open
Datum
2020
Sprache
englisch
Lizenz
CC BY 4.0
ISBN
978-3-319-32428-9
Abmessungen
17.8 x 25.4 cm
Seiten
356
Schlagwörter
Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
Kategorie
Informatik
Web-Books
Bibliothek
Datenschutz
Impressum
Austria-Forum
Austria-Forum
Web-Books
Programming for Computations – Python