Bisection Method Calculator
Overview
The bisection method is a reliable numerical algorithm for finding a real root of a function by repeatedly halving an interval that brackets a sign change. It is based on the Intermediate Value Theorem: if a function is continuous on an interval and takes opposite signs at the endpoints, then it must cross zero somewhere between them.
Requirements (Assumptions)
- Continuity:
f(x)should be continuous on[a,b]. - Bracketing a root: the endpoints must satisfy
f(a)·f(b) < 0(opposite signs). - Real root target: bisection finds a real root in the interval if the above conditions hold.
Core idea and formulas
Start with an interval [a,b] where the root is bracketed. At each iteration, compute the midpoint:
Evaluate f(m). If f(a)·f(m) < 0, the root remains in [a,m] so set b = m. Otherwise (if f(m)·f(b) < 0), set a = m. Repeat.
Stopping criteria and error bound
After n iterations, the interval width is:
(b-a)/2^n
A common absolute error bound for the midpoint estimate is:
|x* - m_n| ≤ (b-a)/2^(n+1), where x* is the true root.
Your tolerance can be interpreted as an interval-width target (e.g., stop when |b-a| ≤ tol) or a function-residual target (e.g., stop when |f(m)| ≤ tol). If your calculator uses one specific rule, interpret the output accordingly.
How to interpret results
- Approximate root: typically the final midpoint
m. - Iterations used: how many bisections were required before stopping.
- Final interval: the remaining bracket
[a,b]that still contains a root (under the assumptions). - Residual:
f(m); smaller residual generally indicates you are closer to a true root, but the interval-width bound is the convergence guarantee.
Worked example
Find a root of f(x)=x^3-2x-5 on [2,3].
f(2)=8-4-5=-1f(3)=27-6-5=16
Because the signs differ, a root is bracketed. Midpoint m=2.5, and f(2.5)=15.625-5-5=5.625 (positive), so the root lies in [2,2.5]. Repeating this halving process quickly narrows the interval until the requested tolerance or maximum iterations is reached. The true root is approximately 2.09455…, so you should see an answer near that value with a small final bracket.
Method comparison
| Method | Needs derivative? | Convergence | Pros | Cons |
|---|---|---|---|---|
| Bisection | No | Linear (guaranteed if bracketed) | Robust, simple, predictable error bound | Slower than Newton/secant |
| Newton–Raphson | Yes | Quadratic (near root) | Very fast when it works | Can diverge; sensitive to initial guess |
| Secant | No | Superlinear (often) | Fast without derivatives | No guaranteed bracket; can fail on some functions |
Limitations and common pitfalls
- No sign change, no guarantee: if
f(a)·f(b) > 0, there may be zero, one (even multiplicity), or multiple roots; bisection cannot certify a root without a sign change. - Discontinuities: a sign change across a discontinuity (e.g.,
tan(x)acrossπ/2) can produce misleading behavior. Continuity on[a,b]is essential. - Multiple roots: if multiple roots exist in the interval, bisection will converge to some root, but which one depends on the function and interval.
- Flat regions: bisection still works, but
|f(m)|may not decrease smoothly; the interval-width error bound is the more dependable indicator. - Rounding/parse issues: ensure your function syntax is valid (e.g.,
x^2,sin(x),exp(x)) and use parentheses where needed.
FAQ
What if f(a) and f(b) have the same sign?
Then the interval does not bracket a sign change, so bisection cannot guarantee a root. Try expanding the interval or plotting/inspecting values to find endpoints with opposite signs.
How many iterations do I need for a given tolerance?
To make the interval width ≤ tol, you can use: n ≥ log2((b-a)/tol). Some implementations use the midpoint error bound, which differs by a factor of 2.
Which tolerance is better: interval width or |f(m)|?
Interval width gives a direct worst-case bound on the root location (under continuity + bracketing). |f(m)| can be useful, but may be misleading if the function is very flat or steep.
Does bisection always converge?
It converges to a root as long as f is continuous on [a,b] and f(a)·f(b) < 0.
Reference
Burden, R. L., & Faires, J. D. Numerical Analysis. (Bisection method and bracketing root-finding.)
