Abstract
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.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsNotes
- 1.
A more robust but slightly more complex method is to put parameters in a parameter vector, and pass that to the derivative function via ode’s argument parms. For models that are to be used to fit parameters to data, this is the most convenient way of passing parameters.
- 2.
it is the most common mistake that beginners make.
- 3.
Here it is worthwhile to point to the difference of the letter “O” and the number “0” in the definition of yini; many strange behaviors of DE models are due to mistyping O and 0.
References
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.
Aris, R. (1965). Introduction to the analysis of chemical reactors. Englewood Cliffs: Prentice Hall.
Bogacki, P., & Shampine, L. F. (1989). A 3(2) pair of Runge–Kutta formulas. Applied Mathematics Letters, 2, 1–9.
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.
Brugnano, L., & Magherini, C. (2004). The BiM code for the numerical solution of ODEs. Journal of Computational and Applied Mathematics, 164–165, 145–158.
Cash, J. R., & Considine, S. (1992). An MEBDF code for stiff initial value problems. ACM Transactions on Mathematical Software, 18(2), 142–158.
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.
Dormand, J. R., & Prince, P. J. (1980). A family of embedded Runge–Kutta formulae. Journal of Computational and Applied Mathematics, 6, 19–26.
Dormand, J. R., & Prince, P. J. (1981). High order embedded Runge–Kutta formulae. Journal of Computational and Applied Mathematics, 7, 67–75.
Fehlberg, E. (1967). Klassische Runge–Kutta formeln funfter and siebenter ordnung mit schrittweiten-kontrolle. Computing (Arch. Elektron. Rechnen), 4, 93–106.
Hairer, E., & Wanner, G. (1996). Solving ordinary differential equations II: Stiff and differential-algebraic problems. Heidelberg: Springer.
Hairer, E., Norsett, S. P., & Wanner, G. (2009). Solving ordinary differential equations I: Nonstiff problems (2nd rev. ed.). Heidelberg: Springer.
Hindmarsh, A. C. (1980). LSODE and LSODI, two new initial value ordinary differential equation solvers. ACM-SIGNUM Newsletter , 15, 10–11.
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.
Hundsdorfer, W., & Verwer, J. G. (2003). Numerical solution of time-dependent advection-diffusion-reaction equations. Springer series in computational mathematics. Berlin: Springer.
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).
Ligges, U., & Mächler, M. (2003). Scatterplot3d–an R package for visualizing multivariate data. Journal of Statistical Software, 8(11), 1–20.
Lorenz, E. N. (1963). Deterministic non-periodic flows. Journal of Atmospheric Sciences, 20, 130–141.
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.
Press, W. H., Teukolsky, S. A., Vetterling, W. T., & Flannery, B. P. (2007). Numerical recipes (3rd ed). Cambridge: Cambridge University Press.
Reddy, M., Yang, R. S., Andersen, M. E., & Clewell, H. J., III (2005). Physiologically based pharmacokinetic modeling: Science and applications. Hoboken: Wiley.
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.
Rossler, O. E. (1976). An equation for continous chaos. Physics Letters A, 57(5), 397–398.
Shampine, L. F. (1994). Numerical solution of ordinary differential equations. New York: Chapman and Hall.
Shampine, L. F., Gladwell, I., & Thompson, S. (2003). Solving ODEs with MATLAB. Cambridge: Cambridge University Press.
Soetaert, K., Petzoldt, T., & Setzer, R. W. (2010). Solving differential equations in R: Package deSolve. Journal of Statistical Software, 33(9), 1–25.
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.
Verhulst, P. (1838). Notice sur la loi que la population poursuit dans son accroissement. Correspondance Mathematique et Physique, 10, 113–121.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2012 Springer-Verlag Berlin Heidelberg
About this chapter
Cite this chapter
Soetaert, K., Cash, J., Mazzia, F. (2012). Solving Ordinary Differential Equations in R. In: Solving Differential Equations in R. Use R!. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-28070-2_3
Download citation
DOI: https://doi.org/10.1007/978-3-642-28070-2_3
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-28069-6
Online ISBN: 978-3-642-28070-2
eBook Packages: Mathematics and StatisticsMathematics and Statistics (R0)