Follow-up Comment #3, bug #39713 (project gsl):
The section within secant.c in which the root position, the function value and
the derivative value are updated is:
x_new = x - (f / df);
f_new = GSL_FN_FDF_EVAL_F(fdf, x_new) ;
df_new = (f_new - f) / (x_new - x) ;
*root = x_new ;
Although it involves an additional multiplication, I think this may be safer:
x_new = x - (f / df);
f_new = GSL_FN_FDF_EVAL_F(fdf, x_new) ;
df_new = df * (1.0 - f_new / f) ;
*root = x_new;
since it avoids the potential problem of x_new and x being the same because (f
/ df) is too small to change x when it is subtracted. Also, since the
algorithm shouldn't presumably be entered with f = 0, the division f_new / f
should not cause a divide by zero problem.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?39713>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/