## "The convergce process in the bisection method is very slow. It depends only on the choice of end points of the interval [a,b]. The function f(x) does not have any role in finding the point c (which is just  the mid-point of a and b). It is used only to decide the next smaller interval [a,c] or [c,b]. A better approximation to c can be obtained by taking the straight line L joining the points (a,f(a)) and (b,f(b)) intersecting the x-axis. To obtain the value of c we can equate the two expressions of the slope m of the line L. "

Given a function f (x) continuous on an interval [a,b] such that f (a) * f (b) < 0
Do
 c = a*f(b) - b*f(a) f(b) - f(a)
if f (a) * f (c) < 0 then  b = c
else  a = c
while (none of the convergence criterion C1, C2 or C3 is satisfied)
Reference:Click
Coding:

#include<stdio.h>

#include<conio.h>

#include<math.h>
#include<string.h>
#include<process.h>

//  Declaration
#define EPS 0.00005
#define f(x)  3*x + sin(x) - exp(x)
int n;

void FAL_POS();

void main()
{
clrscr();
printf("\n Solution by ITERATION METHOD ");
printf("\n\n Equation is -> x*x*x - 2*x + 1 = 0\n");
printf("\n Enter the no. of iterations ");
scanf("%d",&n);
FAL_POS();
getch();
}

void FAL_POS()
{
long float x1,x2,x0;
float f1,f2,f0;
int itr=n,i;
for(x1=0.0;;)
{
f1=f(x1);
if(f1>0)
break;
else
x1=x1+0.1;
}
x0=x1-0.1;
f0=f(x0);
printf("\n\t\t----------------------------------------------------");
printf("\n \t\tITERATION\t x2\t\t\t   F(X)\n");
printf("\n\t\t----------------------------------------------------\n");
for(i=0;i<itr;i++)
{
x2=x0-((x1-x0)/(f1-f0))*f0;
f2=f(x2);
if(f0*f2>0)
{
x1=x2;
f1=f2;
}
else
{
x0=x2;
f0=f2;
}
if(fabs(f(2))>EPS)
printf("\n\t\t %d \t\t %f \t\t %f \n",i+1,x2,f2);
}
printf("\n\n\n\t\t----------------------------------------------------");
printf("\n\t\t ROOT  = %f ",x2);
printf("\n\t\t----------------------------------------------------");
}
Ragula falsi Method in C Reviewed by Tanuj on 5:31:00 pm Rating: 5