Bisection Method

← Numerical Methods

Source inspiration: (Mathew 2000-2019).

Description

The bisection method finds a root of a single equation \(f(x) = 0\) that has been bracketed: it starts from an interval \([a_0, b_0]\) on which \(f\) changes sign and halves that interval until the root is pinned down. Each step evaluates \(f\) at the midpoint and keeps the half on which the sign change survives:

\[ c_k = \frac{a_{k-1} + b_{k-1}}{2}, \qquad [a_k, b_k] = \begin{cases} [a_{k-1},\, c_k] & \text{if } f(a_{k-1})\,f(c_k) < 0,\\ [c_k,\, b_{k-1}] & \text{otherwise}, \end{cases} \qquad k = 1, 2, \ldots \]

The method assumes that \(f\) is continuous on \([a_0, b_0]\) and that \(f(a_0)\) and \(f(b_0)\) have opposite signs; the Intermediate Value Theorem then puts a root in every bracket. It needs no derivative and only one new value of \(f\) per step. It cannot find a root at which \(f\) does not change sign, such as the double root of \((x-1)^2\), and when the bracket holds several roots it finds only one of them.

Mathews’ bisection theorem gives the accuracy as a general result under those two hypotheses: the midpoints converge to a root \(x^*\) in \([a_0, b_0]\), with

\[ |c_k - x^*| \le \frac{b_0 - a_0}{2^k}, \qquad k = 1, 2, \ldots \]

Mathews’ process stops if some \(f(c_k) = 0\), since \(c_k\) is then a root; the rule above has no such test, so an exact hit forces the right half twice, leaving the root (on \(x^2 - 4\), \([0, 4]\): \(c_1 = 2\), then \(c_k \to 4\)). For this rule the guarantee and the bound hold only while no \(f(c_k) = 0\). The bound halves every step whatever \(f\) is, so convergence is linear: one binary digit, about 0.3 decimal digits, per step. Guaranteeing a tolerance \(\delta\) takes \(k \ge \log_2\bigl((b_0 - a_0)/\delta\bigr)\) steps, so 22 for \(\delta = 10^{-6}\) on a bracket of width 3. Only the bound is monotone. In Case 1, \(f(x) = x^3 + 4x^2 - 10\) on \([-1, 2]\), the error at step 12 is \(2.40 \times 10^{-4}\), within the bound \(3/2^{12} \approx 7.32 \times 10^{-4}\), but it grew at steps 3, 6 and 8.

The guarantee needs both hypotheses, and Case 2, \(f(x) = \tan x\) on \([0, 2]\), breaks both. Its root lies exactly at \(a_0 = 0\), so \(f(a_0)\,f(b_0) = 0\) rather than negative, and the rule takes the right half \([1, 2]\) and leaves that root. On \([1, 2]\), \(\tan x\) changes sign across its asymptote at \(x = \pi/2\), not at a root, and the brackets close in on the asymptote: \(c_{12} \approx 1.570801\), where \(|f(c_{12})| \approx 2.2 \times 10^5\). A narrow bracket alone does not prove a root; checking that \(|f(c_k)|\) is small exposes this false one.

False Position keeps the same sign-change bracket but cuts it at the secant line’s \(x\)-intercept instead of the midpoint, Brent’s Method uses bisection as the safeguard behind faster interpolation steps, and Newton-Raphson and the Secant Method converge faster near a simple root but, without a bracket, can lose it.

Animations

Each animation below shows the bracket-halving diagram for the bisection method. The shaded region marks the current bracket \([a, b]\); when \(f\) is continuous on \([a, b]\) and \(f(a)\), \(f(b)\) have opposite signs, the Intermediate Value Theorem guarantees that it contains a root. Each frame computes the midpoint \(c = \tfrac{a+b}{2}\), evaluates \(f(c)\), and narrows the bracket to the half that still contains the sign change. The top panel shows the full view; the bottom panel zooms in on the bracket from before the current step, so each halving stays visible after the bracket becomes narrower than a pixel in the full view (from step 9 on).

Julia source scripts that generated these animations are linked under each case.

Case 1 — Convergent, \(f(x) = x^3 + 4x^2 - 10\), \([a_0, b_0] = [-1, 2]\)

Behavior: \(f(-1) = -7 < 0\) and \(f(2) = 14 > 0\), so the IVT guarantees a root in \([-1, 2]\). The true root is \(x^* \approx 1.3652\). The bracket width halves each step, so the error bound \(|c_k - x^*| \le (b_0 - a_0)/2^k\) shrinks monotonically; the midpoints themselves are not monotone and fall on both sides of the root.

Julia source

Bisection animation on f(x)=x³+4x²−10: bracket narrows around the root at x≈1.3652 over 12 steps, with a lower panel zoomed on each halving

Case 2 — Spurious convergence (cautionary), \(f(x) = \tan(x)\), \([a_0, b_0] = [0, 2]\)

Behavior: \(f(0) = \tan(0) = 0\), so the starting bracket has a genuine root at its left end. The first midpoint is \(c_1 = 1\). This implementation moves \(b\) only when \(f(a)\,f(c) < 0\); since \(f(0)\,f(1) = 0\) is not negative, it keeps \([1, 2]\) and walks away from that root. (A variant testing \(f(a)\,f(c) \le 0\) would keep \([0, 1]\) and converge to the root at 0.) On \([1, 2]\), \(f(1) = \tan(1) > 0\) and \(f(2) = \tan(2) < 0\), but this sign change is caused by the vertical asymptote at \(x = \tfrac{\pi}{2} \approx 1.5708\), not a root: \(\tan\) has no zero in \([1, 2]\). Bisection converges to the asymptote — illustrating that the IVT guarantee requires \(f\) to be continuous on \([a, b]\).

Julia source

Bisection animation on f(x)=tan(x) starting on [0, 2]: the first step leaves the root at x=0, then the method converges to the asymptote at π/2, not a root, as a cautionary example, with a lower panel zoomed on each halving

References

Mathew, John H. 2000-2019. Numerical Analysis - Numerical Methods Modules. https://web.archive.org/web/20190808102217/http://mathfaculty.fullerton.edu/mathews/n2003/NumericalUndergradMod.html.