0

Is there a built-in second order explicit Runge Kutta scheme in GSL? I am aware that the gsl_odeiv2_step_rk2 function is an explicit embedded Runge-Kutta (2, 3) method, which converges to a 3rd order scheme for all the tests I have performed.

Can anyone confirm (or correct) me on this please?

Also can anyone please point me towards an EXPLICIT 2nd order RK step type in GSL for using with the adaptive step control?

Boken
  • 4,825
  • 10
  • 32
  • 42
  • This would essentially be an Euler method with Richardson extrapolation (which essentially produces the expl. midpoint method). Or use directly the Heun method as second order method where the step size controller is based on the first order Euler step as the embedded method. This kind of error estimate in these low orders is very unstable and not really worth the effort. I tried the first in https://stackoverflow.com/a/49320327/3088138, I'm not sure how generally useful the parameters of the controller there are. – Lutz Lehmann Jul 15 '20 at 13:31
  • Thanks @LutzLehmann. I was actually hoping there might be an existing step type in GSL. I have coded a second order scheme myself already so if there isn't any available in GSL I might as well use that! I wanted to use it for performing a comparison between second order adaptive implicit and explicit schemes for different problems. – Samyukta Venkat Jul 15 '20 at 15:19
  • Per http://www.stochasticlifestyle.com/comparison-differential-equation-solver-suites-matlab-r-julia-python-c-fortran/ the gsl solver suite is, to say it lightly, sub-optimal. Boost-odeint is slightly better. As that analysis is from 2017, things may have changed, but I would expect that the boost library is more actively developed. – Lutz Lehmann Jul 15 '20 at 16:29
  • @LutzLehmann I have actually used the Boost-odient Custom RK stepper quite a bit actually. The source code for all the steppers are available and we can actually customise them very easily. It is a very user-friendly/customisable library! – Samyukta Venkat Jul 16 '20 at 09:57

1 Answers1

0

Yes, gsl_odeiv2_step_rk2 uses a 3rd order Runge-Kutta method that contains the explicit midpoint method as embedded method. Similar extensions exist for the Heun method and Ralston method, see the 3rd order methods page in https://www.math.auckland.ac.nz/~butcher/ODE-book-2008/Tutorials/low-order-RK.pdf

The GSL implementation uses the extrapolation variant which is the "wrong" implementation for the basic idea behind the step size control. This basic idea is that the error of the method gets estimated by an estimate using a higher order method, the step size is then adapted so that asymptotically the estimated error converges towards the requested error level. The "correct" way to implement this is thus to take the 2nd order midpoint update, not the 3rd order update.

Or in other words, with the extrapolation variant, while it uses a higher order method and thus gives in general a lower error, there is no lower bound of the actual error relative to the error tolerances, and related to this, there is no guarantee that the steps are taken optimally for the order of the method and requested error level.

Lutz Lehmann
  • 25,219
  • 2
  • 22
  • 51