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???

 Respuesta aceptada

Anton Semechko
Anton Semechko el 7 de Jul. de 2012

0 votos

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 comentarios

John
John el 8 de Jul. de 2012
Editada: Walter Roberson el 8 de Jul. de 2012
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 el 9 de Jul. de 2012
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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Just for fun en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 6 de Jul. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by