behavior of runge-kutta function rk in single step operation inside loop



On 09-07-2013 07:24, Volker van Nek wrote:
> With a by 1e-15 slightly extended range the steps are as expected.
>
> soln2 : rk (-'n, 'n, n, ['t, t, t+dt+1e-15, dt]);
>
> I draw the conclusion that rk cannot guarantee that the right end of 
> the range is always reached. Don't know if this a bug or a typical 
> numerical problem.
Hi,
I'm aware of that and I always regarded it as a feature related to 
floating point representation, so I usually use binary values for dt: 
1/2, 1/4, 1/8, 1/16,... However, now I remember that when I made the new 
version of makelist I had to deal with the same issue. Thus, to be 
consistent with makelist, I will consider this as a bug report and will 
fix rk to make it consistent with makelist:

(%i1) makelist(i,i,0,0.2,0.1);
(%o1) [0, 0.1, 0.2]
(%i2) rk(-n,n,1,[t,0,0.2,0.1]);
(%o2) [[0.0, 1.0], [0.1, 0.9048375], [0.2, .8187309014062499]]

(%i3) makelist(i,i,0,0.3,0.1);
(%o3) [0, 0.1, 0.2, 0.3]
(%i4) rk(-n,n,1,[t,0,0.3,0.1]);
(%o4) [[0.0, 1.0], [0.1, 0.9048375], [0.2, .8187309014062499]]

Regards,
Jaime