plotdf questions: tstep, Runge-Kutta and singular points
Subject: plotdf questions: tstep, Runge-Kutta and singular points
From: Jaime Villate
Date: Fri, 19 Apr 2013 12:51:51 +0100
On 04/18/2013 08:11 PM, Ilya Schurov wrote:
> I believe that the docs should be updated to avoid such questions in the future.
you're right.
>
> As far as I understand, in order to keep length of the segment fixed
> in the phase space, you have to divide your tstep by the length of the
> vector of the vector field in current point (it's just a guess, I
> didn't check the code),
The current method is the following: the length of the x and y intervals
are divided by 200 to give sx and sy (the displacement we'd like to have
in phase space is sqrt(sx^2+sy^2) ).
If the phase velocity in a point is (ux, uy), the tstep for that point
is calculated by the following equation:
tstep = 1 / sqrt ((ux/sx)^2 + (uy/sy)^2))
> and therefore you have instability near theequilibrium point.
You're right.
> Is it really necessary to keep this length strictly fixed? I mean, why not just say something like
>
> tstep=tstep0/max(vmin, len(v))
I see to problems with that approach: the value of vmin (or tmin or
something else) would have to be given by the user because it is not
easy to find a good estimate automatically and in the regions where the
phase velocity is almost constant, the trajectory would move very slowly
(with velocity vmin) making the algorithm as inefficient as it was when
a fixed value of tstep was used.
I think that the major problem near the equilibrium points is not only
that the phase velocity is small but that it changes direction abruptly.
What I was planning to do is to detect those abrupt changes of direction
to triger the end of the trajectory. But I will try out your suggestion
anyway.
>
> Sorry for stupid questions :)
not at all.
>
> Actually, I really appreciate plotdf functionality (I'm encouraging my
> ODE students to use Maxima to draw phase portraits during they study),
> and I'd be happy if I'll be able to help it to become even better :)
> Equilibrium points are crucial in ODE study, you know.
Good. I appreciate any help and comments.
>
> (Unfortunately, I'm not familiar with Lisp at the moment.)
plotdf is written in Tcl. The lisp part is just a front end that
prepares the expressions and options into a form that Tcl can
understand. You can see the source code for the current Runge-Kutta
algorithm in:
interfaces/xmaxima/Tkmaxima/rk4.tcl
In the same directory I also kept the original programs of William
Shelter, which are not being used:
interfaces/xmaxima/Tkmaxima/Rk.tcl
interfaces/xmaxima/Tkmaxima/Adams.tcl
Best regards,
Jaime
>
> On Thu, Apr 18, 2013 at 10:41 PM, Jaime Villate <villate at fe.up.pt> wrote:
>> Hi,
>> ?'m sorry that the documentation is outdated. The adaptive step Runge-Kutta
>> method is now used always and therefore, the tstep value is ignored; the
>> value of tstep will changed in order to keep steps with a fixed
>> length in the phase plane. That method introduces the instabilities that you
>> have seen near the equilibrium points; I have some ideas to improve that
>> behavior in future versions, but in the meantime I suggest that
>> you try using the option direction -> forward (either add
>> [direction,forward] in the plotdf command, or changing
>> it in the menu); that way the trajectories will not move back to the
>> equilibrium point. You can also try changing
>> the value of nsteps.
>> Regards,
>> Jaime
>>
>>
>>
>> On 04/18/2013 05:46 PM, Ilya Schurov wrote:
>>> Hi there,
>>>
>>> I have some problems with plotdf command. I'd like to plot some nice
>>> phase portraits of singular points. However, it seems that integration
>>> algorithm becomes inaccurate near singular points (e.g. nodes).
>>>
>>> Here is an example.
>>>
>>> plotdf([x**2-y,log(1-x+x**2)-log(3)],[x,1,3],[y,3,5]);
>>>
>>> The output looks like this:
>>>
>>> http://schurov.com/maximassode.png
>>>
>>> One can see artifacts near the singular point.
>>>
>>> I tried to overcome this issue by setting tstep parameter as described
>>> in the docs (http://maxima.sourceforge.net/docs/manual/de/maxima_66.html).
>>> However, it seems that the system simply ignores tstep parameter. At
>>> least, I tried commands
>>>
>>> plotdf([x**2-y,log(1-x+x**2)-log(3)],[x,1,3],[y,3,5],[tstep,100000]);
>>>
>>> and
>>>
>>> plotdf([x**2-y,log(1-x+x**2)-log(3)],[x,1,3],[y,3,5],[tstep,0.000001]);
>>>
>>> I believe that the first command should give very inaccurate picture,
>>> and the second one have to produce much more accurate pictures. In
>>> fact, they are identical to each other. Note also, that I do not have
>>> "tstep" parameter in the "Plot setup" window.
>>>
>>> The other idea was to switch to Runge-Kutta method. The docs says it's
>>> possible ("The Adams Moulton method is used for the integration; it is
>>> also possible to switch to an adaptive Runge-Kutta 4th order method"),
>>> but I didn't found such an option in the options list.
>>>
>>> Version of my Maxima:
>>>
>>> Maxima 5.29.1 http://maxima.sourceforge.net
>>> using Lisp SBCL 1.0.55.0.debian
>>>
>>> Any ideas?
>>>
>>> --
>>> With best regards,
>>> Ilya V. Schurov.
>>> _______________________________________________
>>> Maxima mailing list
>>> Maxima at math.utexas.edu
>>> http://www.math.utexas.edu/mailman/listinfo/maxima
>>
>
>