Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

Recipe

Run the bisection method

Use when: you have a bracket [a,b] (f(a), f(b) of opposite sign) and need a root to a stated tolerance

Goal: an approximation within the required tolerance of a root, with a guaranteed error bound at every step

Taught in The Bisection Method

  1. 1

    Evaluate f(a) and f(b) and check that they have opposite signs. If they don't, bisection has nothing to work with — go back and find a real bracket first.

    Example

    For f(x)=x^3-x-2 on [1,2]: f(1)=1-1-2=-2 and f(2)=8-2-2=4. Opposite signs — this is a valid bracket.

    Why: every later step depends on the bracket actually containing a sign change; bisection has no way to detect or recover from starting on an invalid one.

  2. 2

    Compute c=\dfrac{a+b}{2} and evaluate f(c).

    Example

    c=\dfrac{1+2}{2}=1.5. f(1.5)=1.5^3-1.5-2=3.375-1.5-2=-0.125.

    Why: c is the single new piece of information each step needs — it's the point whose sign decides which half of the bracket survives. (Section 8 revisits this exact step with a smarter candidate point than the plain midpoint, keeping every other part of this recipe unchanged.)

  3. 3

    Compare the sign of f(c) to the sign of f(a). If they match, set a\leftarrow c (the root is in the other half, (c,b)). If f(c) matches f(b)'s sign instead, set b\leftarrow c.

    Example

    f(1)=-2 is negative, and f(1.5)=-0.125 is also negative — they match, so a\leftarrow1.5. The new bracket is [1.5,2], half the width of [1,2].

    • f(c)=0 exactly — stop immediately; c is a root, not just an approximation of one.
    • f(c) matches neither sign because f(c)=0 landed exactly between — the exact-root case above already covers this; there is no third outcome.

    Why: keeping the half whose endpoints still disagree in sign is what guarantees, by the same Intermediate Value Theorem argument that found the original bracket, that a root still lies inside the new one.

  4. 4

    Go back to Step 2 with the new bracket, and keep going until |b-a| (or |f(c)|, depending on which stopping rule was asked for) is below the required tolerance.

    Example

    Continuing from [1.5,2]: c=1.75, f(1.75)\approx1.609>0, matches f(2)=4>0, so b\leftarrow1.75, giving [1.5,1.75]. Next, c=1.625, f(1.625)\approx0.666>0, again matches f(b), giving [1.5,1.625]. After 8 steps total the bracket has narrowed to [1.515625,\,1.5234375], width \approx0.0078, closing in on the true root x\approx1.52138.

    • stopping on bracket width |b-a|<\varepsilon — guarantees the root is within \varepsilon of either endpoint, by the theorem above.
    • stopping on |f(c)|<\varepsilon — guarantees c makes f small, which is a reasonable proxy for closeness to a root but not identical to it (a very steep f can have small |f(c)| while c itself is still relatively far from the root).

    ⚡ Shortcut

    The convergence bound also runs in reverse: to hit a target tolerance \varepsilon, solve \dfrac{b-a}{2^n}<\varepsilon for n directly, before running a single step, instead of stepping and checking after each one: n > \log_2\!\left(\frac{b-a}{\varepsilon}\right) For the bracket [1,2] (width 1) and \varepsilon=0.0001: n>\log_2(1/0.0001)=\log_2(10{,}000)\approx13.29, so n=14 steps are needed — checked directly: 1/2^{13}\approx0.000122 is still too wide, but 1/2^{14}\approx0.000061 clears the tolerance. Knowing the exact iteration count ahead of time is useful for budgeting how expensive a bisection run will be, especially when each evaluation of f is costly (a simulation, an experiment) — no other method in this chapter allows this kind of advance guarantee, because none of them shrinks by a fixed, function-independent factor every step.

    Why: each pass through this step is exactly what the convergence theorem above is a guarantee about — the bracket width after n passes is provably (b-a)/2^n, so continuing is what actually delivers on that promise.

Common mistakes

  • Starting bisection on an interval that was never confirmed to be a valid bracket — the method runs without complaint but converges to nothing meaningful.
  • Replacing the wrong endpoint — a slip here (setting b\leftarrow c when the sign match was actually with f(b), not f(a)) throws away the half that actually contains the root.
  • Re-evaluating f at both a and b every step. Only f(c) is new information each step; whichever endpoint survives keeps the function value it already had, computed on a previous step.
  • Stopping after a fixed number of iterations chosen by guesswork instead of checking the actual tolerance required — the shortcut above computes the right number directly instead of guessing.
  • Treating a small |f(c)| and a small bracket width as automatically the same guarantee — they usually track together but aren't identical (see the case note above).