[SciPy-user] suggestions for improving scipy.integrate.odeint
Arnd Baecker
arnd.baecker at web.de
Tue Apr 19 11:17:08 CDT 2005
Dear Hans,
On Tue, 19 Apr 2005, Hans Fangohr wrote:
[...]
> 1. The initial value (array) can change while odeint carries out the
> integration. This source code
>
> #----------------------------
> import Numeric
> from scipy.integrate import odeint
>
> def rhs(y,t):
> return -y[0]
>
> y0 = Numeric.array([1.0])
> print "Initial value:",y0
> ts = Numeric.arange(0,10,1)
> ys = odeint( rhs, y0, ts )
> print "Initial value:",y0
> #----------------------------
>
> produces the following output:
> #===========================
> Initial value: [ 1.]
> Initial value: [ 0.00012341]
> #===========================
>
> I can kind-of-see why this may happen (without digging in the source).
> However, this is highly confusing to the students because y0 is an input
> argument to the odeint function and should not change when odeint is
> called.
I think this is actually done on purpose,
as y0 contains the last entry of ys,
print ys[-1]
[ 0.00012341]
This allows to restart odeint with this initial value
to continue the integration.
We stumbled across the same some time ago
(I thought this was documented somewhere, but it seems
it is not, at least not in the doc-string to odeint).
Best,
Arnd
More information about the SciPy-user
mailing list