Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differences between two ODE solvers

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

like image 599
Ma Y Avatar asked Jan 01 '23 04:01

Ma Y


1 Answers

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

like image 154
Diego Gallegos Avatar answered Jan 12 '23 03:01

Diego Gallegos