hi everyone, is there any numeric multivariable ode solver in sage? i want to solve the double pendulum problem, so i need to solve 4 first order differential equations which deppends on theta1(t) amd thetha2(t). I need something like a multivariable runge kutta algorithm
Most of Sage's numerics is done via Numpy/Scipy which is included in Sage and usable from the Sage Notebook. To solve an ODE using Scipy first reduce your problem to a system of 1st degree ODEs: $u'(x,y,t) = f(t,x,y,u)$. Then, follow the instructions on the relevant Scipy documentation: Ordinary differential equations (odeint). The key components to solving the numerical ODE is (1) writing a Python function for the right-hand side, $f$, (2) writing a function for its Jacobian, $J_f$, (3) and calling the scipy.integrate.odeint function.
Consult the scipy.integrate.odeint documentation for more information on its use. You can read this documentation by entering
Finally, I providing the Jacobian for your problem is an optional argument but it helps with convergence.
Another option is to use the function desolve_odeint (from version 4.6 on, see the docs on desolve_odeint?), which uses the odeint solver internally, but takes as an input symbolic funcions . For instance, to integrate the Lorenz attractor, you would do
to plot the attractor, simply:
I do not know what you mean exactly by the double pendulum, but here it is something similar:
and a nice plot is here
posted Mar 03 '11Joaquim Puig
171 ● 5 ● 9
i make it! using desolvesystemrk4[w1,w2,aw1,aw2],[s1,s2,w1,w2],ics=[0,0.5,0,0.0,0.5],ivar=t,step=0.01,end_points=20)
I compared these results with the results from a maple worksheet that i downloaded from internet and they match very well. The Sage's speed is very good
But i would like to learn how to use odeint from scipy and ode_solver from gsl to solve this system :S
I just started to using Sage 3 days ago and i love it. Thanks!
posted Aug 19 '10ngativ
83 ● 1 ● 6 ● 15
Asked: Aug 19 '10
Seen: 544 times
Last updated: Mar 03 '11
powered by ASKBOT version 0.7.22
Copyright Sage, 2010. Some rights reserved under creative commons license.