9783642112980-t1

7
Contents 1 Computing Integrals ......................................................... 1 1.1 Background ............................................................. 1 1.2 The Computational Problem ........................................... 3 1.3 The Trapezoidal Method ............................................... 4 1.3.1 Approximating the Integral Using One Trapezoid .......... 5 1.3.2 Approximating the Integral Using Two Trapezoids ......... 7 1.3.3 Approximating the Integral Using n Trapezoids ............ 9 1.4 Computational Analysis ............................................... 12 1.5 Back to the Bagels ...................................................... 14 1.6 Exercises ................................................................ 15 1.7 Projects ................................................................. 17 1.7.1 Show that the Error is O.h 2 / ................................. 17 1.7.2 Derive Other Methods for Numerical Integration ........... 22 1.7.3 Compute the Length of a Cable .............................. 26 2 Differential Equations: The First Steps .................................... 31 2.1 Modeling Changes ..................................................... 31 2.1.1 The Cultivation of Rabbits ................................... 32 2.1.2 The Simplest Possible Case .................................. 32 2.1.3 Exponential Growth .......................................... 33 2.1.4 Logistic Growth .............................................. 37 2.2 Numerical Solution ..................................................... 40 2.2.1 The Simplest Possible Model ................................ 41 2.2.2 Numerical Approximation of Exponential Growth ........................................................ 44 2.2.3 Numerical Stability ........................................... 46 2.2.4 An Implicit Scheme .......................................... 48 2.2.5 Explicit and Implicit Schemes ............................... 49 2.2.6 Numerical Solution of the Logistic Equation ............... 55 2.3 Exercises ................................................................ 60 2.4 Projects ................................................................. 67 2.4.1 More on Stability ............................................. 67 2.4.2 More on Accuracy ............................................ 69 vii

description

Springer contents

Transcript of 9783642112980-t1

Contents

1 Computing Integrals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.1 Background .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 The Computational Problem .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3 The Trapezoidal Method .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.3.1 Approximating the Integral Using One Trapezoid .. . . . . . . . . 51.3.2 Approximating the Integral Using Two Trapezoids . . . . . . . . . 71.3.3 Approximating the Integral Using n Trapezoids . . . . . . . . . . . . 9

1.4 Computational Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121.5 Back to the Bagels. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151.7 Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

1.7.1 Show that the Error is O.h2/. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171.7.2 Derive Other Methods for Numerical Integration .. . . . . . . . . . 221.7.3 Compute the Length of a Cable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

2 Differential Equations: The First Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312.1 Modeling Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

2.1.1 The Cultivation of Rabbits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322.1.2 The Simplest Possible Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322.1.3 Exponential Growth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332.1.4 Logistic Growth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

2.2 Numerical Solution.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402.2.1 The Simplest Possible Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412.2.2 Numerical Approximation of Exponential

Growth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442.2.3 Numerical Stability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462.2.4 An Implicit Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482.2.5 Explicit and Implicit Schemes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492.2.6 Numerical Solution of the Logistic Equation . . . . . . . . . . . . . . . 55

2.3 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602.4 Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

2.4.1 More on Stability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 672.4.2 More on Accuracy .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

vii

viii Contents

3 Systems of Ordinary Differential Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 753.1 Rabbits and Foxes; Fish and Sharks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 753.2 A Numerical Method: Unlimited Resources . . . . . . . . . . . . . . . . . . . . . . . . . . 783.3 A Numerical Method: Limited Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . 793.4 Phase Plane Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80

3.4.1 A Simplified Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 803.4.2 The Phase Plane . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 813.4.3 Circles in the Analytical Phase Plane . . . . . . . . . . . . . . . . . . . . . . . . 833.4.4 Alternative Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 843.4.5 Circles in the Numerical Phase Plane. . . . . . . . . . . . . . . . . . . . . . . . 853.4.6 More on Numerics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

3.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 913.6 Project: Analysis of a Simple System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95

4 Nonlinear Algebraic Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 994.1 The Bisection Method.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1024.2 Efficiency Consideration .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1064.3 Newton’s Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1074.4 The Secant Method .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1124.5 Fixed-Point Iterations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115

4.5.1 Convergence of Fixed-Point Iterations . . . . . . . . . . . . . . . . . . . . . .1174.5.2 Speed of Convergence .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1204.5.3 Existence and Uniqueness of a Solution. . . . . . . . . . . . . . . . . . . . .1214.5.4 Uniqueness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1224.5.5 Existence .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .123

4.6 Systems of Nonlinear Equations.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1254.6.1 A Linear System .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1264.6.2 A Nonlinear System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1274.6.3 Newton’s Method .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1294.6.4 A Nonlinear Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1324.6.5 The Nonlinear System Revisited . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133

4.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1344.8 Project: Convergence of Newton’s Method . . . . . . . . . . . . . . . . . . . . . . . . . . .138

5 The Method of Least Squares . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1475.1 Building Models of Discrete Data Sets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .150

5.1.1 Approximation by a Constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1505.1.2 Approximation by a Linear Function .. . . . . . . . . . . . . . . . . . . . . . .1545.1.3 Approximation by a Quadratic Function . . . . . . . . . . . . . . . . . . . .1575.1.4 Large Data Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161

5.2 Application to Population Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1655.2.1 Exponential Growth of the World Population? .. . . . . . . . . . . . .1665.2.2 Logistic Growth of the World Population . . . . . . . . . . . . . . . . . . .170

5.3 Least Squares Approximations of Functions. . . . . . . . . . . . . . . . . . . . . . . . . .1735.3.1 Approximating Functions by a Constant . . . . . . . . . . . . . . . . . . . .176

Contents ix

5.3.2 Approximation Using Linear Functions .. . . . . . . . . . . . . . . . . . . .1785.3.3 Approximation Using Quadratic Functions . . . . . . . . . . . . . . . . .1805.3.4 Summary of the Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .183

5.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1855.5 Project: Computing Coefficients. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .190

6 About Scientific Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1956.1 Algorithms Expressed as Pseudo Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .197

6.1.1 Basic Ingredients of Pseudo Codes . . . . . . . . . . . . . . . . . . . . . . . . . .1976.1.2 Integration.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1996.1.3 Optimization of Algorithms and Implementations .. . . . . . . . .2006.1.4 Developing Algorithms for Simpson’s Rule . . . . . . . . . . . . . . . .2036.1.5 Adaptive Integration Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2076.1.6 Ordinary Differential Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211

6.2 About Programming Languages .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2126.2.1 Static Typing Versus Dynamic Typing . . . . . . . . . . . . . . . . . . . . . .2136.2.2 Computational Efficiency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2146.2.3 Built-in High-Performance Utilities . . . . . . . . . . . . . . . . . . . . . . . . .2156.2.4 Support for User-Defined Objects . . . . . . . . . . . . . . . . . . . . . . . . . . .216

6.3 The Trapezoidal Rule in Different Languages . . . . . . . . . . . . . . . . . . . . . . . .2176.3.1 Code Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2176.3.2 Fortran 77 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2186.3.3 C and CCC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2226.3.4 Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2246.3.5 Matlab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2266.3.6 Python .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2286.3.7 Vectorization .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2306.3.8 Maple. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2366.3.9 Summary .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .237

6.4 Heun’s Scheme in Different Languages .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2396.4.1 Code Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2396.4.2 Fortran 77 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2396.4.3 Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2426.4.4 CCC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2446.4.5 Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2486.4.6 Matlab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2496.4.7 Python .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2516.4.8 Summary .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .252

6.5 Numerical Software Engineering .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2546.5.1 Function Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2546.5.2 Motivation for Object-Oriented Libraries . . . . . . . . . . . . . . . . . . .2596.5.3 Design of a Numerical Integration Hierarchy .. . . . . . . . . . . . . .2626.5.4 A Class Hierarchy in Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2636.5.5 A Class Hierarchy in Python .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2656.5.6 Object-Oriented Programming in Matlab . . . . . . . . . . . . . . . . . . .268

x Contents

6.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2696.7 Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .270

6.7.1 Computing the Volume of a Cylindrical Container . . . . . . . . .2706.7.2 A Class Hierarchy for Scalar ODE Solvers . . . . . . . . . . . . . . . . .2716.7.3 Software for Systems of ODEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .272

7 The Diffusion Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2737.1 Basics of Diffusion Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .274

7.1.1 Heat Conduction .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2747.1.2 Diffusive Transport of a Substance . . . . . . . . . . . . . . . . . . . . . . . . . .2757.1.3 Diffusion Versus Convection .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2767.1.4 The Relevance of One-Dimensional Models . . . . . . . . . . . . . . . .277

7.2 The Mathematical Model of Diffusion .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2857.2.1 The Diffusion Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2857.2.2 Initial and Boundary Conditions .. . . . . . . . . . . . . . . . . . . . . . . . . . . .2867.2.3 The One-Dimensional Initial-Boundary Value Problem .. . .2877.2.4 The Three-Dimensional Diffusion Equation . . . . . . . . . . . . . . . .287

7.3 Derivation of Diffusion Equations .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2907.3.1 Diffusion of a Substance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2907.3.2 Heat Conduction .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2957.3.3 Viscous Fluid Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3007.3.4 Summarizing the Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3047.3.5 Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .307

7.4 Explicit Numerical Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3167.4.1 The Basics of Finite Difference Discretizations. . . . . . . . . . . . .3167.4.2 Incorporating Dirichlet Boundary Conditions. . . . . . . . . . . . . . .3217.4.3 Incorporating Neumann Boundary Conditions . . . . . . . . . . . . . .3217.4.4 How to Verify a Computer Implementation .. . . . . . . . . . . . . . . .3247.4.5 Instability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3277.4.6 A Discrete Algorithm Directly from Physics. . . . . . . . . . . . . . . .3327.4.7 Variable Coefficients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .334

7.5 Implicit Numerical Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3367.5.1 The Backward Euler Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3367.5.2 The Linear System of Equations .. . . . . . . . . . . . . . . . . . . . . . . . . . . .3377.5.3 Solution of Tridiagonal Linear Systems . . . . . . . . . . . . . . . . . . . . .3407.5.4 Comparing the Explicit and Implicit Methods . . . . . . . . . . . . . .3427.5.5 The Crank–Nicolson Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3447.5.6 The � Scheme.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .346

7.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3487.7 Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .352

7.7.1 Diffusion of a Jump . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3527.7.2 Periodical Injection of Pollution . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3537.7.3 Analyzing Discrete Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3557.7.4 Compare Different Scalings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .356

Contents xi

8 Analysis of the Diffusion Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3598.1 Properties of the Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .360

8.1.1 Energy Arguments .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3608.1.2 A Bound on the Derivative .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3628.1.3 Stability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3648.1.4 Uniqueness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3668.1.5 Maximum Principles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3668.1.6 Physical Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3678.1.7 Analytical Considerations .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3678.1.8 The Minimum Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3728.1.9 Summary .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3738.1.10 Uniqueness Revisited . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .374

8.2 Separation of Variables and Fourier Analysis . . . . . . . . . . . . . . . . . . . . . . . . .3748.2.1 Separation of Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3758.2.2 Super-Positioning .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3788.2.3 Fourier Series and the Initial Condition . . . . . . . . . . . . . . . . . . . . .3818.2.4 Some Simple Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3818.2.5 Initial Conditions Given by a Sum of Sine Functions . . . . . .3828.2.6 Computing Fourier Sine Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3848.2.7 Summary .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3868.2.8 More Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3878.2.9 Analysis of an Explicit Finite Difference Scheme . . . . . . . . . .3928.2.10 Consequences of the Stability Criterion . . . . . . . . . . . . . . . . . . . . .3958.2.11 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .396

8.3 Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4038.3.1 Neumann Boundary Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4038.3.2 Variable Coefficients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .406

9 Parameter Estimation and Inverse Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4119.1 Parameter Estimation in Exponential Growth . . . . . . . . . . . . . . . . . . . . . . . .412

9.1.1 A Simpler Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4149.2 The Backward Diffusion Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4159.3 Estimating the Diffusion Coefficient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4189.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .419

10 A Glimpse of Parallel Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42310.1 Motivations for Parallel Computing .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .423

10.1.1 From the Perspective of Speed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42310.1.2 From the Perspective of Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . .42610.1.3 Parallel Computers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .426

10.2 More About Parallel Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42710.2.1 Inspirations from Parallel Processing in Real Life . . . . . . . . . .42810.2.2 From Serial Computing to Parallel Computing . . . . . . . . . . . . .42810.2.3 Example 1 of Data Parallelism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43010.2.4 Example 2 of Data Parallelism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .432

xii Contents

10.2.5 Example 3 of Data Parallelism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43410.2.6 Performance Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43810.2.7 Overhead Related to Parallelization . . . . . . . . . . . . . . . . . . . . . . . . .440

10.3 Parallel Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44210.3.1 OpenMP Programming .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44310.3.2 MPI Programming .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44510.3.3 Concluding Remarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .449

10.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44910.5 Project: Parallel Solution of a 2D Diffusion Equation. . . . . . . . . . . . . . . .451

References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .455

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .457

http://www.springer.com/978-3-642-11298-0