Author(s): Karline Soetaert, Jeff Cash, Francesca Mazzia
Publisher: Springer
Year: 2012
bfm_978-3-642-28070-2_1
Solving Differential Equations in R
Preface
R as a Problem Solving Environment
About the Three Authors
Acknowledgment
References
Contents
1
Chapter 1 Differential Equations
1.1 Basic Theory of Ordinary Differential Equations
1.1.1 First Order Differential Equations
1.1.2 Analytic and Numerical Solutions
1.1.3 Higher Order Ordinary Differential Equations
1.1.4 Initial and Boundary Values
1.1.5 Existence and Uniqueness of Analytic Solutions
1.2 Numerical Methods
1.2.1 The Euler Method
1.2.2 Implicit Methods
1.2.3 Accuracy and Convergence of Numerical Methods
1.2.4 Stability and Conditioning
1.2.4.1 Absolute Stability
1.3 Other Types of Differential Equations
1.3.1 Partial Differential Equations
1.3.2 Differential Algebraic Equations
1.3.3 Delay Differential Equations
References
2
Chapter 2 Initial Value Problems
2.1 Runge-Kutta Methods
2.1.1 Explicit Runge-Kutta Formulae
2.1.2 Deriving a Runge-Kutta Formula
2.1.2.1 The Order Conditions
2.1.2.2 Controlling the Error
2.1.2.3 Changing the Step Size
2.1.2.4 Embedded Runge-Kutta Methods
2.1.2.5 Continuous Solutions
2.1.2.6 Stability
2.1.3 Implicit Runge-Kutta Formulae
2.2 Linear Multistep methods
2.2.1 Convergence, Stability and Consistency
2.2.2 Adams Methods
2.2.2.1 Controlling the Error of Adams Methods
2.2.2.2 Stability of Adams Methods
2.2.3 Backward Differentiation Formulae
2.2.3.1 Variable Step Size in BDF Formulae
2.2.3.2 Stability of BDF
2.2.4 Variable Order – Variable Coefficient Formulae for Linear Multistep Methods
2.2.4.1 Variable Order
2.2.4.2 Variable Coefficient Methods
2.3 Boundary Value Methods
2.4 Modified Extended Backward Differentiation Formulae
2.5 Stiff Problems
2.5.1 Stiffness Detection
2.5.2 Non-stiffness Test
2.6 Implementing Implicit Methods
2.6.1 Fixed-Point Iteration to Convergence
2.6.2 Chord Iteration
2.6.3 Predictor-Corrector Methods
2.6.4 Newton Iteration for Implicit Runge-Kutta Methods
2.7 Codes to Solve Initial Value Problems
2.7.1 Codes to Solve Non-stiff Problems
2.7.2 Codes to Solve Stiff Problems
2.7.3 Codes that Switch Between Stiff and Non-stiff Solvers
References
3
Chapter 3 Solving Ordinary Differential Equations in R
3.1 Implementing Initial Value Problems in R
3.1.1 A Differential Equation Comprising One Variable
3.1.2 Multiple Variables: The Lorenz Model
3.2 Runge-Kutta Methods
3.2.1 Rigid Body Equations
3.2.2 Arenstorf Orbits
3.3 Linear Multistep Methods
3.3.1 Seven Moving Stars
3.3.2 A Stiff Chemical Example
3.3.2.1 External Variables
3.4 Discontinuous Equations, Events
3.4.1 Pharmacokinetic Models
3.4.1.1 A Two-Compartment Model Describing Oral Drug Intake
3.4.1.2 A One-Compartment Model Describing Drug Injection
3.4.2 A Bouncing Ball
3.4.3 Temperature in a Climate-Controlled Room
3.5 Method Selection
3.5.1 The van der Pol Equation
3.5.1.1 Printing the Diagnostics of the Solutions
3.5.1.2 Timings
3.5.1.3 Work Precision Diagrams and mescd
3.6 Exercises
3.6.1 Getting Started with IVP
3.6.2 The Robertson Problem
3.6.3 Displaying Results in a Phase-Plane Graph
3.6.3.1 The Rossler Equations
3.6.3.2 Josephson Junctions
3.6.4 Events and Roots
3.6.5 Stiff Problems
References
4
Chapter 4 Differential Algebraic Equations
4.1 Introduction
4.1.1 The Index of a DAE
4.1.2 A Simple Example
4.1.3 DAEs in Hessenberg Form
4.1.4 Hidden Constraints and the Initial Conditions
4.1.4.1 Hidden Constraints in Index 2 DAEs in Hessenberg Form
4.1.4.2 Hidden Constraints in Index 3 DAEs
4.1.5 The Pendulum Problem
4.2 Solving DAEs
4.2.1 Semi-implicit DAEs of Index 1
4.2.1.1 The -embedding Method
4.2.1.2 The State Space Form Method
4.2.2 General Implicit DAEs of Index 1
4.2.3 Discretization Algorithms
4.2.4 DAEs of Higher Index
4.2.4.1 Index Reduction
4.2.4.2 Higher Index Solvers
4.2.5 Index of a DAE Variable
References
5
Chapter 5 Solving Differential Algebraic Equations in R
5.1 Differential Algebraic Equation Solvers in R
5.2 A Simple DAE of Index 2
5.2.1 Solving the DAEs in General Implicit Form
5.2.2 Solving the DAEs in Linearly Implicit Form
5.3 A Nonlinear Implicit ODE
5.4 A DAE of Index 3: The Pendulum Problem
5.5 Multibody Systems
5.5.1 The Car Axis Problem
5.6 Electrical Circuit Models
5.6.1 The Transistor Amplifier
5.7 Exercises
5.7.1 A Simple DAE
5.7.2 The Robertson Problem
5.7.3 The Pendulum Problem Revisited
5.7.4 The Akzo Nobel Problem
5.7.4.1 Problem Formulation
5.7.4.2 Task
References
6
Chapter 6 Delay Differential Equations
6.1 Delay Differential Equations
6.1.1 DDEs with Delays of the Dependent Variables
6.1.2 DDEs with Delays of the Derivatives
6.2 Difficulties when Solving DDEs
6.2.1 Discontinuities in DDEs
6.2.2 Small and Vanishing Delays
6.3 Numerical Methods for Solving DDEs
References
7
Chapter 7 Solving Delay Differential Equations in R
7.1 Delay Differential Equation Solvers in R
7.2 Two Simple Examples
7.2.1 DDEs Involving Solution Delay Terms
7.2.2 DDEs Involving Derivative Delay Terms
7.3 Chaotic Production of White Blood Cells
7.4 A DDE Involving a Root Function
7.5 Vanishing Time Delays
7.6 Predator-Prey Dynamics with Harvesting
7.7 Exercises
7.7.1 The Lemming Model
7.7.2 Oberle and Pesch
7.7.3 An Epidemiological Model
7.7.4 A Neutral DDE
7.7.5 Delayed Cellular Neural Networks With Impulses
References
8
Chapter 8 Partial Differential Equations
8.1 Partial Differential Equations
8.1.1 Alternative Formulations
8.1.2 Polar, Cylindrical and Spherical Coordinates
8.1.3 Boundary Conditions
8.2 Solving PDEs
8.3 Discretising Derivatives
8.3.1 Basic Diffusion Schemes
8.3.1.1 Non-negativity of Diffusion Schemes
8.3.2 Basic Advection Schemes
8.3.2.1 Stability
8.3.2.2 Non-negativity of Advection Schemes
8.3.3 Flux-Conservative Discretisations
8.3.4 More Complex Advection Schemes
8.3.4.1 Advection of a Square Pulse
8.3.4.2 Time Step Conditions
8.3.4.3 Flux Limiters
8.4 The Method Of Lines
8.5 The Finite Difference Method
References
9
Chapter 9 Solving Partial Differential Equations in R
9.1 Methods for Solving PDEs in R
9.1.1 Numerical Approximations
9.1.1.1 Setting up a Grid
9.1.1.2 Numerical Approximation of Advection and Diffusion
9.1.2 Solution Methods
9.2 Solving Parabolic, Elliptic and Hyperbolic PDEs in R
9.2.1 The Heat Equation
9.2.1.1 Problem Definition
9.2.1.2 Solving the Heat Equation in R
9.2.2 The Wave Equation
9.2.2.1 Problem Definition
9.2.2.2 Solving the Wave Equation in R
9.2.3 Poisson and Laplace's Equation
9.2.3.1 Problem Definition
9.2.3.2 Solving the Laplace Equation in R
9.2.4 The Advection Equation
9.2.4.1 Problem Definition
9.2.4.2 Solving the Advection Equation in R
9.3 More Complex Examples
9.3.1 The Brusselator in One Dimension
9.3.2 The Brusselator in Two Dimensions
9.3.3 Laplace Equation in Polar Coordinates
9.3.4 The Time-Dependent 2-D Sine-Gordon Equation
9.3.5 The Nonlinear Schrödinger Equation
9.4 Exercises
9.4.1 The Gray-Scott Equation
9.4.2 A Macroscopic Model of Traffic
9.4.3 A Vibrating String
9.4.4 A Pebble in a Bucket of Water
9.4.5 Combustion in 2-D
References
10
Chapter 10 Boundary Value Problems
10.1 Two-Point Boundary Value Problems
10.2 Characteristics of Boundary Value Problems
10.2.1 Uniqueness of Solutions
10.2.2 Isolation of Solutions
10.2.3 Stiffness of Boundary Value Problemsand Dichotomy
10.2.4 Conditioning of Boundary Value Problems
10.2.5 Singular Problems
10.3 Boundary Conditions
10.3.1 Separated Boundary Conditions
10.3.2 Defining Good Boundary Conditions
10.3.3 Problems Defined on an Infinite Interval
10.4 Methods of Solution
10.5 Shooting Methods for Two-Point BVPs
10.5.1 The Linear Case
10.5.2 The Nonlinear Case
10.5.3 Multiple Shooting
10.6 Finite Difference Methods
10.6.1 A Low Order Method for Second Order Equations
10.6.2 Other Low Order Methods
10.6.3 Higher Order Methods Based on Collocation Runge-Kutta Schemes
10.6.4 Higher Order Methods Based on Mono Implicit Runge-Kutta Formulae
10.6.5 Higher Order Methods Based on Linear Multistep Formulae
10.6.6 Deferred Correction
10.7 Codes for the Numerical Solution of BoundaryValue Problems
References
11
Chapter 11 Solving Boundary Value Problems in R
11.1 Boundary Value Problem Solvers in R
11.2 A Simple BVP Example
11.2.1 Implementing the BVP in First Order Form
11.2.2 Implementing the BVP in Second Order Form
11.3 A More Complex BVP Example
11.4 More Complex Initial or End Conditions
11.5 Solving a Boundary Value Problem Using Continuation
11.5.1 Manual Continuation
11.5.2 Automatic Continuation
11.6 BVPs with Unknown Constants
11.6.1 The Elastica Problem
11.6.2 Non-separated Boundary Conditions
11.6.3 An Unknown Integration Interval
11.7 Integral Constraints
11.8 Sturm-Liouville Problems
11.9 A Reaction Transport Problem
11.10 Exercises
11.10.1 A Stiff Boundary Value Problem
11.10.2 The Mathieu Equation
11.10.3 Another Swirling Flow Problem
11.10.4 Another Reaction Transport Problem
References
bbm_978-3-642-28070-2_1
Appendix A
A.1 Butcher Tableaux for Some Runge-Kutta Methods
A.2 Coefficients for Some Linear Multistep Formulae
A.3 Implemented Integration Methods for Solving Initial Value Problems in R
A.4 Other Integration Methods in R
References
Index