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
Well the main difference is the following:
odeint
came first and is uses lsoda from the FORTRAN package odepack to solve ODEs.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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With