fminbnd fails to converge with exitflag=1

1 Ansicht (letzte 30 Tage)
John
John am 6 Jul. 2012
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???

Akzeptierte Antwort

Anton Semechko
Anton Semechko am 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 Kommentare
Anton Semechko
Anton Semechko am 9 Jul. 2012
Sorry, can't help you here. You got to take this issue up with the MathWorks folks.
Alan Weiss
Alan Weiss am 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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by