Subject: Initial- and boundary-value problems in Maxima.
From: Richard Fateman
Date: Fri, 09 Sep 2011 09:00:24 -0700
On 9/9/2011 3:22 AM, Jaime Villate wrote:
> On Fri, 2011-09-09 at 13:08 +0300, Gregor Berman wrote:
>
>> I am looking for a decent Maxima numerical solver for initial-value
>> problems, with adaptive step size and error control. As far I can
>> tell, Maxima only has function rk() for this, but rk() is an
>> implementation of a rather elementary 4th-order Runge-Kutta method,
>> with constant step size and no error control. Such an algorithm is
>> definitely not suitable for serious work.
>> I am aware of excellent initial-value solvers implemented in Fortran,
>> most notably LSODAR (included in ODEPACK), which I use extensively in
>> my Fortran programs (it is also included in Scilab). I wonder if I can
>> use something similar in Maxima. If not, any decent solver for
>> initial-value problems will do. The only way I can think is to use
>> Maxima within Scilab, but I am looking for a neat Maxima way.
> Hi,
> the main focus of Maxima has been symbolic computations rather than
> numerical methods. rk was made just to let first-year undergraduate
> students play around with the Runge-Kutta method without getting lost
> with programming details. However, it should be easy to replace the 4th
> order Runge-Kutta method by any other method you want.
>
> You can find the Maxima code for rk() at the last 27 lines in the file:
> [Maxima-root]/share/dynamics/dynamics.mac
>
> Feel free to ask me for any help you need with the code.
>
> Regards,
>
> Jaime Villate
> (author of rk)
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
Jaime's code in dynamics.mac looks rather nice. If the changes
needed to make it "decent" are to add adaptive step size and
error control, it would be great to add that.
If the term "decent" in Gregor Berman's original post
also means "much faster" then a different tactic may be necessary.
Typically this means writing out the function-evaluation parts into
fortran-syntax files, compiling them and linking with fortran
programs, and communicating with Maxima / plotting/ etc. This
kind of setup has been used in the past, but tends to be more
delicate -- for example, not all of the operating systems/lisps
that support Maxima will manage such connections to fortran in
the same way. Also, the programs that spew out fortran syntax
may not be as sophisticated as needed.
An intermediate possibility exists, which is to use lisp
rather than Maxima language / [even compiled Maxima language]
which should be considerably faster.
There are other points to note: the arithmetic in Maxima can be
altered to be higher precision, and so the treatment of sensitive
parts of the solver can be modified to take smaller steps and also
do the arithmetic to (arbitrarily) high precision if this would
help.
RJF