[SciPy-User] SCIPY FSOLVE
Mon Oct 12 12:00:54 CDT 2009
>It appears you are correct in your concern about the closeness of p1 and
>p2. You can avoid the problem of raising a negative number to a
>fractional power if you reformulate your residual.
>If you change this:
> curr_err = q1 - ( c * ( p2 ** 2 - p1 ** 2 ) ) ** n
> curr_err = q1**(1/n) - ( c * ( p2 ** 2 - p1 ** 2 ) )
>the script gives the answer:
>[ 200.00004794 2.39840655 1.77542113 0.62298543]
>Note that p2 is very close to p1, so it is not surprising that during
>the solver's iterations, p2**2 - p1**2 occasionally becomes negative.
thanks for the suggestion - that could well be the answer! Will try
it in my larger model
More information about the SciPy-User