Skip to main content
15-Moonstone
December 31, 2014
Solved

Odesolve vs. Rkadapt

  • December 31, 2014
  • 1 reply
  • 2276 views

Curious minds want to know: I am solving a simple (linear) ode for a number of various parameters. When I use Odesolve, passing the various parameters, it runs relatively slowly compared with using Rkadapt passing the parameters via the initial conditions (since I have a lot of cases to look at, using Rkadapt seems the better choice). Why is this? Is it typical?

Best answer by Werner_E

John Rudnicki wrote:

Curious minds want to know: I am solving a simple (linear) ode for a number of various parameters. When I use Odesolve, passing the various parameters, it runs relatively slowly compared with using Rkadapt passing the parameters via the initial conditions (since I have a lot of cases to look at, using Rkadapt seems the better choice). Why is this? Is it typical?

The way you use the solve block function you force the solve block to be evaluated for every single point which is plotted and that are quite a few.

If you precalculate the odesolve function just once with the parameters needed and use this I guess its equally fast (apart from the effort the odesolve solution has to put into interpolating).

See attached.

1 reply

Werner_E25-Diamond IAnswer
25-Diamond I
December 31, 2014

John Rudnicki wrote:

Curious minds want to know: I am solving a simple (linear) ode for a number of various parameters. When I use Odesolve, passing the various parameters, it runs relatively slowly compared with using Rkadapt passing the parameters via the initial conditions (since I have a lot of cases to look at, using Rkadapt seems the better choice). Why is this? Is it typical?

The way you use the solve block function you force the solve block to be evaluated for every single point which is plotted and that are quite a few.

If you precalculate the odesolve function just once with the parameters needed and use this I guess its equally fast (apart from the effort the odesolve solution has to put into interpolating).

See attached.

15-Moonstone
December 31, 2014

Thanks. That makes sense. And thanks for your help on various other problems and questions. Happy New Year.

25-Diamond I
December 31, 2014

John Rudnicki wrote:

Thanks. That makes sense. And thanks for your help on various other problems and questions. Happy New Year.

You are welcome!

The remarkable part is the difference in results, even if you chose "Adaptive" for odesolve. At max more than 2%. Not sure why.

Happy New Year! (6 hours to go 😉

1.png