# [SciPy-user] solving an ode with boundary conditions

Rob Clewley rob.clewley@gmail....
Tue Jun 23 20:57:43 CDT 2009

```On Tue, Jun 23, 2009 at 8:37 PM, Max Wainwright<cwainwri@ucsc.edu> wrote:
> I have a 1D second-order differential equation that I'm trying to
> solve with the following boundary conditions: dy/dt = 0 at r = 0 and y
> (t) = 0 at t = infinity.  I can solve this by doing guess and check
> for the initial value of y at t = 0.  If I guess too high, then y
> goes to negative infinity at t = infinity.  If I guess too low, y
> Therefore, to check if I've overshot or undershot the solution all I
> need to do is stop the integration once either y or -dy/dt goes
> negative.  Is there any way to do this with scipy?  I also tried
> looking at PyDSTool, but I had a hard time finding what I need.  I
> don't in principle know the time-scale of the solution (I'll be doing
> this for lots of different parameters), so I'd like to avoid using a
> fixed timestep.

It's pretty easy to set up a standard minimizer from scipy to use an
method" for this boundary value problem (BVP), which is simple enough
to permit this method of solution. You just need to measure your
over-/undershoot numerically in such a way that it provides correct
feedback to the optimizer. PyDSTool would make catching the event of y
or -dy/dt going negative very simple, but it does not have a BVP
solver itself either. There are plenty of tutorial and demo scripts
about that online. This would be hard with scipy's solvers. If you set
up an attempt and need more help you can post it here for more
feedback.

Scipy does not have a BVP built in either. You can also try this
recent package:
http://www.elisanet.fi/ptvirtan/software/bvp/index.html but that might
be like using a sledgehammer to crack a nut, as we say.

-Rob
```