Skip to content

Add argument to return NaN, not an error, when no convergence #196

@jverzani

Description

@jverzani

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions