[Tutor] hi

Oscar Benjamin oscar.j.benjamin at gmail.com
Mon Aug 12 23:00:42 CEST 2013


On 12 August 2013 21:32, Vick <vick1975 at orange.mu> wrote:
>> From: Oscar Benjamin [mailto:oscar.j.benjamin at gmail.com]
>> Sent: Monday, 12 August, 2013 20:42
>
>> Are you able to access this paper (link at the bottom)?
>
> [Vick] yes. But the formula seems unfamiliar to me. And I really can't
> understand what with the compact writing and small letters.

Yeah, I'm not old enough to have seen the days when people wrote
equations with typewriters so it looks strange to me as well.

>>
>> I believe this is the original source for the coefficients you are using.
> They
>> describe constructing a system of linear rational equations for the
>> coefficients of the method. I think that the equations must be satisfied
> for
>> any 13-stage explicit RK method that has an 8th-order with embedded 7th-
>> order method. Solving the equations leads to a solution space with 10
>> degrees of freedom.
>
> [Vick] You are telling only half the story...it looks like we have to write
> up over 230 equations or so.

Well you don't actually have to write them out by hand. You would use
loops in a script to compute the coefficients for the equations. But
yes it seems like too much work for me right now and I don't think it
would really help you that much so I wouldn't bother.

>> Much as I would love to see those coefficients, for your own sake it would
> be
>> a lot easier to just use an Adams-Bashforth integrator.
>> Here's a stripped down script that can compute the exact coefficients for
> any
>> arbitrary order:
>>
>  [Vick] It looks as though your code is using some form of polynomial and if
> I'm not mistaken is it the legendre polynomial?

Yes, that's my own code for doing algebra with polynomials. You can
see the explanation for using polynomials to get the coefficients
here:
http://en.wikipedia.org/wiki/Linear_multistep_method#Adams.E2.80.93Bashforth_methods

> I'm not sure what your code is really doing as I'm not an expert programmer.
> What I need is to get an explanation with example of what some things are
> supposed to be doing and then if I have understood correctly I will try to
> code it on my own using my own coding capabilities. I think it's better if I
> start work with the standard rk4 method as it has the same properties as the
> dopri8. You make heavy use of scipy and numpy and the other modules in
> python, so I guess you are a seasoned programmer in python so we are really
> not on the same page with regard to understanding coding. My code shows that
> I have done the rk4 and dopri8 from scratch without using the modules in
> python except of course for mpmath. It would do me no good if I have to use
> a function in coding which I really don't understand.

It depends what you mean by "don't understand". Truthfully I don't
know how scipy's odeint works. I have a general understanding of how
integration methods work and I know that it does a good job. The
important thing is not so much that you understand all of the code in
question but that you know how to check the accuracy of the results
yourself.

> It seems that I got you interested in DOPRI8 after all. You said you have a
> collection of integrators. What are they, just to compare notes! Actually
> the best or most efficient and most accurate I know about for ODEs is the
> Gauss Jackson 8th order method (GJ8), but I don't have it. The second most
> powerful is the RKN12 this is the runge kutta Nystrom 12th order but it is
> useful only for 2nd order ODEs and as I haven't any use for it I haven't
> completed its coding, but I do have its rational coefficients. Then the
> third most efficient is the DOPRI8(7)13, the one you just got interested in.
> With regard to integration (area under a curve) the best I know is the
> tanh-sinh quadrature and I have it coded. Anyway it is also built in mpmath.
> The second best is Gauss-Konrod but I don't have it and the third one is the
> Gauss-legendre which I have also. And then there are the lesser orders like
> Boole rule, Simpson's rule etc, even in their adaptive forms.

As I've said before, comparisons between different integrators are
actually quite subjective. The most significant difference between the
methods you have just described is between the stable implicit methods
for stiff problems and unstable explicit methods for non-stiff
problems. That difference is fundamental.

Otherwise the arguments about which is better are, as I said before,
implicitly tied to certain assumptions about how you write your code.
The fact that (as shown by decimal rk4 script) the simplest methods
can achieve arbitrarily small errors (if you're prepared to wait for
the output) means that there is no clear definition of the "best
integrator". In fact one strong assumption that is often made
implicitly is that you're using something like C or Fortran and that
you're definitely not using Python! Since you've already broken that
assumption you can't rely on the common wisdom about which integrator
better than which other.

> Well just send me some tutorial on how to build and obtain the coefficients
> for the butcher tableau for the RK4 as an example, and after I've mastered
> it, I'd give the dopri8 a shot.

I am up for it so I'll see if I can find time to write a script that
shows how to do it.


Oscar


More information about the Tutor mailing list