I am a bit confused with odeint
.
I found one example below to solve y"=ay + by'
. So it seems that y[0]
is the function, y[1]
is the first derivative.
So does the following expression mean y[1] =y'
and y'[1]= a*y[0]+b*y[1]
?
If it were y[2], a*y[0]+b*y[1]
, what would it mean?
I am a bit confused since the expression does not say the left hand side of the equation.
I also encountered expressions like [a(y[0], y[1]), b(y[0], y[1])]
but have no clue of the differential equation.
Here is one example:
from scipy.integrate import odeint
from pylab import * # for plotting commands
def deriv(y,t): # return derivatives of the array y
a = -2.0
b = -0.1
return array([ y[1], a*y[0]+b*y[1] ])
time = linspace(0.0,10.0,1000)
yinit = array([0.0005,0.2]) # initial values
y = odeint(deriv,yinit,time)
figure()
plot(time,y[:,0])
xlabel('t')
ylabel('y')
show()