// REGULAR FALSI METHOD OF FINDING ROOTS OF AN EQUATION // #include<iostream.h> #include<conio.h> #include<math.h> float fun(float a) { float x,y; x=a; y=(pow(x,3)+2*x*x+10*x-20); return y; } main() { cout<<"===================================================================\n "; cout<<"Program to find root of the equation x^3+2x^2+10x-20=0 in specified i nterval\n"; cout<<"===================================================================\n "; float x0,x1,x2,y0,y1,y2,e; int i=0; cout<<"Enter the lower limit of the interval\n"; cin>>x0; cout<<"Enter the upper limit of the innterval\n"; cin>>x1; cout<<"Enter error allowed in the answer\n"; cin>>e; y0=fun(x0); y1=fun(x1); if((y0*y1)>0) { cout<<"Sorry no solution in the specified interval\n"; cout<<"y0="<<y0<<"\t y1="<<y1<<"\n"; } else { do { x2=x0-((x1-x0)/(fun(x1)-fun(x0)))*fun(x0); y2=fun(x2); if((y0*y2)>0) x0=x2; else x1=x2; i++; cout<<"Value of the funnction after "<<i<<" iteration ="<<y2<<"\n"; }while((fabs(fun(x2)))>e); cout<<"The solution of the equation x^3+2x^2+10x-20=0 in the entered interva l is:"<<x2<<"\n"; cout<<"The number of iteration ="<<i<<"\n"; } getch(); return 0; }