Python中scipy.integrate中的odeint是否给出错误的结果?

Python中scipy.integrate中的odeint是否给出错误的结果?,python,matlab,scipy,Python,Matlab,Scipy,我正在尝试使用以下代码求解ivp y'=-y-5*exp-t*sin5 t,y0=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 =

我正在尝试使用以下代码求解ivp y'=-y-5*exp-t*sin5 t,y0=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。它实际上不同于以下替代集成:

from scipy.integrate import ode

# initialize the 4th order Runge-Kutta solver
solver = ode(mif).set_integrator('dop853')

# initial value
y0 = 1.0
solver.set_initial_value(y0, 0)

values = 1000
t = np.linspace(0.0001, 3, values)
y = np.zeros(values)

for ii in range(values):
    y[ii] = solver.integrate(t[ii])[0] #z[0]=u

这会产生正确的结果。odeint有什么问题?

函数参数在ode和odeint之间变化。你需要什么

def mif(y, t):
颂歌呢

def mif(t, y):
e、 g


函数参数在ode和odeint之间变化。你需要什么

def mif(y, t):
颂歌呢

def mif(t, y):
e、 g


如果答案对你有帮助,不要忘记接受它。谢谢如果答案对你有帮助,不要忘记接受它。谢谢