Re: Differential Equations on the 49G+ and 50G Message #17 Posted by Les Wright on 3 May 2007, 9:25 p.m., in response to message #4 by JM Baillard
Quote:
It seems difficult to do faster in RPL
I've written an 'RK8' program for the HP48
that uses an 8thorder RungeKutta method
and it yields almost the same results in 65s
with stepsize = 0.1 but there is no errorestimate.
Actually, I have learned that if I can spare a couple of extra minutes on a problem your RK8 method applied twice can generate rough error estimates.
As an 8th order method, stepsize halving should (in theory) roughly improve the error by a factor of 2^8 = 1/256. This means if I run the problem twice with stepsize 2h and then stepzize h, the difference in results can give a rough measure of the estimated error for each run. I won't regurgitate the algebra, which is actually not too difficult, but it seems to me that the error of the 2h run is of the order of 256/255 times this difference, and the error of the h run is roughly the difference divided by 255.
I have experimented with this with some simple problems and find that the error estimates are actually pretty good, especially in those admittedly ideal situations where the analytical solution of the DE is nice and smooth and continuous with an infinity of well behaved higher derivatives that make the Taylor series upon which the error estimates are based a reasonable approximation of reality. The bottom line is that the difference between two runs can yield some meaningful information, and, if one is willing to take the time, one can get a sense of the result the solution is approaching.
I must confess that I do in some cases like routines such as this one where the number of iterations are set a priori by me, since I know it is going to end some time! Adaptive schemes that converge according to some desired tolerance may actually never converge, or take for ever. I would prefer to know as soon as possible whether a particular problem is stiff or just illposed.
I think your RK8 is in some ways a desirable alternative to the HP48/49 series builtin RKF45 adaptive solver. I am also impressed at how well it ports to these calculators, and how quickly I was able to get it onto my calculator via SD card. The HP41 version is excellent too, but is of course slower and really requires a card reader or extended memory so that one need only enter and store all of those constants once. I also think it would well on the HP42Sthe constants can be stored and saved in a vector and swapped for the REGS variable as required. But I would have to hope like heck not to reset the memory at my next battery swap!
Les
Edited: 3 May 2007, 9:27 p.m.
