Featured Post

Step Wise Project Planning

Planning is the most difficult process in project management. The framework described is called the Stepwise method to help to distinguis...

  1. Home

Bisection Method

To Find out the root of the Algebraic And Transcendental equations using Bisection Method

#include<stdio.h>
#include<conio.h>
#include<math.h>
float f(float x)
{
return (x*x*x-4*x-9);
}
void bisect(float*x,float a,float b,int*itr)
{
*x=(a+b)/2;
++(*itr);
printf("Iteration no. %3d x=%7.5f \n",*itr,*x);
}
main()
{
int itr=0,maxitr;
float x,a,b,aerr,x1;
clrscr();
printf("Enter the value of a,b,allowed error,maxium iterations \n");
scanf("%f%f%f%d",&a,&b,&aerr,&maxitr);
bisect(&x,a,b,&itr);
do
{
if(f(a)*f(x)<0)
b=x;
else
a=x;
bisect(&x1,a,b,&itr);
if(fabs(x1-x)<aerr)
{
printf("After %d iterations,root=%6.4f \n",itr,x1);
return 0;
}
x=x1;
}
while(itr<maxitr);
printf("Solution does not converge”,”iterations not sufficient");
return 1;
}
Output


Bisection Method







Previous
Next Post »