Solving Differential Equations in R: Package deSolve

In this paper we present the R package <b>deSolve</b> to solve initial value problems (IVP) written as ordinary differential equations (ODE), differential algebraic equations (DAE) of index 0 or 1 and partial differential equations (PDE), the latter solved using the method of lines appro...

Full description

Bibliographic Details
Main Authors: Karline Soetaert, Thomas Petzoldt, R. Woodrow Setzer
Format: Article
Language:English
Published: Foundation for Open Access Statistics 2010-02-01
Series:Journal of Statistical Software
Subjects:
Online Access:http://www.jstatsoft.org/v33/i09/paper
_version_ 1818128661399732224
author Karline Soetaert
Thomas Petzoldt
R. Woodrow Setzer
author_facet Karline Soetaert
Thomas Petzoldt
R. Woodrow Setzer
author_sort Karline Soetaert
collection DOAJ
description In this paper we present the R package <b>deSolve</b> to solve initial value problems (IVP) written as ordinary differential equations (ODE), differential algebraic equations (DAE) of index 0 or 1 and partial differential equations (PDE), the latter solved using the method of lines approach. The differential equations can be represented in R code or as compiled code. In the latter case, R is used as a tool to trigger the integration and post-process the results, which facilitates model development and application, whilst the compiled code significantly increases simulation speed. The methods implemented are efficient, robust, and well documented public-domain Fortran routines. They include four integrators from the <b>ODEPACK</b> package (LSODE, LSODES, LSODA, LSODAR), DVODE and DASPK2.0. In addition, a suite of Runge-Kutta integrators and special-purpose solvers to efficiently integrate 1-, 2- and 3-dimensional partial differential equations are available. The routines solve both stiff and non-stiff systems, and include many options, e.g., to deal in an efficient way with the sparsity of the Jacobian matrix, or finding the root of equations. In this article, our objectives are threefold: (1) to demonstrate the potential of using R for dynamic modeling, (2) to highlight typical uses of the different methods implemented and (3) to compare the performance of models specified in R code and in compiled code for a number of test cases. These comparisons demonstrate that, if the use of loops is avoided, R code can efficiently integrate problems comprising several thousands of state variables. Nevertheless, the same problem may be solved from 2 to more than 50 times faster by using compiled code compared to an implementation using only R code. Still, amongst the benefits of R are a more flexible and interactive implementation, better readability of the code, and access to R’s high-level procedures. <b>deSolve</b> is the successor of package <b>odesolve</b> which will be deprecated in the future; it is free software and distributed under the GNU General Public License, as part of the R software project.
first_indexed 2024-12-11T07:36:48Z
format Article
id doaj.art-19b72c411eae4c8ea93696d25ae3a3f2
institution Directory Open Access Journal
issn 1548-7660
language English
last_indexed 2024-12-11T07:36:48Z
publishDate 2010-02-01
publisher Foundation for Open Access Statistics
record_format Article
series Journal of Statistical Software
spelling doaj.art-19b72c411eae4c8ea93696d25ae3a3f22022-12-22T01:15:41ZengFoundation for Open Access StatisticsJournal of Statistical Software1548-76602010-02-013309Solving Differential Equations in R: Package deSolveKarline SoetaertThomas PetzoldtR. Woodrow SetzerIn this paper we present the R package <b>deSolve</b> to solve initial value problems (IVP) written as ordinary differential equations (ODE), differential algebraic equations (DAE) of index 0 or 1 and partial differential equations (PDE), the latter solved using the method of lines approach. The differential equations can be represented in R code or as compiled code. In the latter case, R is used as a tool to trigger the integration and post-process the results, which facilitates model development and application, whilst the compiled code significantly increases simulation speed. The methods implemented are efficient, robust, and well documented public-domain Fortran routines. They include four integrators from the <b>ODEPACK</b> package (LSODE, LSODES, LSODA, LSODAR), DVODE and DASPK2.0. In addition, a suite of Runge-Kutta integrators and special-purpose solvers to efficiently integrate 1-, 2- and 3-dimensional partial differential equations are available. The routines solve both stiff and non-stiff systems, and include many options, e.g., to deal in an efficient way with the sparsity of the Jacobian matrix, or finding the root of equations. In this article, our objectives are threefold: (1) to demonstrate the potential of using R for dynamic modeling, (2) to highlight typical uses of the different methods implemented and (3) to compare the performance of models specified in R code and in compiled code for a number of test cases. These comparisons demonstrate that, if the use of loops is avoided, R code can efficiently integrate problems comprising several thousands of state variables. Nevertheless, the same problem may be solved from 2 to more than 50 times faster by using compiled code compared to an implementation using only R code. Still, amongst the benefits of R are a more flexible and interactive implementation, better readability of the code, and access to R’s high-level procedures. <b>deSolve</b> is the successor of package <b>odesolve</b> which will be deprecated in the future; it is free software and distributed under the GNU General Public License, as part of the R software project.http://www.jstatsoft.org/v33/i09/paperordinary differential equationspartial differential equationsdifferential algebraic equationsinitial value problemsRFortranC
spellingShingle Karline Soetaert
Thomas Petzoldt
R. Woodrow Setzer
Solving Differential Equations in R: Package deSolve
Journal of Statistical Software
ordinary differential equations
partial differential equations
differential algebraic equations
initial value problems
R
Fortran
C
title Solving Differential Equations in R: Package deSolve
title_full Solving Differential Equations in R: Package deSolve
title_fullStr Solving Differential Equations in R: Package deSolve
title_full_unstemmed Solving Differential Equations in R: Package deSolve
title_short Solving Differential Equations in R: Package deSolve
title_sort solving differential equations in r package desolve
topic ordinary differential equations
partial differential equations
differential algebraic equations
initial value problems
R
Fortran
C
url http://www.jstatsoft.org/v33/i09/paper
work_keys_str_mv AT karlinesoetaert solvingdifferentialequationsinrpackagedesolve
AT thomaspetzoldt solvingdifferentialequationsinrpackagedesolve
AT rwoodrowsetzer solvingdifferentialequationsinrpackagedesolve