Bisection Method

Summary

Bisection finds a root of a continuous function on a bracket [a,b] with f(a)f(b)<0 by repeatedly cutting the interval in half. It is slow but reliable.

Prerequisites

Problem Type

Solve f(x)=0 when a valid sign-changing interval is known.

Method Definition

Given continuous f on [a,b] with f(a)f(b)<0 , set c=(a+b)/2 . Replace [a,b] by the half that still has a sign change. Repeat until the half-width is below a tolerance.[1]

Assumptions / Requirements

Algorithm

  1. Input a,b,ε,max_iter with f(a)f(b)<0 .
  2. For k=1,2,… :
    • c←(a+b)/2
    • If |f(c)|<ε or (b−a)/2<ε , return c
    • If f(a)f(c)<0 then b←c , else a←c
  3. Stop with failure if the iteration budget is exceeded

Formula / Iteration Rule

ck=ak+bk2,error bound:|ck−r|≤b0−a02k

for some root r∈[ak,bk] .

Convergence

Linear (interval length halves each step). Convergence is guaranteed under the assumptions above.

Error / Accuracy

Stopping options:

Iteration count to guarantee half-width ≤ε :

n≥log2⁡(b0−a0ε)

Worked Example

Use f(x)=x3−2x−5 . Then f(1)=−6 , f(2)=−1 , f(3)=16 . A valid bracket is [2,3] , not [1,2] .[1:1]

With ε=10−3 :

n≥log2⁡(10.001)≈9.97⇒n=10

First steps:

k a b c f(c) new interval
1 2 3 2.5 4.875 [2,2.5]
2 2 2.5 2.25 1.546875 [2,2.25]
3 2 2.25 2.125 0.18164… [2,2.125]

The unique real root is near 2.09455 .

Pseudocode

function bisection(f, a, b, tol, max_iter):
    require f(a)*f(b) < 0
    for k = 1 to max_iter:
        c = (a + b) / 2
        if abs(f(c)) < tol or (b - a)/2 < tol:
            return c
        if f(a)*f(c) < 0:
            b = c
        else:
            a = c
    return (a + b) / 2   # not converged

Common Failure Modes

Visual Explanation

The interval-halving invariant is shown in Bisection convergence (Manim).

Connections

References


  1. Burden & Faires, Numerical Analysis, bisection method; NIST DLMF Ch. 3, https://dlmf.nist.gov/3 ↩︎ ↩︎