[SciPy-User] SCIPY FSOLVE

Etrade Griffiths etrade.griffiths@dsl.pipex....
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[0] * ( p2 ** 2 - p1 ** 2 ) ) ** n[0]
>
>to this:
>
>      curr_err = q1**(1/n[0]) - (  c[0] * ( 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.

Warren

thanks for the suggestion - that could well be the answer!  Will try 
it in my larger model

Best regards

Alun Griffiths 



More information about the SciPy-User mailing list