Lably
Skip to content

Bisection method

Algorithm for finding a zero of a function

  • 5 min read
  • 2 chapters

Related on Lably

Through Mathematics, Continuous function and Bisection

For polynomials, more elaborate methods exist for testing the existence of a root in an interval (Descartes' rule of signs, Sturm's theorem, Budan's theorem). They allow extending the bisection method into efficient algorithms for finding all real roots of a polynomial; see Real-root isolation.

The method

The method is applicable for numerically solving the equation f(x)=0 for the real variable x, where f is a continuous function defined on an interval [a,b] and where f(a) and f(b) have opposite signs. In this case a and b are said to bracket a root since, by the intermediate value theorem, the continuous function f must have at least one root in the interval (a,b).

At each step the method divides the interval in two parts/halves by computing the midpoint c=(a+b)/2 of the interval and the value of the function f(c) at that point. If c itself is a root then the process has succeeded and stops. Otherwise, there are now only two possibilities: either f(a) and f(c) have opposite signs and bracket a root, or f(c) and f(b) have opposite signs and bracket a root. The method selects the subinterval that is guaranteed to be a bracket as the new interval to be used in the next step. In this way an interval that contains a zero of f is reduced in width by 50% at each step. The process is continued until the interval is sufficiently small.

Explicitly, if f(c)=0 then c may be taken as the solution and the process stops.

Otherwise, if f(a) and f(c) have the same signs,

  • then the method sets a=c,
  • else the method sets b=c.

In both cases, the new f(a) and f(b) have opposite signs, so the method may be applied to this smaller interval.

Once the process starts, the signs at the left and right ends of the interval remain the same for all iterations.

Stopping conditions

In order to determine when the iteration should stop, it is necessary to consider various possible stopping conditions with respect to a tolerance (ϵ). Burden and Faires (2016) identify the three stopping conditions:

  • Absolute tolerance: |pN−pN−1|<ϵ
  • Relative tolerance: |pN−pN−1pN|<ϵ, for pN≠0
  • |f(pN)|<ϵ.

|f(pN)|<ϵ does not give an accurate result to within ϵ unless |f′(pN)|≥1. The other two possibilities represent different concepts: the absolute difference |c−a|≤5×10−t says that c and a are the same to t decimal places, while the relative difference |c−ac|≤5×10−t says that c and a are the same to t significant figures. If nothing is known about the value of the root, then relative tolerance is the best stopping condition.

Iteration process

The input for the method is a continuous function f and an interval [a,b], such that the function values f(a) and f(b) are of opposite sign (there is at least one zero crossing within the interval). Each iteration performs these steps:

  1. Calculate c, the midpoint of the interval, c=a+b2;
  2. Calculate the function value at the midpoint, f(c);
  3. If f(c)=0, return c;
  4. If convergence is satisfactory (that is, |c−a|≤5×10−t|c|), return c;
  5. Examine the sign of f(c) and replace either a or b with c so that there is a zero crossing within the new interval.

Example

Suppose that the bisection method is used to find a root of the polynomial

f(x)=x3−x−2.

First, two numbers a and b have to be found such that f(a) and f(b) have opposite signs. For the above function, a=1 and b=2 satisfy this criterion, as

f(1)=(1)3−(1)−2=−2

and

f(2)=(2)3−(2)−2=+4.

Because the function is continuous, there must be a root within the interval [1, 2]. Iterating the bisection method on this interval gives increasingly accurate approximations:

After 13 iterations, it becomes apparent that there is a convergence to about 1.521: a root for the polynomial.

Sign in to keep reading

One more chapter is free with a Lably account.

More in Calculus and analysis