from scipy.integrate import odeint from pylab import * # for plotting commands def deriv(x,t): # return derivatives of the array y a = -2.0 b = -0.1 return array([ x[1], a*x[0]+b*x[1]]) time = linspace(0.0,100.0,1000) xinit = array([0.0005,0.2]) # initial values x = odeint(deriv,xinit,time) figure() plot(time,x[:,0]) # x[:,0] is the first column of x xlabel('t') ylabel('x') show() from scipy.integrate import odeint from pylab import * # for plotting commands def deriv(z,t): # return derivatives of the array y a = -0.1 b = 0.2 c = 0.1 return array([z[1], a*z[2], z[3], b+c*z[1]]) time = linspace(0.0,10.0,1000) zinit = array([0,0.2,0,0.1]) # initial values z = odeint(deriv,zinit,time) figure() plot(time,z[:,0],label='x') # z[:,0] is the first column of z plot(time,z[:,2],label='y') # z[:,2] is the third column of z xlabel('t') legend(loc='upper left') show()