[SciPy-user] Solving an equation using scipy.optimize.newton
Wed Sep 5 16:33:07 CDT 2007
On 9/5/07, firstname.lastname@example.org <email@example.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],
> 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
> 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
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-user