我想知道,ODEINT
和solve_ivp
之间的区别是什么?它们之间的优缺点是什么?
f1 = solve_ivp(f, [0,1], y0) #y0 is the initial point
f2 = odeint(f, y0, [0, 1], args=(a, b)) # a and b are arguments of function f
谢谢
答案 0 :(得分:2)
主要区别如下:
odeint
首先出现,并使用FORTRAN软件包odepack中的 lsoda 来求解ODE。solve_ivp
是一种更通用的解决方案,它使用户可以决定使用哪个积分器来求解ODE。如果将method
参数定义为method='LSODA'
,则它将使用与odeint
相同的积分器。另外,您可以选择其他方法,例如 BDF 和 RK25 。 关于性能,有一张票证表明solve_ivp
的速度较慢。这可能是因为它是用Python编写的。
在scipy中检查两个文档:
https://docs.scipy.org/doc/scipy-1.2.1/reference/generated/scipy.integrate.odeint.html https://docs.scipy.org/doc/scipy-1.2.1/reference/generated/scipy.integrate.solve_ivp.html