Connect via MCP →

Enter Calculation

Use x as the variable. Functions: sin, cos, tan, asin, acos, atan, exp, ln, log, sqrt, abs. Constants: pi, e. Operators: + - * / ^.
Choose a, b so that f(a)·f(b) ≤ 0 (the root must be bracketed).

Formula

Advertisement

Results

x (root) where f(x) ≈ 0
0.7390851332151449
approximate solution of f(x) = 0
f(x) at root -0.0000000000000263
Iterations used 50
Method Bisection (interval halving)

What is the bisection method?

The bisection method is one of the oldest and most reliable techniques for finding a root of a continuous function \(f(x)\) — a value \(x\) where \(f(x) = 0\). It works by starting with an interval \([a, b]\) in which the function changes sign, then repeatedly cutting the interval in half and keeping the half that still brackets the root. Because the sign change is preserved at every step, the method is guaranteed to converge as long as \(f\) is continuous and \(f(a)\) and \(f(b)\) have opposite signs. This calculator works for any dimensionless real function and uses radians for trigonometry.

Continuous curve crossing the x-axis between points a and b, with the midpoint shown
The bisection method brackets a root where \(f(a)\) and \(f(b)\) have opposite signs.

How to use this calculator

Enter your function in the f(x) box using x as the variable (for example x-cos(x), x^2-2, or exp(x)-3). Set the lower endpoint a and upper endpoint b so that the root lies between them — the product \(f(a)\cdot f(b)\) must be less than or equal to zero. Pick a maximum iteration count n and how many display digits you want. The tool returns the approximate root, the function value there (which should be near zero), and how many iterations were actually needed.

The formula

At each step the estimate is the midpoint $$x_n = \frac{a_n + b_n}{2}.$$ If \(|f(x_n)|\) is below the tolerance, \(x_n\) is accepted. Otherwise the algorithm keeps whichever half still has a sign change: if \(f(a_n)\cdot f(x_n) > 0\) the root is to the right (set \(a = x_n\)), otherwise it is to the left (set \(b = x_n\)). The bracket width shrinks as \(\frac{b-a}{2^n}\), so convergence is linear — roughly one extra correct binary digit per step.

Successive halving of an interval converging on a root
Each iteration halves the interval, keeping the half that still brackets the root.

Worked example

For \(f(x) = x - \cos(x)\) on \([-10, 10]\): \(f(-10) \approx -10.84\) (negative) and \(f(10) \approx 10.84\) (positive), so the root is bracketed. Halving repeatedly converges to \(x \approx 0.7390851332151607\), the famous Dottie number where \(x = \cos x\), with \(f(x)\) effectively zero.

How to Do the Bisection Method by Hand

The bisection method finds a root of \(f(x)=0\) by repeatedly halving an interval that is known to contain a root. It relies on the Intermediate Value Theorem: if \(f\) is continuous on \([a,b]\) and \(f(a)\) and \(f(b)\) have opposite signs, a root must lie between them.

  1. Verify the bracket. Confirm that \(f(a)\cdot f(b)<0\). If the product is positive, the interval is not guaranteed to contain a root — pick a different \([a,b]\).
  2. Compute the midpoint. \(m=\dfrac{a+b}{2}\).
  3. Evaluate the function. Find \(f(m)\). If \(f(m)=0\) (or is within tolerance), \(m\) is the root and you stop.
  4. Replace an endpoint by sign. If \(f(a)\cdot f(m)<0\), the root is in \([a,m]\), so set \(b\leftarrow m\). Otherwise the root is in \([m,b]\), so set \(a\leftarrow m\).
  5. Repeat steps 2–4 until \(|b-a|<\text{tol}\) or \(|f(m)|<\text{tol}\), or until you reach the maximum iteration count.

Example: \(f(x)=x^{3}-x-2\) on \([1,2]\). Check: \(f(1)=-2\), \(f(2)=4\), product \(<0\) — the bracket is valid.

Iter a b m=(a+b)/2 f(m) New interval
1 1.0000 2.0000 1.5000 −0.125 [1.5, 2]
2 1.5000 2.0000 1.7500 1.6094 [1.5, 1.75]
3 1.5000 1.7500 1.6250 0.6660 [1.5, 1.625]
4 1.5000 1.6250 1.5625 0.2522 [1.5, 1.5625]
5 1.5000 1.5625 1.5313 0.0591 [1.5, 1.5313]
6 1.5000 1.5313 1.5156 −0.0340 [1.5156, 1.5313]

After more iterations the interval closes on the true root 1.521380, which is also the only real root of the cubic \(x^{3}-x-2=0\) found by a 1.521380 direct solver.

Iterations vs. Tolerance and Bracket Width

Each bisection step halves the interval, so after \(n\) iterations the bracket width is \((b-a)/2^{\,n}\). To reach a tolerance \(\text{tol}\) on the location of the root you need approximately

$$n \approx \log_2\!\left(\frac{b-a}{\text{tol}}\right).$$

The count grows only with the logarithm of the precision, so even very tight tolerances require relatively few steps. The table shows the rounded-up iteration count for several combinations.

Initial width \(b-a\) Target tolerance \(\log_2((b-a)/\text{tol})\) Iterations needed
1 \(10^{-3}\) 9.97 10
1 \(10^{-6}\) 19.93 20
1 \(10^{-10}\) 33.22 34
10 \(10^{-6}\) 23.25 24
20 \(10^{-6}\) 24.25 25
100 \(10^{-8}\) 33.22 34
0.5 \(10^{-12}\) 38.86 39

For example, a width-20 bracket refined to \(10^{-6}\) needs \(\lceil\log_2(20/10^{-6})\rceil=\lceil 24.25\rceil=\) 25 iterations, and a width-1 bracket to \(10^{-10}\) needs \(\lceil 33.22\rceil=\) 34. Halving the starting width saves exactly one iteration; squaring the precision (one extra decimal) costs about 3.3 iterations.

Key Terms

  • Root. A value \(x^{*}\) where the function is zero, \(f(x^{*})=0\); also called a zero or solution of the equation.
  • Bracket / interval \([a,b]\). A pair of endpoints believed to enclose a root. For bisection it must satisfy the sign-change condition.
  • Sign change. The condition \(f(a)\cdot f(b)<0\), meaning \(f\) takes opposite signs at the endpoints. For a continuous \(f\) this guarantees at least one root in between (Intermediate Value Theorem).
  • Midpoint. The center of the current interval, \(m=(a+b)/2\); each step tests this point and discards the half that cannot contain the root.
  • Tolerance. The accuracy target that stops the iteration, applied either to the interval width \(|b-a|\) or the residual \(|f(m)|\).
  • Convergence (linear). Bisection converges linearly: the error is roughly halved each step (error \(\le (b-a)/2^{n}\)), giving steady but not accelerating progress — about one extra correct binary digit per iteration.
  • Iteration. One full cycle of computing the midpoint, evaluating the function, and updating an endpoint. The iteration count is capped by the maximum-iterations setting.

FAQ

Why do I get a "no sign change" error? Bisection needs \(f(a)\) and \(f(b)\) to have opposite signs. Adjust a and b until they straddle the root.

Can it find more than one root? No — it returns a single root inside the bracket and cannot detect roots where the curve only touches the axis without crossing.

Why is it slower than Newton's method? Bisection converges linearly, gaining about one binary digit per step, while Newton converges quadratically. Bisection is often used to get a safe starting point that faster methods then refine.

Last updated: