This method is known as Bolzano method, bracketing method, binary chopping method or half interval method.

Suppose we are given the continuous function f(x) in the interval [p, q] and we want to find root of the equation f(x)=0 by bisection method. The process is described as follows:-

1) Find two points a and b such that f(a) * f(b) < 0. That is find a and b so that f(a) and f(b) are of opposite sign. This process is called finding the initial root.

2) Compute the middle point c using relation c= (a+b)/2. If f(c) = 0 then ‘c’ is the required root & stop the process if f (c) 0 then go to next step.

3) If f(a) * f (c) <0 then root lies between a & c otherwise the root lies between c & b.

4) Repeat step 2 & 3 until the root is found to be desired of accuracy.

#include<stdio.h>

#include<conio.h>

float f(float x){

return (x*x*x-4*x-9);

}

void main(){

int i,n;

float a,b,c;

clrscr();

printf("Enter the no of iteration:");

scanf("%d",&n);

printf("enter two values where the root lies:");

scanf("%f %f",&a,&b);

if(f(a)*f(b)>0)

{

printf("the initial values are out of range");

getch();

exit(0);

}

else{

for(i=1;i<=n;i++){

c=(a+b)/2;

if(f(c)==0)

break;

if(f(a)*f(c)<0)

b=c;

else

a=c;

}

printf("the reqd. root is:%f",c);

getch();

}

}

Bisection Method || numerical Method
Reviewed by Santosh Adhikari
on
October 04, 2018
Rating:

## No comments: