fminbnd fails to converge with exitflag=1

1 view (last 30 days)
I'm trying to use fminbnd to find the extrema of a function, but I'm having an issue with the tolerance. Here is a simple example:
>> [x,fval,exitflag]=fminbnd(@cos,3,4,optimset('TolX',1e-12))
x = 3.1416
fval = -1
exitflag = 1
>> x-pi
ans = 4.3792e-10
The exitflag indicates that fminbnd converged within the specified tolerance. So why is x-pi>TolX???

Accepted Answer

Anton Semechko
Anton Semechko on 7 Jul 2012
because TolX is a measure of change in x between two successive iterations and not an indication of how close it is to a true minimum, which is generally not known
  3 Comments
Anton Semechko
Anton Semechko on 9 Jul 2012
Sorry, can't help you here. You got to take this issue up with the MathWorks folks.
Alan Weiss
Alan Weiss on 9 Jul 2012
Thanks for the excellent question. You found an error in the documentation. I will address this error soon.
In fact, if you look at the code for fminbnd by executing "edit fminbnd", you see that there is a tolerance of TolX and also a value sqrt(eps) that comes into play. The true final tolerance relates to
sqrt(eps)*x + TolX/3
where x is the current point. Now sqrt(eps) ~ 1e-8, so if you choose a TolX any smaller than that, and x ~ 1, then the value of TolX has almost no effect.
Alan Weiss
MATLAB mathematical toolbox documentation

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!