Brent's method


In numerical analysis, Brent's method is a root-finding algorithm combining the bisection method, the secant method and inverse quadratic interpolation. It has the reliability of bisection but it can be as quick as some of the less-reliable methods. The algorithm tries to use the potentially fast-converging secant method or inverse quadratic interpolation if possible, but it falls back to the more robust bisection method if necessary. Brent's method is due to Richard Brent and builds on an earlier algorithm by Theodorus Dekker. Consequently, the method is also known as the Brent–Dekker method.
Chandrupatla's method is a variant which is simpler and converges faster for functions that are flat around their roots.

Dekker's method

The idea to combine the bisection method with the secant method goes back to.
Suppose that we want to solve the equation f = 0. As with the bisection method, we need to initialize Dekker's method with two points, say a0 and b0, such that f and f have opposite signs. If f is continuous on , the intermediate value theorem guarantees the existence of a solution between a0 and b0.
Three points are involved in every iteration:
Two provisional values for the next iterate are computed. The first one is given by linear interpolation, also known as the secant method:
and the second one is given by the bisection method
If the result of the secant method, s, lies strictly between bk and m, then it becomes the next iterate, otherwise the midpoint is used.
Then, the value of the new contrapoint is chosen such that f and f have opposite signs. If f and f have opposite signs, then the contrapoint remains the same: ak+1 = ak. Otherwise, f and f have opposite signs, so the new contrapoint becomes ak+1 = bk.
Finally, if |f| < |f|, then ak+1 is probably a better guess for the solution than bk+1, and hence the values of ak+1 and bk+1 are exchanged.
This ends the description of a single iteration of Dekker's method.
Dekker's method performs well if the function f is reasonably well-behaved. However, there are circumstances in which every iteration employs the secant method, but the iterates bk converge very slowly. Dekker's method requires far more iterations than the bisection method in this case.

Brent's method

proposed a small modification to avoid this problem. He inserted an additional test which must be satisfied before the result of the secant method is accepted as the next iterate. Two inequalities must be simultaneously satisfied:
Given a specific numerical tolerance, if the previous step used the bisection method, the inequality
must hold to perform interpolation, otherwise the bisection method is performed and its result used for the next iteration.
If the previous step performed interpolation, then the inequality
is used instead to perform the next action interpolation or bisection method.
Also, if the previous step used the bisection method, the inequality
must hold, otherwise the bisection method is performed and its result used for the next iteration. If the previous step performed interpolation, then the inequality
is used instead.
This modification ensures that at the kth iteration, a bisection step will be performed in at most additional iterations, because the above conditions force consecutive interpolation step sizes to halve every two iterations, and after at most iterations, the step size will be smaller than, which invokes a bisection step. Brent proved that his method requires at most N2 iterations, where N denotes the number of iterations for the bisection method. If the function f is well-behaved, then Brent's method will usually proceed by either inverse quadratic or linear interpolation, in which case it will converge superlinearly.
Furthermore, Brent's method uses inverse quadratic interpolation instead of linear interpolation. If f, f and f are distinct, it slightly increases the efficiency. As a consequence, the condition for accepting s has to be changed: s has to lie between / 4 and bk.

Algorithm

input a, b, and a function for f
calculate f
calculate f
if f'f ≥ 0 then
exit function because the root is not bracketed.
end if
if |f| < |f| then
swap
end if
c := a
set mflag
repeat until f = 0 or |ba| is small enough '
if ff and ff then
'
else
'
end if
if ' s is not or
' or
' or
' or
' then
'
set mflag
else
clear mflag
end if
calculate f
d := c '
c := b
if f'f < 0 then
b := s
else
a := s
end if
if |f| < |f| then
swap
end if
end repeat
output b or s

Example

Suppose that we are seeking a zero of the function defined by f = 2.
We take = as our initial interval.
We have f = −25 and f = 0.48148, so the conditions f f < 0 and |f| ≤ |f| are satisfied.
  1. In the first iteration, we use linear interpolation between = = and =, which yields s = 1.23256. This lies between / 4 and b0, so this value is accepted. Furthermore, f = 0.22891, so we set a1 = a0 and b1 = s = 1.23256.
  2. In the second iteration, we use inverse quadratic interpolation between = and = and =. This yields 1.14205, which lies between / 4 and b1. Furthermore, the inequality |1.14205 − b1| ≤ |b0b−1| / 2 is satisfied, so this value is accepted. Furthermore, f = 0.083582, so we set a2 = a1 and b2 = 1.14205.
  3. In the third iteration, we use inverse quadratic interpolation between = and = and =. This yields 1.09032, which lies between / 4 and b2. But here Brent's additional condition kicks in: the inequality |1.09032 − b2| ≤ |b1b0| / 2 is not satisfied, so this value is rejected. Instead, the midpoint m = −1.42897 of the interval is computed. We have f = 9.26891, so we set a3 = a2 and b3 = −1.42897.
  4. In the fourth iteration, we use inverse quadratic interpolation between = and = and =. This yields 1.15448, which is not in the interval between. Hence, it is replaced by the midpoint m = −2.71449. We have f = 3.93934, so we set a4 = a3 and b4 = −2.71449.
  5. In the fifth iteration, inverse quadratic interpolation yields −3.45500, which lies in the required interval. However, the previous iteration was a bisection step, so the inequality |−3.45500 − b4| ≤ |b4b3| / 2 need to be satisfied. This inequality is false, so we use the midpoint m = −3.35724. We have f = −6.78239, so m becomes the new contrapoint and the iterate remains the same.
  6. In the sixth iteration, we cannot use inverse quadratic interpolation because b5 = b4. Hence, we use linear interpolation between = and =. The result is s = −2.95064, which satisfies all the conditions. But since the iterate did not change in the previous step, we reject this result and fall back to bisection. We update s = -3.03587, and f = -0.58418.
  7. In the seventh iteration, we can again use inverse quadratic interpolation. The result is s = −3.00219, which satisfies all the conditions. Now, f = −0.03515, so we set a7 = b6 and b7 = −3.00219 | ≤ |f.
  8. In the eighth iteration, we cannot use inverse quadratic interpolation because a7 = b6. Linear interpolation yields s = −2.99994, which is accepted.
  9. In the following iterations, the root x = −3 is approached rapidly: b9 = −3 + 6·10−8 and b10 = −3 − 3·10−15. = -1.4E-07, Iter 10 : f

    Implementations

  1. Function minimization at with an example .
  2. Root finding implements the newer TOMS748, a more modern and efficient algorithm than Brent's original, at , and that with .