Regula-Falsi Method(The method of False Position)

Regula-Falsi method is the oldest method of finding the real root of an equation f(x)=0
In this method, we chose two points x0 and x1 such that f(x0) and f(x1) are on the opposite sides of the X axis and thus the value x for which f(x) is on the X axis is the solution. This method is very similar to the bisection method.
The method replaces the actual curve of x0 and x1 with a line and taking the point of the intersection of the chord with the X axis as the initial approximation. Thus by decreasing the length of the cord i.e. the distance between the points x0 and x1 the approximation is always closer to the actual value. The C code for this method is:

#include<stdio.h>
#include<conio.h> 
#include<math.h>
float f(float x)
{
return(2*x-log10(x)-6);
}
void main()
{
float x,x1,a,b,err=0.00005;
int itr=1,n;
clrscr();
printf("enter the values of a,b and maximum iterations\n");
scanf("%f%f%d",&a,&b,&n);
x=a-(((b-a)/(f(b)-f(a)))*f(a));
printf("iteration no. %d\tx=%f\n",itr,x);
itr++;
while(itr<n)
{
if(f(a)*f(x)<0)
b=x;
else
a=x;
x=a-(((b-a)/(f(b)-f(a)))*f(a));
printf("iteration no. %d\tx=%f\n",itr,x);
if(fabs(x1-x)<err)
{
printf("\nafter %d iterations, the value of root is %f\n",itr,x);
break;
}
else
itr++;
x1=x;
}
if(itr==n)
printf("\nsolution does not exist as iterations are not sufficient");
getch();
return 0;
}

kaliadevansh has written 15 articles

2 thoughts on “Regula-Falsi Method(The method of False Position)

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>