On 29 lis, 02:47, Marshall Hampton <[email protected]> wrote:
> I think that's probably a bug.  As far as I know, the ode_solver code
> hasn't been used all that much.  When I have personally wanted to
> numerically solve ODEs I have just written my own Runge-Kutta 4th
> order solvers in Cython.  If no one else chimes in I will file a
> ticket for that.
>

It will be in next Sage, see http://trac.sagemath.org/sage_trac/ticket/6479
It is done via Maxima, perhaps other way could be faster.

Robert


from the patch:

        844     def desolve_rk4(de, dvar, ics=None, ivar=None, end_points=None,
step=0.1, output='list', **kwds):
        845         """
        846         Solves numerically one first-order ordinary differential
equation.
        847
        848         INPUT:
        849             input is similar to desolve command. The differential
equation can be
        850             written in a form close to the plot_slope_field or
desolve command
        851
        852             Variant 1 (function in two variables)
        853             de   -- right hand side, i.e. the function f(x,y) from
ODE y'=f(x,y)
        854             dvar -- dependent variable (symbolic variable declared
by var)
        855
        856             Variant 2 (symbolic equation)
        857             de   -- equation, including term with diff(y,x)
        858             dvar -- dependent variable (declared as funciton of
independent variable)
        859
        860             Other parameters
        861             ivar  -- should be specified, if there are more
variables or if the equation is autonomous
        862             ics   -- initial conditions in the form [x0,y0]
        863             end_points  -- the end points of the interval
        864                if end_points is a or [a], we integrate on between 
min
(ics[0],a) and max(ics[0],a)
        865                if end_points is None, we use end_points=ics[0]+10
        866                if end_points is [a,b] we integrate on between 
min(ics
[0],a) and max(ics[0],b)
        867             step   -- the length of the step (positive number)
        868             output -- 'list', 'plot', 'slope_field' (graph of the
solution with slope field)
        869
        870
        871         OUTPUT:
        872             Returns a list of points, or plot produced by list_plot,
optionally with slope field.
        873
        874
        875         EXAMPLES:
        876             sage: from sage.calculus.desolvers import desolve_rk4
        877
        878         Variant 2 for input - more common in numerics
        879
        880             sage: x,y=var('x y')
        881             sage: desolve_rk4(x*y*(2-y),y,ics=
[0,1],end_points=1,step=0.5)
        882             [[0, 1], [0.5, 1.12419127425], [1.0, 1.46159016229]]
        883
        884         Variant 1 for input - we can pass ODE in the form used by
        885         desolve function In this example we integrate bakwards,
since
        886         end_points < ics[0]
        887
        888             sage: y=function('y',x)
        889             sage: desolve_rk4(diff(y,x)+y*(y-1) == x-2,y,ics=
[1,1],step=0.5, end_points=0)
        890             [[0.0, 8.90425710896], [0.5, 1.90932794536], [1, 1]]
        891
        892         Here we show how to plot simple pictures. For more advanced
aplications use
        893         list_plot instead. To see the resulting picture use show(P)
in Sage notebook.
        894
        895             sage: x,y=var('x y')
        896             sage: P=desolve_rk4(y*(2-y),y,ics=
[0,.1],ivar=x,output='slope_field',end_points=[-4,6],thickness=3)
        897
        898         ALGORITHM:
        899             4th order Runge-Kutta method. Wrapper for command rk in
Maxima's dynamics package.
        900             Perhaps could be faster by using fast_float instead.



-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to