我试图用以下代码求解ivp y'=-y-5*exp(-t)*sin(5t),y(0)=1:
%pylab inline
%matplotlib inline
from scipy.integrate import odeint
def mif(t, y):
return -y-5*exp(-t)*sin(5*t)
tspan = np.arange(0, 3, 0.000001)
y0 = 1.0
y_result = odeint(mif, y0, tspan)
y_result = y_result[:, 0] # convert the returned 2D array to a 1D array
plt.figure()
plt.plot(tspan, y_result)
plt.show()
然而,我得到的图是错误的,它与我所得到的不匹配,比如说,用Matlab或Mathematica。它实际上不同于以下替代集成:
^{pr2}$结果是正确的。我拿奥迪恩怎么了?在
函数参数在ode和odeint之间变化。你需要什么
为了颂歌
^{pr2}$例如
以及
相关问题 更多 >
编程相关推荐