rkf45 included in next release?



On 03/01/2012 10:06 PM, Robert Dodier wrote:
> OK, I'm working on including rkf45 in Maxima share.
> I remember this came up some months ago and people
> seemed generally happy about including it.
>
> Thanks to Panagiotis Papasotiriou for his work on this topic.

Thank you Robert,

I noticed in the code the use of "endcons" to accumulate the results 
into a list, which for large numbers of steps (and I am doing > 15k 
steps in my case) would give a slow result as it should grow as O(n^2). 
Surprisingly the function is still quite fast compared to rk, thanks to 
its superior algorithmic step size choice, but the usual method in these 
types of cases is to cons onto the front of list and then reverse the 
list right before returning it.

The following patch does just that, and in my testing seemed to work:


--- rkf45.mac.orig	2012-03-02 10:10:54.726724001 -0800
+++ rkf45.mac	2012-03-02 10:10:49.530724001 -0800
@@ -139,7 +139,7 @@
        xi:xc+h,
        yi:yi+1.157407407407407e-1*k1+5.489278752436647e-1*k3
             +5.353313840155946e-1*k4-0.2*k5,
-      if save_steps then sol:endcons(cons(xi,yi),sol),
+      if save_steps then sol:cons(cons(xi,yi),sol),
        estimated_errors[1]:min(trunc_error,estimated_errors[1]),
        estimated_errors[2]:max(trunc_error,estimated_errors[2]),
        step_extrema[1]:min(h,step_extrema[1]),
@@ -180,6 +180,6 @@
      print("                accuracy, and/or increase maximum number of 
steps.")
    ),
    /* Return solution */
-  return(sol)
+  return(reverse(sol))
  )$
 
/*----------------------------------------------------------------------------*/