octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exit codes for fzero


From: Rik
Subject: Re: Exit codes for fzero
Date: Wed, 10 Feb 2010 14:42:18 -0800

Jaroslav Hajek wrote:

>> One thought I had would be a single sanity check at the end of fzero to
>> verify that fval is somewhere near zero.  That would easily catch this case
>> where the end value of 7x10^14 cannot be confused with zero.  Is there
>> another better way to get an error exit code when the algorithm has failed?
>>
>> --Rik
>>
>>
> 
> Hi Rik,
> your explanation is correct - the algorithm falls back to bisection
> when inverse interpolation fails. Basically, the function is assumed
> to be continuous, so based on that assumption the algorithm
> incorrectly deduces that a root is bracketed (as if the -Inf and Inf
> were connected).
> This is where the actual bracketing interval may be useful. After
> fsolve "converges", you can check out the final bracketing, and if the
> jump in values is excessive, consider it to be a discontinuity. I
> don't think it's much useful to put such a check directly into fzero;
> the best way to react is probably problem-dependent.
> 

My hope was to avoid coding checks around every function call.  When I call
an ordinary system function I can use the exit code alone to determine if
something went wrong.  In the current case I would need to code something like:

if ((INFO == 1) && (abs(FEVAL) < SOME_TOLERANCE)) { result was good }

If this is the way that everyone should be verifying the results of fzero
then it makes more sense to locate this code within fzero.m rather than
duplicated  in hundreds of user scripts.

My second rationale is that I want to be able to use fzero as a black box
without understanding all of its internals.  When investigating new
functions I won't necessarily know in advance whether a function is
pathological or not.  Or I might be exploring a parameter space and have
the same function with random parameters for which only a few values
produce bad functions.  In this case I would like to just try the function
and have fzero itself report whether it was successful since I can't guess
at all of the ways that the algorithm might fail.

Maybe I'm wishing for something that just doesn't exist.  Can anyone with
Matlab run 'fzero(@(x) 1./(x-pi), 3)' and see whether the exit code reports
success or failure?

--Rik


reply via email to

[Prev in Thread] Current Thread [Next in Thread]