# [SciPy-User] ftol and xtol

pfeldman Phillip.M.Feldman@gmail....
Sat Jul 6 02:32:05 CDT 2013

```If one uses relative error, it is unclear how to handle the situation where
the minimum is at zero.  So, absolute error seems more practical.

On Fri, Jul 5, 2013 at 4:38 AM, GRBChaser [via Scipy-User] <
ml-node+s10969n18518h56@n7.nabble.com> wrote:

> On the subject of ftol and xtol,  the  help for fmin describes these
> parameters as :
>
>     xtol : float
>         Relative error in xopt acceptable for convergence.
>     ftol : number
>         Relative error in func(xopt) acceptable for convergence.
>
>
> The use of the word "Relative" here has always implied to me that the
> convergence tests calculated by fmin refer to fractional changes in
> parameters or function values. However, I had difficulties trying to
> minimize a function in which the two parameters defer by many orders or
> magnitude (e.g. 1 and 1e10) and I've come to the conclusion it is because
> the large parameter never passes the convergence test.
>
> The code in fmin which tests for convergence is :
>
>         if (max(numpy.ravel(abs(sim[1:]-sim[0]))) <= xtol \
>             and max(abs(fsim[0]-fsim[1:])) <= ftol):
>             break
>
> This does not look like a test for the relative change in parameters or
> function values to me, but rather a test for their absolute changes. A
> relative change would surely be something like
>
>         if (max(numpy.ravel(abs((sim[1:]-sim[0])/sim[0]))) <= xtol \
>             and max(abs((fsim[0]-fsim[1:])/fsim[0])) <= ftol):
>             break
>
> (though care should really be taken for possible divide by zero errors).
>
>
> Either the docstring needs changing so "Relative" is replaced with
> "Absolute" to make it clear, or the convergence test needs to be changed so
> it truly is a relative error test.
>
>
>
> ------------------------------
> below:
> http://scipy-user.10969.n7.nabble.com/ftol-and-xtol-tp18355p18518.html
> .
>

--
View this message in context: http://scipy-user.10969.n7.nabble.com/ftol-and-xtol-tp18355p18520.html
Sent from the Scipy-User mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20130706/924855dc/attachment.html
```