[SciPy-User] strange behavior calling odeint from brentq

Warren Weckesser warren.weckesser@enthought....
Fri Nov 25 14:09:34 CST 2011

On Tue, Nov 22, 2011 at 2:11 PM, Schmidt, Phil <PSchmidt@watlow.com> wrote:

>  Hello,
> I am implementing the shooting method using optimize.brentq() and
> integrate.odeint(). The following is an outline of my code:
> def objective(t2, *args):
>     t1 = args[0]
>     x_init = args[1]
>     x_target = args[2]
>     x = odeint(dxdt, x_init, [t1, t2])
>     return x - x_target
> t_target = brentq(objective, t1, t2, args=(t1, x_init, x_target))
> I have observed that if I place do-nothing statements in the objective
> function (e.g., print statements or dummy assignments like t1=t1),
> sometimes I will get different answers for t_target. I have not identified
> a pattern for when this may or may not occur, but presumably there is some
> dependency between brentq() and odeint().
> I am running Scipy 0.9.0rc3, Python 2.6.5, Windows XP.
> Can anyone explain why this is happening, and point me to the "right" way
> to do what I'm attemtping?
> Phil


It is difficult to tell what might be happening based on just the outline
that you showed.  Can you include a complete, minimal example that we can
run and possibly reproduce the problem?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20111125/422bb1bb/attachment.html 

More information about the SciPy-User mailing list