fminbnd fails to converge with exitflag=1

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일

0 개 추천

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

John
John 2012년 7월 8일
편집: Walter Roberson 2012년 7월 8일
Thanks, Anton. Good point...
The real problem actually comes when there is no local min on x = [x1,x2]. For example:
>> [x,fval,exitflag]=fminbnd(@cos,0,1,optimset('TolX',1e-12))
x = 1.0000
fval = 0.5403
exitflag = 1
>> x-1
ans = -2.4233e-08
When this is no local min, the documentation says fminbnd will return an interior point x1<x<x2 which is no more than 2*TolX from x1 or x2.
Anton Semechko
Anton Semechko 2012년 7월 9일
Sorry, can't help you here. You got to take this issue up with the MathWorks folks.
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개)

카테고리

도움말 센터File Exchange에서 Just for fun에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by