xviii
Contents
6.6.3 Finite Precision of Floating-Point Numbers . . . . . . . . . . . . . 153
6.6.4 Constructing Unit Tests and Writing Test Functions . . . . . . 155
6.7 Double and Triple Integrals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
6.7.1 The Midpoint Rule for a Double Integral . . . . . . . . . . . . . . . 157
6.7.2 The Midpoint Rule for a Triple Integral . . . . . . . . . . . . . . . . 161
6.7.3 Monte Carlo Integration for Complex-Shaped Domains . . . 163
6.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
7 Solving Nonlinear Algebraic Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
7.1 Brute Force Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
7.1.1 Brute Force Root Finding . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
7.1.2 Brute Force Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
7.1.3 Model Problem for Algebraic Equations . . . . . . . . . . . . . . . . 180
7.2 Newton’s Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
7.2.1 Deriving and Implementing Newton’s Method . . . . . . . . . . 181
7.2.2 Making a More Efficient and Robust Implementation . . . . . 184
7.3 The Secant Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
7.4 The Bisection Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
7.5 Rate of Convergence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
7.6 Solving Multiple Nonlinear Algebraic Equations . . . . . . . . . . . . . . . . 195
7.6.1 Abstract Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
7.6.2 Taylor Expansions for Multi-Variable Functions . . . . . . . . . 195
7.6.3 Newton’s Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
7.6.4 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
7.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
8 Solving Ordinary Differential Equations . . . . . . . . . . . . . . . . . . . . . . . . . 203
8.1 Filling a Water Tank: Two Cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
8.1.1 Case 1: Piecewise Constant Rate . . . . . . . . . . . . . . . . . . . . . . 205
8.1.2 Case 2: Continuously Increasing Rate . . . . . . . . . . . . . . . . . . 207
8.1.3 Reformulating the Problems as ODEs . . . . . . . . . . . . . . . . . . 209
8.2 Population Growth: A First Order ODE . . . . . . . . . . . . . . . . . . . . . . . . 210
8.2.1 Derivation of the Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
8.2.2 Numerical Solution: The Forward Euler (FE) Method . . . . 213
8.2.3 Programming the FE Scheme; the Special Case . . . . . . . . . . 217
8.2.4 Understanding the Forward Euler Method . . . . . . . . . . . . . . 219
8.2.5 Programming the FE Scheme; the General Case . . . . . . . . . 220
8.2.6 A More Realistic Population Growth Model . . . . . . . . . . . . 221
8.2.7 Verification: Exact Linear Solution of the Discrete
Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
8.3 Spreading of Disease: A System of First Order ODEs . . . . . . . . . . . . 225
8.3.1 Spreading of Flu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
8.3.2 A FE Method for the System of ODEs . . . . . . . . . . . . . . . . . 228
8.3.3 Programming the FE Scheme; the Special Case . . . . . . . . . . 229
8.3.4 Outbreak or Not . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
8.3.5 Abstract Problem and Notation . . . . . . . . . . . . . . . . . . . . . . . 232
8.3.6 Programming the FE Scheme; the General Case . . . . . . . . . 232
8.3.7 Time-Restricted Immunity . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Précédent

- 17/350

Suivant