Page - XII - in Programming for Computations β Python - A Gentle Introduction to Numerical Simulations with Python
Image of the Page - XII -
Text of the Page - XII -
xii Contents
3 ComputingIntegrals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
3.1 Basic IdeasofNumerical Integration . . . . . . . . . . . . . . . . . . 56
3.2 TheCompositeTrapezoidalRule . . . . . . . . . . . . . . . . . . . . . 57
3.2.1 TheGeneralFormula. . . . . . . . . . . . . . . . . . . . . . . . 59
3.2.2 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
3.2.3 MakingaModule . . . . . . . . . . . . . . . . . . . . . . . . . . 62
3.2.4 AlternativeFlatSpecial-Purpose Implementation . . . . . . 63
3.3 TheCompositeMidpointMethod . . . . . . . . . . . . . . . . . . . . 65
3.3.1 TheGeneralFormula. . . . . . . . . . . . . . . . . . . . . . . . 66
3.3.2 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
3.3.3 Comparing theTrapezoidaland theMidpointMethods . . . 67
3.4 Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
3.4.1 ProblemswithBriefTestingProcedures . . . . . . . . . . . . 68
3.4.2 ProperTestProcedures . . . . . . . . . . . . . . . . . . . . . . 69
3.4.3 FinitePrecisionofFloating-PointNumbers . . . . . . . . . . 71
3.4.4 ConstructingUnitTests andWritingTestFunctions . . . . . 72
3.5 Vectorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
3.6 MeasuringComputationalSpeed . . . . . . . . . . . . . . . . . . . . . 77
3.7 DoubleandTriple Integrals . . . . . . . . . . . . . . . . . . . . . . . . 78
3.7.1 TheMidpointRule foraDouble Integral . . . . . . . . . . . 78
3.7.2 TheMidpointRule foraTriple Integral . . . . . . . . . . . . 81
3.7.3 MonteCarlo Integration forComplex-ShapedDomains . . 84
3.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
4 SolvingOrdinaryDifferentialEquations . . . . . . . . . . . . . . . . . . 95
4.1 PopulationGrowth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
4.1.1 Derivationof theModel . . . . . . . . . . . . . . . . . . . . . . 97
4.1.2 NumericalSolution . . . . . . . . . . . . . . . . . . . . . . . . . 99
4.1.3 ProgrammingtheForwardEulerScheme; theSpecialCase 102
4.1.4 Understanding theForwardEulerMethod . . . . . . . . . . . 105
4.1.5 ProgrammingtheForwardEulerScheme; theGeneralCase 105
4.1.6 Making thePopulationGrowthModelMoreRealistic . . . 106
4.1.7 Verification:ExactLinearSolutionoftheDiscreteEquations109
4.2 SpreadingofDiseases . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
4.2.1 SpreadingofaFlu . . . . . . . . . . . . . . . . . . . . . . . . . 110
4.2.2 AForwardEulerMethod for theDifferential Equation
System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
4.2.3 ProgrammingtheNumericalMethod; theSpecialCase . . . 114
4.2.4 OutbreakorNot . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
4.2.5 AbstractProblemandNotation . . . . . . . . . . . . . . . . . 116
4.2.6 ProgrammingtheNumericalMethod; theGeneralCase . . 117
4.2.7 Time-Restricted Immunity . . . . . . . . . . . . . . . . . . . . 119
4.2.8 IncorporatingVaccination . . . . . . . . . . . . . . . . . . . . . 120
4.2.9 DiscontinuousCoefficients:AVaccinationCampaign . . . 123
4.3 OscillatingOne-DimensionalSystems . . . . . . . . . . . . . . . . . 124
4.3.1 DerivationofaSimpleModel . . . . . . . . . . . . . . . . . . 124
4.3.2 NumericalSolution . . . . . . . . . . . . . . . . . . . . . . . . . 126
4.3.3 ProgrammingtheNumericalMethod; theSpecialCase . . . 126
back to the
book Programming for Computations β Python - A Gentle Introduction to Numerical Simulations with Python"
Programming for Computations β Python
A Gentle Introduction to Numerical Simulations with Python
- Title
- Programming for Computations β Python
- Subtitle
- A Gentle Introduction to Numerical Simulations with Python
- Authors
- Svein Linge
- Hans Petter Langtangen
- Publisher
- Springer Open
- Date
- 2016
- Language
- English
- License
- CC BY-NC 4.0
- ISBN
- 978-3-319-32428-9
- Size
- 17.8 x 25.4 cm
- Pages
- 248
- Keywords
- Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
- Category
- Informatik