跳到内容
Walter_Fang's Blog
返回

函数零点求解法中的布伦特法

编辑页面

一般的零点求解方法

给定给定区间 [a,b][a, b] ,函数连续且 f(a)⋅f(b)<0f(a) \cdot f(b)<0 ,那么根据介值定理,函数必然在区间内有根。

布伦特法

初始化区间 (a0,b0)\left(a_0, b_0\right) 使得 f(a0)⋅f(b0)<0f\left(a_0\right) \cdot f\left(b_0\right)<0 。其中 bkb_k 是上次迭代中的根估计值。如果 ∣f(a0)∣<∣f(b0)∣\left|f\left(a_0\right)\right|<\left|f\left(b_0\right)\right|,那么赋值互换(我们认为对应函数值的绝对值较小的点更接近真正的根值) 。

每次迭代包含四个点:

方法的选择

有以下四个不等式:

∣δ∣<∣bk−bk−1∣ (1) ∣δ∣<∣bk−1−bk−2∣ (2) ∣s−bk∣<12∣bk−bk−1∣ (3) ∣s−bk∣<12∣bk−1−bk−2∣ (4) \begin{aligned} & |\delta|<\left|b_k-b_{k-1}\right| \text { (1) } \\ & |\delta|<\left|b_{k-1}-b_{k-2}\right| \text { (2) } \\ & \left|s-b_k\right|<\frac{1}{2}\left|b_k-b_{k-1}\right| \text { (3) } \\ & \left|s-b_k\right|<\frac{1}{2}\left|b_{k-1}-b_{k-2}\right|\text { (4) } \end{aligned}

上次迭代为二分法且 (1)(1) 为假;上次迭代为二分法且 (3)(3) 为假;上次迭代为插值法且 (2)(2) 为假;上次迭代为插值法且 (4)(4) 为假;以插值法计算的临时值不在 3ak+bk4\frac{3a_k+bk}{4} 和 bkb_k 中间,以上五个条件满足一个,那么本次迭代的值采用二分法,否则采用插值法。

而插值法的选择如下:如果三点各不同,则用二次插值;否则用线性插值。

本次迭代的临时值 ss 作为区间的一个端点,另一个端点在 aka_k 和 bkb_k 中选择,二者作为 ak+1,bk+1a_{k+1}, b_{k+1} ,且满足 f(ak+1)⋅f(bk+1)<0f\left(a_{k+1}\right) \cdot f\left(b_{k+1}\right)<0 , ∣f(ak+1)∣>∣f(bk+1)∣\left|f\left(a_{k+1}\right)\right|>\left|f\left(b_{k+1}\right)\right|


Brent’s method is a root-finding algorithm which combines root bracketing, bisection, and inverse quadratic interpolation. It is sometimes known as the van Wijngaarden-Deker-Brent method. Brent’s method is implemented in the Wolfram Language as the undocumented option Method →\rightarrow Brent in FindRoot[eqn, {x,x0,x1}]\{x, x_0, x_1\}].

Brent’s method uses a Lagrange interpolating polynomial of degree 2. Brent (1973) claims that this method will always converge as long as the values of the function are computable within a given region containing a root. Given three points x1x_1, x2x_2, and x3x_3, Brent’s method fits xx as a quadratic function of yy, then uses the interpolation formula

x=[y−f(x1)][y−f(x2)]x3[f(x3)−f(x1)][f(x3)−f(x2)]+[y−f(x2)][y−f(x3)]x1[f(x1)−f(x2)][f(x1)−f(x3)]+[y−f(x3)][y−f(x1)]x2[f(x2)−f(x3)][f(x2)−f(x1)]x=\frac{\left[y-f\left(x_1\right)\right]\left[y-f\left(x_2\right)\right] x_3}{\left[f\left(x_3\right)-f\left(x_1\right)\right]\left[f\left(x_3\right)-f\left(x_2\right)\right]}+\frac{\left[y-f\left(x_2\right)\right]\left[y-f\left(x_3\right)\right] x_1}{\left[f\left(x_1\right)-f\left(x_2\right)\right]\left[f\left(x_1\right)-f\left(x_3\right)\right]}+\frac{\left[y-f\left(x_3\right)\right]\left[y-f\left(x_1\right)\right] x_2}{\left[f\left(x_2\right)-f\left(x_3\right)\right]\left[f\left(x_2\right)-f\left(x_1\right)\right]}

Subsequent root estimates are obtained by setting y=0y=0, giving

x=x2+PQx=x_2+\frac{P}{Q}

where

P=S[T(R−T)(x3−x2)−(1−R)(x2−x1)]Q=(T−1)(R−1)(S−1)\begin{aligned} & P=S\left[T(R-T)\left(x_3-x_2\right)-(1-R)\left(x_2-x_1\right)\right] \\ & Q=(T-1)(R-1)(S-1) \end{aligned}

with

R≡f(x2)f(x3)S≡f(x2)f(x1)T≡f(x1)f(x3)\begin{aligned} R & \equiv \frac{f\left(x_2\right)}{f\left(x_3\right)} \\ S & \equiv \frac{f\left(x_2\right)}{f\left(x_1\right)} \\ T & \equiv \frac{f\left(x_1\right)}{f\left(x_3\right)} \end{aligned}

Brent’s Method

Brent’s method for approximately solving f(x)=0f(x)=0, where f:R→Rf: \mathbb{R} \rightarrow \mathbb{R}, is a “hybrid” method that combines aspects of the bisection and secant methods with some additional features that make it completely robust and usually very efficient. Like bisection, it is an “enclosure” method that begins with an initial interval across which ff changes sign and, as the iterations proceed, determines a sequence of nested intervals that share this property and decrease in length. Convergence of the iterates is guaranteed, even in floating-point arithmetic. If ff is continuous on the initial interval, then each of the decreasing intervals determined by the method contains a solution, and the limit of the iterates is a solution. Like the bisection and secant methods, the method requires only one evaluation of ff at each iteration; in particular, f′f^{\prime} is not required. The following provides a rough outline of how the method works. The full details of the method are complicated and can be found in R. P. Brent, Algorithms for Minimization without Derivatives, Prentice-Hall, 1973. The method builds upon an earlier method of T. J. Dekker and is the basis of MATLAB’s fzero routine. At each iteration, Brent’s method first tries a step of the secant method or something better. If this step is unsatisfactory, which usually means too long, too short, or too close to an endpoint of the current interval, then the step reverts to a bisection step. There is also a feature that occasionally forces a bisection step to guard against too little progress for too many iterations. In the details of the method, a great deal of attention has been paid to considerations of floating-point arithmetic (overflow and underflow, accuracy of computed expressions, etc.). An overview of the operation of the method is as follows:

If necessary, aa and bb are exchanged so that ∣f(b)∣≤∣f(a)∣|f(b)| \leq|f(a)|; thus bb is regarded as the better approximate solution. A third point cc is initialized by setting c=ac=a.

Each iteration proceeds as follows:

  1. If ∣b−c∣≤δ|b-c| \leq \delta, then the method returns bb as the approximate solution.
  2. Otherwise, the method determines a trial point b^\hat{b} as follows:

(i) If a=ca=c, then b^\hat{b} is determined by linear (secant) interpolation: b^=af(b)−bf(a)f(b)−f(a)\hat{b}=\frac{a f(b)-b f(a)}{f(b)-f(a)}. (ii) Otherwise, a,ba, b, and cc are distinct, and b^\hat{b} is determined using inverse quadratic interpolation:

  1. If necessary, b^\hat{b} is adjusted or replaced with the bisection point. (The rules are complicated.)
  2. Once b^\hat{b} has been finalized, a,b,ca, b, c, and b^\hat{b} are used to determine new values of a,ba, b, and cc. (The rules are complicated.) Remark: In part (ii) of step 2, the coefficients α,β\alpha, \beta, and (especially) γ\gamma are easily determined using standard methods at the cost of a few arithmetic operations. (Of course, there needs to be a safeguard against the unlikely event that f(a),f(b)f(a), f(b), and f(c)f(c) are not distinct.) Note that γ\gamma is just p(0)p(0), so if ff really were the inverse of a quadratic, i.e., f−1(y)=p(y)=αy2+βy+γf^{-1}(y)=p(y)=\alpha y^2+\beta y+\gamma for all yy, then b^=γ\hat{b}=\gamma would satisfy f(b^)=f(p(0))=f(f−1(0))=0f(\hat{b})=f(p(0))=f\left(f^{-1}(0)\right)=0. Thus inverse quadratic interpolation provides a low-cost approximate zero of ff that should be more accurate than that obtained by linear (secant) interpolation. Note that if direct quadratic interpolation were used instead of inverse quadratic interpolation, i.e., if we found p(x)=αx2+βx+γp(x)=\alpha x^2+\beta x+\gamma such that p(a)=f(a),p(b)=f(b)p(a)=f(a), p(b)=f(b), and p(c)=f(c)p(c)=f(c), then it would be necessary to find a b^\hat{b} such that p(b^)=0p(\hat{b})=0 using the quadratic formula, which involves a square root. By using inverse quadratic interpolation, Brent’s method avoids this square root.

编辑页面
分享这篇文章:

上一篇
P2880 做题笔记
下一篇
题解:P4986 逃离