zeroin¶
-
sherpa.utils.
zeroin
(fcn, xa, xb, fa=None, fb=None, args=(), maxfev=32, tol=0.01)[source]¶ Obtain a zero of a function of one variable using Brent’s root finder.
Return an approximate location for the root with accuracy:
4*DBL_EPSILON*abs(x) + tol
using the algorithm from [1].
References
[1] G.Forsythe, M.Malcolm, C.Moler, Computer methods for mathematical computations. M., Mir, 1980, p.180 of the Russian edition Notes
The function makes use of a bisection procedure combined with a linear or quadratic inverse interpolation.
At each step the code operates three abscissae - a, b, and c:
- b - the last and the best approximation to the root
- a - the last but one approximation
- c - the last but one or even an earlier approximation such that:
|f(b)| <= |f(c)|
- f(b) and f(c) have opposite signs, i.e. b and c encompass the root
Given these abscissae, the code computes two new approximations, one by the bisection procedure and the other one from interpolation (if a,b, and c are all different the quadratic interpolation is used, linear otherwise). If the approximation obtained by the interpolation looks reasonable (i.e. falls within the current interval [b,c], not too close to the end points of the interval), the point is accepted as a new approximation to the root. Otherwise, the result of the bissection is used.