-
Notifications
You must be signed in to change notification settings - Fork 58
Description
Following https://discourse.julialang.org/t/switch-find-zero-method-if-convergence-fails-without-try-catch/50482 and https://discourse.julialang.org/t/query-status-of-the-solution-when-using-roots/50328/5 it seems that adding a means to return NaN
instead of an error is desirable.
Currently, the user can get this by calling find_zero
with a different signature, that being find_zero(M, f, options, state)
. There are at least two reasonable ways to address this:
-
As per Per "A “clean” way of doing this would be too add a keyword argument throw_on_failure to find_zero. This argument could have a default value of Val(true), but setting it to Val(false) would cause the exception to be returned instead of thrown. (This causes a type instability in the return value, but that instability is resolved as soon as the calling function verifies that the returned value is indeed a Number.)"
-
There could be a new interface, something like:
prob =ZeroProblem(M, f, x0; kwargs)
find_zero(prob)
or even solve(prob)
(were it only that solve
were some base function to extend)