[SciPy-user] Solving an equation using scipy.optimize.newton

Dominique Orban dominique.orban@gmail....
Wed Sep 5 16:33:07 CDT 2007


On 9/5/07, fdu.xiaojf@gmail.com <fdu.xiaojf@gmail.com> wrote:
>
> Hi all,
>
> I'm trying to solve an equation f(x) = 0 with scipy.optimize.newton.
>
> However the problem isn't so simple. There are bound constraints for my
> equation: the equation cannot be evaluated when x is out of [Min, Max],
> but
> the root is always in the interval of [Min, Max]
>
> When newton() iterates to find a root, it sometimes try to evaluate the
> equation with a x out of [Min, Max], and then error occurs.
>
> How to solve this problem ?
>
> I couldn't easily find two points with different signs every time, so
> methods
> like brentq don't work here.


There are variants of Newton's method that can handle bound constraints.
However, another way to treat your problem would be to solve the
optimization problem:

minimize   0
subject to   f(x) = 0, and Min <= x <= Max.

The objective function of this problem is constant, so any x satisfying the
constraints is optimal, and is what you are looking for. Note however that
you now have an optimization problem with nonlinear equality constraints.

If a solver isn't able to identify a point satisfying the constraints, it
will usually guarantee some sort of 'proximity property', i.e., the final
iterate will minimize the residual of constraints in some sense.

Dominique
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20070905/4352d967/attachment.html 


More information about the SciPy-user mailing list