You are previewing Numerical Analysis Using R.
O'Reilly logo
Numerical Analysis Using R

Book Description

This book presents the latest numerical solutions to initial value problems and boundary value problems described by ODEs and PDEs. The author offers practical methods that can be adapted to solve wide ranges of problems and illustrates them in the increasingly popular open source computer language R, allowing integration with more statistically based methods. The book begins with standard techniques, followed by an overview of 'high resolution' flux limiters and WENO to solve problems with solutions exhibiting high gradient phenomena. Meshless methods using radial basis functions are then discussed in the context of scattered data interpolation and the solution of PDEs on irregular grids. Three detailed case studies demonstrate how numerical methods can be used to tackle very different complex problems. With its focus on practical solutions to real-world problems, this book will be useful to students and practitioners in all areas of science and engineering, especially those using R.

Table of Contents

  1. Cover
  2. Half title
  3. Title
  4. Copyright
  5. Dedication
  6. Table of Contents
  7. Preface
  8. 1 ODE Integration Methods
    1. 1.1 Introduction
    2. 1.2 Euler Methods
      1. 1.2.1 Forward Euler
      2. 1.2.2 Backward Euler
    3. 1.3 Runge–Kutta Methods
      1. 1.3.1 RK Coefficients
      2. 1.3.2 Variable Step Size Methods
      3. 1.3.3 SHK: Sommeijer, Van Der Houwen, and Kok Method
    4. 1.4 Linear Multistep Methods (LMMs)
      1. 1.4.1 General
      2. 1.4.2 Backward Differentiation Formulas (BDFs)
      3. 1.4.3 Numerical Differentiation Formulas (NDFs)
      4. 1.4.4 Convergence
      5. 1.4.5 Adams Methods
    5. 1.5 Truncation Error and Order of Integration
      1. 1.5.1 LMM Truncation Error
      2. 1.5.2 Verification of Integration Order
    6. 1.6 Stiffness
    7. 1.7 How to Choose a Numerical Integrator
    8. 1.A Installation of the R Package Ryacas
    9. 1.B Installation of the R Package rSymPy
    10. References
  9. 2 Stability Analysis of ODE Integrators
    1. 2.1 General
      1. 2.1.1 Dahlquist Barrier Theorems
    2. 2.2 Dahlquist Test Problem
    3. 2.3 Euler Methods
      1. 2.3.1 Forward Euler
      2. 2.3.2 Backward Euler
    4. 2.4 Runge–Kutta Methods
      1. 2.4.1 RK-1: First-Order Runge–Kutta
      2. 2.4.2 RK-2: Second-Order Runge–Kutta
      3. 2.4.3 RK-4: Fourth-Order Runge–Kutta
      4. 2.4.4 RKF-54: Fehlberg Runge–Kutta
      5. 2.4.5 SHK: Sommeijer, van der Houwen, and Kok
    5. 2.5 Linear Multistep Methods (LMMs)
      1. 2.5.1 General
      2. 2.5.2 Backward Differentiation Formulas (BDFs)
      3. 2.5.3 Numerical Differentiation Formulas (NDFs)
      4. 2.5.4 Adams Methods
    6. References
  10. 3 Numerical Solution of PDEs
    1. 3.1 Some PDE Basics
    2. 3.2 Initial and Boundary Conditions
    3. 3.3 Types of PDE Solutions
    4. 3.4 PDE Subscript Notation
    5. 3.5 A General PDE System
    6. 3.6 Classification of PDEs
    7. 3.7 Discretization
      1. 3.7.1 General Finite Difference Terminology
      2. 3.7.2 The Mesh
      3. 3.7.3 Nonuniform Grid Spacing
      4. 3.7.4 The Courant–Friedrichs–Lewy Number
      5. 3.7.5 The Stencil
      6. 3.7.6 Upwinding
    8. 3.8 Method of Lines (MOL)
      1. 3.8.1 Introduction
      2. 3.8.2 Finite Difference Matrices
      3. 3.8.3 MOL 1D: Cartesian Coordinates
      4. 3.8.4 MOL 2D: Cartesian Coordinates
      5. 3.8.5 MOL 2D: Polar Coordinates
    9. 3.9 Fully Discrete Methods
      1. 3.9.1 Introduction
      2. 3.9.2 Overview of Some Common Schemes
      3. 3.9.3 Results from Simulating a Hyperbolic Equation
    10. 3.10 Finite volume method
      1. 3.10.1 General
      2. 3.10.2 Application to a 1D Conservative System
      3. 3.10.3 Application to a General Conservation Law
    11. 3.11 Interpretation of Results
      1. 3.11.1 Verification
      2. 3.11.2 Validation
      3. 3.11.3 Truncation Error
    12. 3.A Appendix: Derivative Matrix Coefficients
      1. 3.A.1 First Derivative Schemes
      2. 3.A.2 Second Derivative Schemes
      3. 3.A.3 Third Derivative Schemes
      4. 3.A.4 Fourth Derivative Schemes
    13. 3.B Appendix: Derivative Matrix Library
      1. 3.B.1 Example
    14. References
  11. 4 PDE Stability Analysis
    1. 4.1 Introduction
    2. 4.2 The Well-Posed PDE Problem
    3. 4.3 Matrix Stability Method
      1. 4.3.1 Semi-Discrete Systems
    4. 4.4 Von Neumann Stability Method
      1. 4.4.1 General
      2. 4.4.2 Fully Discrete Systems
      3. 4.4.3 Semi-Discrete Systems
    5. 4.5 Unstructured Grids
    6. 4.A Fourier Transforms
    7. References
  12. 5 Dissipation and Dispersion
    1. 5.1 Introduction
    2. 5.2 Dispersion Relation
    3. 5.3 Amplification Factor
    4. 5.4 Dissipation
    5. 5.5 Dispersion
    6. 5.6 Dissipation and Dispersion Errors
      1. 5.6.1 The 1D Advection Equation, Semi-Discrete Upwind
      2. 5.6.2 The 1D Advection Equation, Semi-Discrete Second-Order Upwind
      3. 5.6.3 The 1D Advection Equation, Fully Discrete Upwind
      4. 5.6.4 The 1D Advection Equation, Fully Discrete Lax–Friedrichs (LxF)
    7. 5.7 Group and Phase Velocities
      1. 5.7.1 Exact Relationships for the Basic PDE
      2. 5.7.2 Semi-Discrete, First-Order Upwind Discretization
      3. 5.7.3 Semi-Discrete Leapfrog Discretization
      4. 5.7.4 Fully Discrete Leapfrog Discretization
    8. 5.8 Modified PDEs
    9. References
  13. 6 High-Resolution Schemes
    1. 6.1 Introduction
    2. 6.2 The Riemann Problem
    3. 6.3 Total Variation Diminishing (TVD) Methods
      1. 6.3.1 TVD Numerical Integration
    4. 6.4 Godunov Method
      1. 6.4.1 Godunov’s Theorem
    5. 6.5 Flux Limiter Method
      1. 6.5.1 How Limiters Work
      2. 6.5.2 Limiter Functions
    6. 6.6 Monotone Upstream-Centered Schemes for Conservation Laws (MUSCL)
      1. 6.6.1 Linear Reconstruction
      2. 6.6.2 Kurganov and Tadmor Central Scheme
      3. 6.6.3 Piecewise Parabolic Reconstruction
      4. 6.6.4 Solutions to the Euler Equations
    7. 6.7 Weighted Essentially Nonoscillatory (WENO) Method
      1. 6.7.1 Polynomial Reconstruction: Finite Volume Approach
      2. 6.7.2 Polynomial Coefficients
      3. 6.7.3 Polynomial Reconstruction: Finite Difference Reconstruction
      4. 6.7.4 WENO Reconstruction
      5. 6.7.5 Alternative Calculation for Substencil Coefficients
      6. 6.7.6 Weights
      7. 6.7.7 Smoothness Indicators
      8. 6.7.8 Calculation of Smoothness Indicator Coefficients
      9. 6.7.9 Flux Splitting
      10. 6.7.10 Implementation of a WENO Finite Volume Scheme
      11. 6.7.11 Scalar Problems
      12. 6.7.12 Euler Equation Problems
      13. 6.7.13 2D Examples
    8. 6.8 Further Reading
    9. 6.A Eigenvalues of Euler Equations
    10. 6.B R Code for Simulating 1D Scalar Equation Problems
      1. 6.B.1 The Main Program
      2. 6.B.2 The Derivative Function
      3. 6.B.3 The MUSCL Function
      4. 6.B.4 Initialization
    11. 6.C R Code for Simulating 1D Euler Equations Problems
      1. 6.C.1 The Main Routine
      2. 6.C.2 Initialization
      3. 6.C.3 The Derivative Function
      4. 6.C.4 The MUSCL Function
      5. 6.C.5 Postsimulation Calculations
    12. References
  14. 7 Meshless Methods
    1. 7.1 Introduction
    2. 7.2 Radial Basis Functions (RBF)
      1. 7.2.1 Positive Definite RBFs
      2. 7.2.2 RBF with Compact Support (CSRBF)
    3. 7.3 Interpolation
      1. 7.3.1 Interpolation Example: 1D
      2. 7.3.2 Interpolation Example: 2D
      3. 7.3.3 Larger Interpolation Example: 2D
      4. 7.3.4 Interpolation Example: 3D
      5. 7.3.5 Interpolation with Polynomial Precision
    4. 7.4 Differentiation
      1. 7.4.1 Derivative Example: 1D
    5. 7.5 Local RBFs
      1. 7.5.1 Allocating Stencil Nodes
      2. 7.5.2 Choosing the Right Shape Parameter Value
    6. 7.6 Application to Partial Differential Equations
      1. 7.6.1 Explicit Euler Integration
      2. 7.6.2 Weighted Average Integration
      3. 7.6.3 Method of Lines
      4. 7.6.4 With Nonlinear Terms
      5. 7.6.5 Initial Conditions (ICs) and Boundary Conditions (BCs)
      6. 7.6.6 Stability Considerations
      7. 7.6.7 Time-Dependent PDEs
      8. 7.6.8 Time-Independent PDEs
    7. 7.A Franke’s Function
    8. 7.B Halton Sequence
    9. 7.C RBF Definitions
    10. References
  15. 8 Conservation Laws
    1. 8.1 Introduction
    2. 8.2 Korteweg–de Vries (KdV) Equation
      1. 8.2.1 The First Conservation Law, u
      2. 8.2.2 The Second Conservation Law, u[sup(2)]
      3. 8.2.3 The Third Conservation Law, u[sup(3)] + ½u[sup(2)][sub(x)]
      4. 8.2.4 Another Conservation Law
      5. 8.2.5 An Infinity of Conservation Laws
      6. 8.2.6 KdV Equation: 2D
      7. 8.2.7 KdV Equation with Variable Coefficients (vcKdV)
    3. 8.3 Conservation Laws for Other Evolutionary Equations
      1. 8.3.1 Nonlinear Schrödinger Equation
      2. 8.3.2 Boussinesq Equation
    4. 8.A Symbolic Algebra Computer Source Code
    5. References
  16. 9 Case Study: Analysis of Golf Ball Flight
    1. 9.1 Introduction
    2. 9.2 Drag Force
    3. 9.3 Magnus Force
    4. 9.4 Gravitational Force
    5. 9.5 Golf Ball Construction
    6. 9.6 Ambient Conditions
    7. 9.7 The Shot
      1. 9.7.1 Golf Ball Compression
      2. 9.7.2 Spin
      3. 9.7.3 Launch Angle
      4. 9.7.4 Bounce and Roll
      5. 9.7.5 Shot Statistics
    8. 9.8 Completing the Mathematical Description
      1. 9.8.1 The Effect of Wind
    9. 9.9 Computer Simulation
      1. 9.9.1 Driver Shots
      2. 9.9.2 Wood Shots
      3. 9.9.3 Iron Shots
      4. 9.9.4 Effect of Wind
      5. 9.9.5 Effect of Differing Ambient Conditions
      6. 9.9.6 Effect of Push/Pull and Inclined Golf Ball Spin Axis
      7. 9.9.7 Drag/Lift Carry Test
      8. 9.9.8 Drag Effect at Ground Level
    10. 9.10 Computer Code
      1. 9.10.1 Main Program
      2. 9.10.2 Derivative Function
      3. 9.10.3 Initial Conditions
    11. References
  17. 10 Case Study: Taylor–Sedov Blast Wave
    1. 10.1 Brief Background to the Problem
    2. 10.2 System Analysis
    3. 10.3 Some Useful Gas Law Relations
    4. 10.4 Shock Wave Conditions
    5. 10.5 Energy
    6. 10.6 Photographic Evidence
    7. 10.7 Trinity Site Conditions
    8. 10.8 Numerical Solution
    9. 10.9 Integration of PDEs
    10. 10.A Appendix: Similarity Analysis
    11. 10.B Appendix: Analytical Solution
      1. 10.B.1 Closed-Form Solution
      2. 10.B.2 Additional Complexity
      3. 10.B.3 The Los Alamos Primer
    12. References
  18. 11 Case Study: The Carbon Cycle
    1. 11.1 Introduction
    2. 11.2 The Model
      1. 11.2.1 Atmosphere
      2. 11.2.2 Oceans
      3. 11.2.3 Air–Ocean Exchange
      4. 11.2.4 Carbonate Chemistry
      5. 11.2.5 Acidity of Surface Seawater
      6. 11.2.6 Ocean Circulation
      7. 11.2.7 Emission Profiles
      8. 11.2.8 Earth’s Radiant Energy Balance
      9. 11.2.9 How the Atmosphere is Affected by Radiation
    3. 11.3 Simulation Results
      1. 11.3.1 Carbon Buildup in the Atmosphere
      2. 11.3.2 Carbon Buildup in Surface Seawater and Accompanying Acidification
      3. 11.3.3 Surface Temperature Changes
    4. 11.A Appendices
      1. 11.A.1 Model Differential Equations
      2. 11.A.2 Correlations for Chemical Equilibrium and Dissociation Constants
      3. 11.A.3 Revelle and Uptake Factors
      4. 11.A.4 Residence Time
      5. 11.A.5 Mass Action
      6. 11.A.6 The Electromagnetic Spectrum
    5. References
  19. Appendix: A Mathematical Aide-Mémoire
  20. Index