Skip to main content
15-Moonstone
Dec 31, 2014 3:44 PM UTC
Solved

Odesolve vs. Rkadapt

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?

Werner_E
Werner_EAnswer
25-Diamond I
Dec 31, 2014 4:53 PM UTC

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.

3 replies

Werner_E
Werner_E25-Diamond IAnswer
25-Diamond I
Dec 31, 2014 4:53 PM UTC

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.

Translate
15-Moonstone
Dec 31, 2014 5:04 PM UTC

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

Translate
Werner_E
25-Diamond I
Dec 31, 2014 5:19 PM UTC

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

Translate