18

I have read the docs for these here, but it just states that odeint is "an integrator with a simpler interface based on lsoda from ODEPACK"

What is the actual difference? Under what circumstances is using one more appropriate than the other?

Dipole
  • 1,840
  • 2
  • 24
  • 35

2 Answers2

14

If you can solve your problem with odeint, I would recommend that. It is simply a function that integrates an ode using lsoda.

If you want a lot more options, ode is a class with many methods and solvers:

Community
  • 1
  • 1
askewchan
  • 45,161
  • 17
  • 118
  • 134
  • Is it possible to set a different integrator for odeint? – imranal Oct 22 '15 at 18:00
  • @imranal, not as it's written, as far as I can tell. It may not be that difficult to modify, or to look at the source to inform writing your own version. – askewchan Oct 22 '15 at 19:44
  • Bingo! `ode` cat haz `.set_solout`, but `odeint` can't. However, it looks like only some of the integrators (e.g. Runge Kutta dopri5, dop853) *actually* can haz. – uhoh Jul 15 '16 at 08:16
  • @uhoh Whats with your spelling? – dearN Feb 11 '17 at 00:47
  • 2
    @drN you are right! For some reason I've transposed the `z` to has, it should remain within [cheeseburger](https://en.wikipedia.org/wiki/I_Can_Has_Cheezburger%3F), as in the classic Happycat https://i.stack.imgur.com/BZ33g.jpg The problem I often have with `.odeint()` is that you have to choose the ending time ahead of time and can't detect trouble and say "stop! go no further". However, for some integrators in `.ode()` you have [`.set_solout()`](https://docs.scipy.org/doc/scipy-0.18.1/reference/generated/scipy.integrate.ode.set_solout.html#scipy.integrate.ode.set_solout) – uhoh Feb 11 '17 at 04:43
  • 1
    @drN it seems I am [not the first](http://english.stackexchange.com/q/20356/217285) to mipsell the werd haz. – uhoh Feb 11 '17 at 04:47
  • 1
    @uhoh You certainly waz there! – dearN Feb 11 '17 at 13:49
0

I was wondering about the same question, and I found later that there is an other API available in scipy.integrate. The method is clearly explained in the documentation.

It could interest people comparing odeint (odeintw for complex) and ode (complex_ode for complex).

It is called scipy.integrate.solve_ivp, available from scipy v1.0.0 : https://scipy.github.io/devdocs/generated/scipy.integrate.solve_ivp.html#scipy.integrate.solve_ivp In this solver, LSODA cant handle complex but BDF is faster in my case.

Geoffroy
  • 89
  • 1
  • 7