[SciPy-User] Does odeint return derivative
Sun Aug 28 11:32:42 CDT 2011
On Sun, Aug 28, 2011 at 7:02 AM, ali franco <email@example.com> wrote:
> I am solving a system of differential equations using odeint. Is there a
> simpler way of also getting the derivative other than calculating the
> derivative from the solutions obtained which in my case is going to take
> alot of extra time.
Maybe I misunderstand which derivative you are interested in, but if
you have a system
x' = f(x, t)
then the rates of change of the state variables x at any given time
and known state position are simply given by calling function f
directly. That's what the ODE means by definition. So if you have
solved for a trajectory and have an array of time t and state x
values, just pass a pair of x, t values to f to find out how fast x is
changing at that point.
This *is* a very simple and cheap way to get the derivative (you can
even vectorize it), but I'm guessing that you were considering doing
some kind of finite differencing to obtain approximate derivatives
from the trajectory.
Anyway, hope that helps.
More information about the SciPy-User