我與odeint
有點混淆。使用scipy odeint求解耦合微分方程的系統
我在下面找到一個例子來解決y"=ay + by'
。所以看起來y[0]
是函數,y[1]
是第一個導數。
那麼下列表達式是否意味着y[1] =y'
和y'[1]= a*y[0]+b*y[1]
?
如果是y[2], a*y[0]+b*y[1]
,這是什麼意思?
我有點困惑,因爲表達式並沒有說方程的左邊。
我也遇到過像[a(y[0], y[1]), b(y[0], y[1])]
這樣的表達式,但沒有線性的微分方程。
下面是一個例子:
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()
我找到答案,方程應以下列方式表示:Y1 '= Y2,Y2'= Y3,...,YN'= F(X,.. ),只有方程的右邊必須給出解微分方程。 – pappu 2012-02-06 21:30:33