R by Example: Numerical Solutions to Differential Equations
March/April 2013 (Vol. 15, No. 2) pp. 6-7
1521-9615/13/$31.00 © 2013 IEEE

Published by the IEEE Computer Society
R by Example: Numerical Solutions to Differential Equations
  Article Contents  
  Reference  
Download Citation
   
Download Content
 
PDFs Require Adobe Acrobat
 

Karline Soetaert, Jeff Cash, and Francesca Mazzia, Solving Differential Equations in R, Springer, 2012, ISBN: 978-3-642-28069-6, 248 pp.

Here, John Ludlam provides his analysis of a book about the free and open source software R, which offers numerical solutions to differential equations.

This book is a practical guide for obtaining numerical solutions to differential equations in the popular (and free) open source software R. Differential equations are important in fields as diverse as physics, biology, and oceanography, but much of the software for solving differential equations is either difficult to use or expensive. R is a relatively easy-to-use environment that can be freely downloaded at www.r-project.org. R is being widely adopted for statistical analysis and modeling in a variety of disciplines, including my field of ecology. 1
Much of the functionality of R is contained in user-contributed "packages." The first author of this book (Karline Soetaert) is also a coauthor of several packages for solving differential equations in R: deSolve, rootSolve, and bvpSolve. In Solving Differential Equations in R, the focus is on demonstrating how these packages are used to solve a wide variety of differential equations.
After an introductory chapter on differential equations and methods to solve them, the book covers ordinary differential equations, differential algebraic equations, delay differential equations, partial differential equations, and boundary value problems. Chapters alternate between introductions to the mathematical theory and practical techniques for solving each type of differential equation in R. Each chapter that focuses on R examples ends with a number of practice exercises.
I should point out that this book isn't an introduction to the R language and environment (if that's what you need, see other titles in the same Use R! series from Springer). It also isn't a general introduction to the mathematics of differential equations. Rather, it's a useful reference for practicing scientists and graduate students who need solutions to differential equations. Additionally, it includes numerous references to relevant literature throughout the book if you need more information on a particular topic.
The strongest part of the book is the five chapters of example problems in R. I wish I had this book in graduate school, where I spent quite a few frustrating hours learning how to get R to do what I needed. The first chapter of examples in this book (chapter 3) covers what I needed then in just a few pages. Each example chapter walks the reader through the provided R code in detail and explains what each part of the code does. It also includes helpful tips on the nuts and bolts of solving differential equations. For example, guidelines are given for choosing the appropriate numerical method (from the many options implemented in these packages) for a problem, as well as ways to determine if the method is working well. Common potential errors are highlighted where necessary. Finally, R has excellent graphical capabilities, and the examples include useful tips for producing publication-quality graphics.
To demonstrate the range of problems covered by this book, I will highlight some of the contents of the chapter on ordinary differential equations (chapter 3). This chapter begins with a simple model of logistic growth, and then it moves to a model with multiple variables. The chapter also includes stiff problems, which require different techniques to solve them because different time scales are present in the system. In an example of ozone chemistry, solar radiation time series data are included as an external variable into the model. Models with discontinuous events are described, including models where the event's timing is known beforehand (for example, a pill or drug injection given every day) and where events depend on conditions within the model (such as a bouncing ball). Switching functions that change model behavior (for example, the temperature in a room with a heater controlled by a thermostat) are also described.
As a biologist rather than a mathematician, I found the theory chapters to be less accessible and helpful than the example chapters. Also, because the authors chose to segregate theory and examples into separate chapters, the coverage of some topics felt disjointed. However, I think that separating the chapters was a good decision, because it lets readers quickly focus on the content most relevant to them.
I was pleased to find that all the R code used in the book is available on the publisher's website in nicely organized code. Novice R users should make sure that any data files are in the current working directory, and that required packages are installed before running the R code.
Ris a powerful and flexible environment for solving differential equations. This book provides a good introduction to several packages capable of solving a wide range of differential equations. Overall, this book is probably best suited for those who know what they want from their equations, but aren't sure how to get there in R.

Reference

John Ludlam is an assistant professor of biology at Fitchburg State University, Massachusetts, and he uses R to solve differential equations and for statistical analysis. His research interests include aquatic ecology and conservation. Ludlam has a PhD in biology from the University of Arkansas. Contact him at jludlam@fitchburgstate.edu.