Bisection method


In mathematics, the bisection method is a root-finding method that applies to any continuous functions for which one knows two values with opposite signs. The method consists of repeatedly bisecting the interval defined by these values and then selecting the subinterval in which the function changes sign, and therefore must contain a root. It is a very simple and robust method, but it is also relatively slow. Because of this, it is often used to obtain a rough approximation to a solution which is then used as a starting point for more rapidly converging methods. The method is also called the interval halving method, the binary search method, or the dichotomy method.
For polynomials, more elaborated methods exist for testing the existence of a root in an interval. They allow extending bisection method into efficient algorithms for finding all real roots of a polynomial; see Real-root isolation.

The method

The method is applicable for numerically solving the equation f = 0 for the real variable x, where f is a continuous function defined on an interval and where f and f have opposite signs. In this case a and b are said to bracket a root since, by the intermediate value theorem, the continuous function f must have at least one root in the interval.
At each step the method divides the interval in two by computing the midpoint c = / 2 of the interval and the value of the function f at that point. Unless c is itself a root there are now only two possibilities: either f and f have opposite signs and bracket a root, or f and f have opposite signs and bracket a root. The method selects the subinterval that is guaranteed to be a bracket as the new interval to be used in the next step. In this way an interval that contains a zero of f is reduced in width by 50% at each step. The process is continued until the interval is sufficiently small.
Explicitly, if f and f have opposite signs, then the method sets c as the new value for b, and if f and f have opposite signs then the method sets c as the new a. In both cases, the new f and f have opposite signs, so the method is applicable to this smaller interval.

Iteration tasks

The input for the method is a continuous function f, an interval , and the function values f and f. The function values are of opposite sign. Each iteration performs these steps:
  1. Calculate c, the midpoint of the interval, c =.
  2. Calculate the function value at the midpoint, f.
  3. If convergence is satisfactory, return c and stop iterating.
  4. Examine the sign of f and replace either or with so that there is a zero crossing within the new interval.
When implementing the method on a computer, there can be problems with finite precision, so there are often additional convergence tests or limits to the number of iterations. Although f is continuous, finite precision may preclude a function value ever being zero. For example, consider ; there will never be a finite representation of x that gives zero. Additionally, the difference between a and b is limited by the floating point precision; i.e., as the difference between a and b decreases, at some point the midpoint of will be numerically identical to either a or b.

Algorithm

The method may be written in pseudocode as follows:
INPUT: Function f,
endpoint values a, b,
tolerance TOL,
maximum iterations NMAX
CONDITIONS: a < b,
either f < 0 and f > 0 or f > 0 and f < 0
OUTPUT: value which differs from a root of f = 0 by less than TOL

N ← 1
while NNMAX do // limit iterations to prevent infinite loop
c ← /2 // new midpoint
if f = 0 or /2 < TOL then // solution found
Output
Stop
end if
NN + 1 // increment step counter
if sign = sign then ac else bc // new interval
end while
Output // max number of steps exceeded

Example: Finding the root of a polynomial

Suppose that the bisection method is used to find a root of the polynomial
First, two numbers and have to be found such that and have opposite signs. For the above function, and satisfy this criterion, as
and
Because the function is continuous, there must be a root within the interval .
In the first iteration, the end points of the interval which brackets the root are and, so the midpoint is
The function value at the midpoint is. Because is negative, is replaced with for the next iteration to ensure that and have opposite signs. As this continues, the interval between and will become increasingly smaller, converging on the root of the function. See this happen in the table below.
Iteration
1121.5−0.125
21.521.751.6093750
31.51.751.6250.6660156
41.51.6251.56250.2521973
51.51.56251.53125000.0591125
61.51.53125001.5156250−0.0340538
71.51562501.53125001.52343750.0122504
81.51562501.52343751.5195313−0.0109712
91.51953131.52343751.52148440.0006222
101.51953131.52148441.5205078−0.0051789
111.52050781.52148441.5209961−0.0022794
121.52099611.52148441.5212402−0.0008289
131.52124021.52148441.5213623−0.0001034
141.52136231.52148441.52142330.0002594
151.52136231.52142331.52139280.0000780

After 13 iterations, it becomes apparent that there is a convergence to about 1.521: a root for the polynomial.

Analysis

The method is guaranteed to converge to a root of f if f is a continuous function on the interval and f and f have opposite signs. The absolute error is halved at each step so the method converges linearly, which is comparatively slow.
Specifically, if c1 = is the midpoint of the initial interval, and cn is the midpoint of the interval in the nth step, then the difference between cn and a solution c is bounded by
This formula can be used to determine in advance the number of iterations that the bisection method would need to converge to a root to within a certain tolerance.
The number of iterations needed, n, to achieve a given error, ε, is given by:
where
Therefore, the linear convergence is expressed by