# [SciPy-user] integrate.odeint and simultaniuos equations

Warren Weckesser warren.weckesser@gmail....
Tue Jan 20 23:00:18 CST 2009

```Scott,

I added an example with two degrees of freedom to the SciPy wiki, in this
"cookbook" entry:
http://www.scipy.org/Cookbook/CoupledSpringMassSystem
A system with two degrees of freedom (and no constraints) will result in a
four dimensional state space; you will have a system of four first order
differential equations.  This is what Bastian Weber pointed out at the end

Best regards,

Warren

On Tue, Jan 20, 2009 at 6:34 AM, Scott Askey <scotta_2002@yahoo.com> wrote:

> Do ode and odeint work in multiple dimensions?
>
> I could not any examples with more than one degree of freedom.  And from
> the doc string it how to solve simultaneous  ode's was not obvious.  The
> code for modelling a 2d simple harmonic oscillator or spherical pendulum
> would give me the insight I need.
>
> I found and understand the following 1 D harmonic oscillator model from the
> scipy cookbook.
>
> V/R
>
> Scott
>
>
>
> from scipy import *
> from pylab import *
> deriv = lambda y,t : array([y[1],-y[0]-.1*y[1]])#xdot,x2dot
> # Integration parameters
> start=0
> end=10
> numsteps=10000
> time=linspace(start,end,numsteps)
> from scipy import integrate
> y0=array([0.0005,0.2]) #x,x_dot
> y=integrate.odeint(deriv,y0,time)
> plot(time,y[:,0])#x,xdot
> show()
>
>
>
>
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20090120/a9dc1b02/attachment.html
```