Sign up with your email address to be the first to know about new products, VIP offers, blog features & more.

 




Bisection Method – Algorithm, Flowchart and Code in C

Bisection Method Illustration

Bisection Method Illustration

The bisection method is one of the simplest and most reliable of iterative methods for the solution of nonlinear equations. This method, also known as binary chopping or half-interval method, relies on the fact that if f(x) is real and continuous in the interval a < x < b, and f(a) and f(b) are of opposite signs, that is,

f(a)*f(b) < 0

then there is at least one real root in the interval between a and b.

Bisection method is a closed bracket method and requires two initial guesses. It is the simplest method with slow but steady rate of convergence.

Features of Bisection Method:

  • Type – closed bracket
  • No. of initial guesses – 2
  • Convergence – linear
  • Rate of convergence – slow but steady
  • Accuracy – good
  • Programming effort – easy
  • Approach – middle point

Bisection Method Algorithm and Flowchart:

Algorithm:

Start

  1. Decide initial values for x1 and x2 and stopping criterion, E.
  2. Compute f1 = f(x1) and f2 = f(x2).
  3. If f1 * f2>0, x1 and x2 do not bracket any root and go to step 7;
    Otherwise continue.
  4. Compute x0 = (x1+x2)/2 and compute f0 = f(x0)
  5. If f1*f0 < 0 then
    set x2 = x0
    else
    set x1 = x0
    set f1 = f0
  6. If absolute value of (x2 – x1)/x2 is less than error E, then
    root = (x1 + x2)/2
    write the value of root
    go to step 7
    else
    go to step 4
  7. Stop.

Flow Chart

Bisection Method 1- Flowchart

Bisection Method 1- Flowchart

Above given Algorithm and Flowchart of Bisection Methods Root computation is a simple and easier way of understanding how the bracketing system works, algorithm and flowchart may not follow same procedure, yet they give the same outputs.

Tabular Example of Bisection Method Numerical Computation

Consider f(x) = x3 + 3x – 5, where [x1 = 1, x2 = 2] and E = 0.001.

i x1 x0 x2 f(x1) f(x0) f(x2)
1 1 1.5 2 –1  2.875  9
2 1 1.25 1.5 –1  0.703125  2.875
3 1 1.125 1.25 –1 –0.201171875  0.703125
4 1.125 1.1875 1.25 –0.201171875  0.237060546875  0.703125
5 1.125 1.15625 1.1875 –0.201171875  0.014556884765625  0.237060546875
6 1.125 1.140625 1.15625 –0.201171875 –0.0941429138183594   0.014556884765625
7 1.140625 1.1484375 1.15625 –0.0941429138183594 –0.0400032997131348  0.014556884765625
8 1.1484375 1.15234375 1.15625 –0.0400032997131348 –0.0127759575843811  0.014556884765625
9 1.15234375 1.154296875 1.15625 –0.0127759575843811  0.000877253711223602  0.014556884765625

Note: Bisection method guarantees the convergence of a function f(x) if it is continuous on the interval [a,b] (denoted by x1 and x2 in the above algorithm. For this, f(a) and f(b) should be of opposite nature i.e. opposite signs. The slow convergence in bisection method is due to the fact that the absolute error is halved at each step. Due to this the method undergoes linear convergence, which is comparatively slower than the Newton-Raphson, secant or false-position method.

Bisection Method – Code in C Programming

Method 1:
This program in C is used to demonstarte bisection method.
Bisection method is one of the many root finding methods.
In this method we are given a function f(x) and we approximate 2 roots a and b for the function such that f(a).f(b)<0.
Then we find another point
c=(a+b)/2
if f(c)==0
then root=c;
else
if f(a).f(c)<0
b=c;
if f(b).f(c)<0
a=c;
and we repeat these steps for the given number of iterations.

Method 2: Source Code for Bisection Method
for equation f(x) = x^3 – 4*x – 9

 

Thank you for your love.
share

No Comments Yet.

What do you think?

Your email address will not be published. Required fields are marked *