Quantcast

More accurate ODE solver?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

More accurate ODE solver?

tn85
Dear All,

I was using rk4 and lsoda to solve a ODE system. However, both of them gave
bad accurate solutions, especially compared with Matlab solver ODE45. For
example, ODE45 gave solutions that can go to a stable level (about 1.6) when
time goes to infinity, however, the solutions from lsoda are decreasing to
very very small (about 1e-130) numbers.

Does R have more accurate ODE solvers as ODE45 in Matlab?

Thank you,
Jane

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: More accurate ODE solver?

bbolker
Tianchan Niu <niu <at> isis.georgetown.edu> writes:

>
> Dear All,
>
> I was using rk4 and lsoda to solve a ODE system. However, both of them gave
> bad accurate solutions, especially compared with Matlab solver ODE45. For
> example, ODE45 gave solutions that can go to a stable level (about 1.6) when
> time goes to infinity, however, the solutions from lsoda are decreasing to
> very very small (about 1e-130) numbers.
>
> Does R have more accurate ODE solvers as ODE45 in Matlab?

  See ?rkMethods in the deSolve package. You could try

rk(..., method="ode45")

or otherwise try playing with the tolerances.
Without a reproducible example, it's pretty much impossible to
say what the precise problem is.  It's mildly surprising (although
I am *not* a numerical analyst) that the default 'lsoda' solver
doesn't work well.

  At least in the general description of the algorithm,
method="ode45" is the same as MATLAB's algorithm, although it's
entirely possible that the default tolerances, details of the
implementation, etc., have been tuned differently in the two
packages (since MATLAB is closed-source, we can't tell what the
precise details are).

  It would be interesting to know where the actual problem lies
(different tolerance setting, ode45 vs lsoda, MATLAB vs R implementation);
can you report on your findings and/or post a reproducible example?

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Loading...