fminbnd fails to converge with exitflag=1

2 次查看(过去 30 天)
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???

采纳的回答

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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by