Differences between two ODE solvers

流过昼夜 提交于 2021-01-27 11:28:13

问题


I am wondering, what are the differences between ODEINT and solve_ivp for solving a differential equation. What could be advantages and disadvantages between them?

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

Thank you


回答1:


Well the main difference is the following:

  1. odeint came first and is uses lsoda from the FORTRAN package odepack to solve ODEs.
  2. solve_ivp is a more general solution that lets use decide which integrator to use to solve ODEs. If you define the method param as method='LSODA' then this will use the same integrator as odeint. Additionally you can choose other methods such as BDF and RK25.

Regarding performance, there is a ticket that indicate that solve_ivp is slower. This maybe because its written in Python.

https://github.com/scipy/scipy/issues/8257

Check the docs for both of them in 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



来源:https://stackoverflow.com/questions/55152516/differences-between-two-ode-solvers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!