Hi, I am a user of the root and minimization finder. I noticed that the root finder and minimization fail if the function evaluation gives an infinite result.
The failure occurs because all the functions are called through a "SAFE_FUNC_CALL" macro. Which seems to be designed to catch infinite evaluations. "function value is not finite at bisection.c:56 error code 9: problem with user-supplied function" However I think that this check puts unnecessary constrains in the algorithms. For example the bisection doesn't rely on the values of the function but only in the sign. This means that if the function evaluation has a well defined sign it can still find roots even if intermediate evaluations gave infinity. Ultimatelly the same can be said of Brent, which effectively fallback to bisection. Here it is an example of a function which for which if the check is not done still should give an answer. f(x) = x if -1 < x < 1, -inf if x < -1, +inf if x > 1. (with initial guess points x = -2 and 2 for example) In fact I would argue that this case is the only reason to use bisection, because it is robust even if the function evaluates to infinity (with well defined sign). The same can be said about minimization by golden ratio and brent (minimization). f(x) = x^2 if -1 < x < 1, +inf if x < -1, -inf if x > 1. (with initial guess x = -2, 0.5, 2 for example) Needless to say that sometimes the infinite results is involuntary, it is just a well justified overflow in a different calculation try to give a very large number, which if it used correctly shouldn't prevent some robust algorithms to work. In summary, the SAFE_FUN_CALL puts unnecessary constrains on the function regarding its rejection of infinite results. This is very obvious for bisection. I was tempted to file a bug but I wanted to use the help mailing list first. Thanks, A
