0

I have a large system of differential equations I am trying to solve. I get the same results using scipy.odeint and scipy.solve_ivp, however the former is ~17 times faster in my case. I read that solve_ivp is recommended for initial value problems, but can't find more on why I can't use odeint (when it's giving me the same results).

Do I need to use solve_ivp when I am getting the same results as from odeint? When would I use one vs the other?

Thanks.

DPdl
  • 723
  • 7
  • 23
  • 1
    Are you using the default `method` in `solve_ivp`. I see a `LSODA` alternative that may work more like the `odeint`. The `solve_ivp` recommendation may be based on it providing more method options, and a newer, more systematic interface. Read, and reread, the docs! – hpaulj Apr 15 '20 at 19:52
  • You are correct. I used the default 'RK45' method. 'LSODA' was much faster, and gave similar results. – DPdl Apr 15 '20 at 19:56
  • 1
    You *can* use `odeint`. As @hpaulj noted, `solve_ivp` is newer and has more features, but `odeint` still works. How does the peformance of `solve_ivp` with the 'LSODA' method compare to that of `odeint`? Note that the default error tolerances used by `odeint` are much smaller than those used by `solve_ivp`. You might want to adjust these to make an "apples to apples" comparison. – Warren Weckesser Apr 16 '20 at 07:15

0 Answers0