Explore the bisection method, a numerical technique that locates roots by repeatedly halving intervals of continuous functions.
The bisection method finds a zero of a continuous function by repeatedly halving an interval in which the function changes sign. It is slow but reliable: it always converges, and it predicts in advance how many steps are needed to achieve a given accuracy [1].
If $f$ is continuous on $[a, b]$ and $f(a)\,f(b) < 0$, by the zero theorem there is at least one root in $(a, b)$. The midpoint $m = (a + b)/2$ is calculated: if $f(m) = 0$ the process stops, otherwise the half in which the sign changes is kept. After $k$ steps the interval has length $(b - a)/2^k$ [1][2].
The root of $f(x) = x^2 - 2$ is sought in $[1, 2]$, with $f(1) = -1$ and $f(2) = 2$ (assumed values). The successive midpoints are $1.5$, $1.25$, $1.375$, $1.4375$, $1.40625$, $1.421875$, $1.4140625$ (calculation). After $7$ steps the interval is wide $2^{-7} = 0.0078125$, and the value $1.4140625$ is close to $\sqrt{2} \approx 1.41421$.
To obtain an interval of length less than $\varepsilon$, $k \ge \log_2\dfrac{b - a}{\varepsilon}$ steps are needed. With $b - a = 1$ and $\varepsilon = 10^{-6}$ these are $k = 20$ (calculation). Each step gains about one bit of precision, i.e. $0.3$ decimal digits: the convergence is linear.
The algorithm can be stopped when the interval length is less than the desired tolerance, or when $|f(m)|$ is sufficiently small. The two criteria are not equivalent if the function is very steep or very flat near the root, so it is advisable to use the first (general observation).
- It requires only continuity and a sign change, not the derivative.
- It is robust: it always converges, whatever the function.
- The number of steps is known in advance.
Root finding of equations, inversion of monotone functions, binary search in computer science, and as a first step for faster methods such as Newton-Raphson (see the dedicated entry) (general observation).
An initial interval with a sign change is required. It does not find roots of even multiplicity, where the function touches the axis without crossing it, such as $(x - 1)^2$. If the interval contains multiple roots, it finds only one. Compared to Newton it is much slower.
[1] Wikipedia (it): Metodo della bisezione
[2] Wikipedia (en): Bisection method
Generating summary…