behavior of runge-kutta function rk in single step operation inside loop
Subject: behavior of runge-kutta function rk in single step operation inside loop
From: Edwin Woollett
Date: Wed, 10 Jul 2013 12:22:18 -0700
On July 9, 2013, 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.
--------------------------------------
Thanks for the work-around, which works for me and gives me
rk output that when plotted with points style is positioned
more clearly than if I used dt = 1/8 = 0.125.
By the way, redefining dt with the extra increment 1e-15 at the
start doesn't cure the problem:
=====================
(%i1) [dt, tv, nv] : [0.1+1e-15, 0, 1];
(%o1) [0.1,0,1]
(%i2) for j thru 5 do
(print (j),
soln2 : rk (-n, n, nv, [t, tv, tv + dt, dt]),
print (soln2),
soln1 : second (soln2),
print (soln1),
tv : soln1[1],
nv : soln1[2],
display (tv, nv))$
1
[[0.0,1.0],[0.1,0.904837]]
[0.1,0.904837]
tv = 0.1
nv = 0.904837
2
[[0.1,0.904837],[0.2,0.818731]]
[0.2,0.818731]
tv = 0.2
nv = 0.818731
3
[[0.2,0.818731],[0.3,0.740818]]
[0.3,0.740818]
tv = 0.3
nv = 0.740818
4
[[0.3,0.740818]]
second: no such element in [[0.3,0.740818]]
-- an error. To debug this try: debugmode(true);
==================
I have to put the 1e-15 into rk instead as you suggest:
================
(%i3) [dt, tv, nv] : [0.1, 0, 1];
(%o3) [0.1,0,1]
(%i4) for j thru 5 do
(print (j),
soln2 : rk (-n, n, nv, [t, tv, tv + dt + 1e-15, dt]),
print (soln2),
soln1 : second (soln2),
print (soln1),
tv : soln1[1],
nv : soln1[2],
display (tv, nv))$
1
[[0.0,1.0],[0.1,0.904837]]
[0.1,0.904837]
tv = 0.1
nv = 0.904837
2
[[0.1,0.904837],[0.2,0.818731]]
[0.2,0.818731]
tv = 0.2
nv = 0.818731
3
[[0.2,0.818731],[0.3,0.740818]]
[0.3,0.740818]
tv = 0.3
nv = 0.740818
4
[[0.3,0.740818],[0.4,0.67032]]
[0.4,0.67032]
tv = 0.4
nv = 0.67032
5
[[0.4,0.67032],[0.5,0.606531]]
[0.5,0.606531]
tv = 0.5
nv = 0.606531
=============================
On July 9, 2013, Jaime Villate wrote:
-------------------------
> ...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:
---------------------------
As I mention above, I prefer dt = 0.1 rather than dt = 1/8 since plotting
output in points style with dt = 0.1 is easier to read on the plot.
I would be interested in a patch for this present problem with rk.
I am now running the windows 5.30 binary, with your correction for
line 268 of complex_dynamics.lisp incorporated.
Ted