Solving Ordinary Differential Equations in R

  • Karline Soetaert
  • Jeff Cash
  • Francesca Mazzia
Part of the Use R! book series (USE R)


Both Runge-Kutta and linear multistep methods are available to solve initial value problems for ordinary differential equations in the R packages deSolve and deTestSet. Nearly all of these solvers use adaptive step size control, some also control the order of the formula adaptively, or switch between different types of methods, depending on the local properties of the equations to be solved. We show how to trigger the various methods using a variety of applications pointing, where necessary, to problems that may arise. For instance, many practical applications involve discontinuities. As the integration routines assume that a solution is sufficiently differentiable over a time step, handing such discontinuities requires special consideration. We give examples of how we can implement a nonsmooth forcing term, switching behavior, and problems that include sudden jumps in the dependent variables. Since much computational efficiency can be gained by using the correct method for a particular problem, we end this chapter by providing a few guidelines as to how the most efficient solution method for a particular problem can be found.


Nitrogen Oxide Root Function Derivative Function Stiff Problem Linear Multistep Method 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


  1. 1.
    Arenstorf, R. F. (1963). Periodic solutions of the restricted three-body problem representing analytic continuations of Keplerian elliptic motions. American Journal of Mathematics, 85, 27–35.Google Scholar
  2. 2.
    Aris, R. (1965). Introduction to the analysis of chemical reactors. Englewood Cliffs: Prentice Hall.Google Scholar
  3. 3.
    Bogacki, P., & Shampine, L. F. (1989). A 3(2) pair of Runge–Kutta formulas. Applied Mathematics Letters, 2, 1–9.Google Scholar
  4. 4.
    Brown, P. N., Byrne, G. D., & Hindmarsh, A. C. (1989). VODE, a variable-coefficient ODE solver. SIAM Journal on Scientific and Statistical Computing, 10, 1038–1051.Google Scholar
  5. 5.
    Brugnano, L., & Magherini, C. (2004). The BiM code for the numerical solution of ODEs. Journal of Computational and Applied Mathematics, 164–165, 145–158.Google Scholar
  6. 6.
    Cash, J. R., & Considine, S. (1992). An MEBDF code for stiff initial value problems. ACM Transactions on Mathematical Software, 18(2), 142–158.Google Scholar
  7. 7.
    Cash, J. R., & Karp, A. H. (1990). A variable order Runge–Kutta method for initial value problems with rapidly varying right-hand sides. ACM Transactions on Mathematical Software, 16, 201–222.Google Scholar
  8. 8.
    Dormand, J. R., & Prince, P. J. (1980). A family of embedded Runge–Kutta formulae. Journal of Computational and Applied Mathematics, 6, 19–26.Google Scholar
  9. 9.
    Dormand, J. R., & Prince, P. J. (1981). High order embedded Runge–Kutta formulae. Journal of Computational and Applied Mathematics, 7, 67–75.Google Scholar
  10. 10.
    Fehlberg, E. (1967). Klassische Runge–Kutta formeln funfter and siebenter ordnung mit schrittweiten-kontrolle. Computing (Arch. Elektron. Rechnen), 4, 93–106.Google Scholar
  11. 11.
    Hairer, E., & Wanner, G. (1996). Solving ordinary differential equations II: Stiff and differential-algebraic problems. Heidelberg: Springer.Google Scholar
  12. 12.
    Hairer, E., Norsett, S. P., & Wanner, G. (2009). Solving ordinary differential equations I: Nonstiff problems (2nd rev. ed.). Heidelberg: Springer.Google Scholar
  13. 13.
    Hindmarsh, A. C. (1980). LSODE and LSODI, two new initial value ordinary differential equation solvers. ACM-SIGNUM Newsletter , 15, 10–11.Google Scholar
  14. 14.
    Hindmarsh, A. C. (1983). ODEPACK, a systematized collection of ODE solvers. In R. Stepleman (Ed.), Scientific computing: Vol. 1. IMACS transactions on scientific computation (pp. 55–64). Amsterdam: IMACS/North-Holland.Google Scholar
  15. 15.
    Hundsdorfer, W., & Verwer, J. G. (2003). Numerical solution of time-dependent advection-diffusion-reaction equations. Springer series in computational mathematics. Berlin: Springer.Google Scholar
  16. 16.
    Iavernaro, F., & Mazzia, F. (1998). Solving ordinary differential equations by generalized Adams methods: Properties and implementation techniques. Applied Numerical Mathematics, 28(2–4), 107–126. Eighth conference on the numerical treatment of differential equations (Alexisbad, 1997).Google Scholar
  17. 17.
    Ligges, U., & Mächler, M. (2003). Scatterplot3d–an R package for visualizing multivariate data. Journal of Statistical Software, 8(11), 1–20.Google Scholar
  18. 18.
    Lorenz, E. N. (1963). Deterministic non-periodic flows. Journal of Atmospheric Sciences, 20, 130–141.Google Scholar
  19. 19.
    Petzold, L. R. (1983). Automatic selection of methods for solving stiff and nonstiff systems of ordinary differential equations. SIAM Journal on Scientific and Statistical Computing, 4, 136–148.Google Scholar
  20. 20.
    Press, W. H., Teukolsky, S. A., Vetterling, W. T., & Flannery, B. P. (2007). Numerical recipes (3rd ed). Cambridge: Cambridge University Press.Google Scholar
  21. 21.
    Reddy, M., Yang, R. S., Andersen, M. E., & Clewell, H. J., III (2005). Physiologically based pharmacokinetic modeling: Science and applications. Hoboken: Wiley.Google Scholar
  22. 22.
    Robertson, H. H. (1966). The solution of a set of reaction rate equations. In J. Walsh (Ed.), Numerical analysis: An introduction (pp. 178–182). London: Academic Press.Google Scholar
  23. 23.
    Rossler, O. E. (1976). An equation for continous chaos. Physics Letters A, 57(5), 397–398.Google Scholar
  24. 24.
    Shampine, L. F. (1994). Numerical solution of ordinary differential equations. New York: Chapman and Hall.Google Scholar
  25. 25.
    Shampine, L. F., Gladwell, I., & Thompson, S. (2003). Solving ODEs with MATLAB. Cambridge: Cambridge University Press.Google Scholar
  26. 26.
    Soetaert, K., Petzoldt, T., & Setzer, R. W. (2010). Solving differential equations in R: Package deSolve. Journal of Statistical Software, 33(9), 1–25.Google Scholar
  27. 27.
    van Dorsselaer, J. L. M., & Spijker, M. N. (1994). The error committed by stopping the newton iteration in the numerical solution of stiff initial value problems. IMA journal of Numerical Analysis, 14, 183–209.Google Scholar
  28. 28.
    Verhulst, P. (1838). Notice sur la loi que la population poursuit dans son accroissement. Correspondance Mathematique et Physique, 10, 113–121.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2012

Authors and Affiliations

  • Karline Soetaert
    • 1
  • Jeff Cash
    • 2
  • Francesca Mazzia
    • 3
  1. 1.Department Ecosystem StudiesRoyal Netherlands Institute for Sea ResearchYersekeThe Netherlands
  2. 2.MathematicsImperial CollegeLondonUK
  3. 3.Dipartimento di MatematicaUniversity of BariBariItaly

Personalised recommendations