# Handling non-convergence in roots.jl

4 messages
Open this post in threaded view
|
Report Content as Inappropriate

## Handling non-convergence in roots.jl

 I am running a sequence of root finding functions in a loop.For my problem the basic fzero always work.However, using Newtons method is very useful because it is very fast when it converges.The problem is that when it does not converge it throws an error instead of a non-convergence flag.That way I cant use the fzero when newton fails (actually try/catch works but its very slow).Any suggestions?
Open this post in threaded view
|
Report Content as Inappropriate

## Re: Handling non-convergence in roots.jl

 On Thu, 2016-11-10 at 18:54, Joaquim Masset Lacombe Dias Garcia <[hidden email]> wrote: > I am running a sequence of root finding functions in a loop. > For my problem the basic fzero always work. > > However, using Newtons method is very useful because it is very fast when > it converges. > The problem is that when it does not converge it throws an error instead of > a non-convergence flag. > > That way I cant use the fzero when newton fails (actually try/catch works > but its very slow). > > Any suggestions? Just modify the Roots.jl package.
Open this post in threaded view
|
Report Content as Inappropriate

## Re: Handling non-convergence in roots.jl

 On Thu, 2016-11-10 at 20:07, Mauro <[hidden email]> wrote: > On Thu, 2016-11-10 at 18:54, Joaquim Masset Lacombe Dias Garcia <[hidden email]> wrote: >> I am running a sequence of root finding functions in a loop. >> For my problem the basic fzero always work. >> >> However, using Newtons method is very useful because it is very fast when >> it converges. >> The problem is that when it does not converge it throws an error instead of >> a non-convergence flag. >> >> That way I cant use the fzero when newton fails (actually try/catch works >> but its very slow). >> >> Any suggestions? > > Just modify the Roots.jl package. To be a bit more informative:  The error gets thrown here: https://github.com/JuliaMath/Roots.jl/blob/943cf897e9ea6b31ab3ec70238ac4931065d365a/src/derivative_free.jl#L45In that function, modify all occurrences of   throw(ConvergenceFailed("some message")) with   ( warn("some message"); return true) Restart the REPL Then it should not throw but warn and return the best value it found.