Industrial Training




Regula Falsi Method


This method is improvement over slow convergence of bisection method. To find root, input is search Interval containing the root [a,b], then tangent is drawn joining (a,f(a)) & (b,f(b)). The point where the tangent touches the x-axis is point of interest.


Given a function f (x) continuos 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)

The criteria for convergence are still same:-


  • C1. Fixing a priori the total number of iterations N i.e., the length of the interval or the maximum error after N iterations in this case is less than |b−a|/2N.
  • C2. By testing the condition |ci−ci−1| (where i are the iteration number) less than some tolerance limit, say epsilon, fixed threshold.
  • C3. By testing the condition |f(ci)| less than some tolerance limit alpha again fixed threshold.

C Implementation


#include < stdio.h>
#include < stdlib.h>
#include < math.h>
#define f(x) ((x*x*x)-18)
int main(){
float a=0,b=0,error=0,c,cold;
int i=0;
printf("Input Interval: ");
scanf("%f %f",&a,&b);
if((f(a)*f(b))>0){
        printf("Invalid Interval Exit!");
        exit(1);
}
else if(f(a)==0 || f(b)==0){
        printf("Root is one of interval bounds. Root is %f\n",f(a)==0?a:b);
        exit(0);
}
printf("Ite\ta\t\tb\t\tc\t\tf(c)\t\terror\n");
do{
        cold=c;
        c=(((a*f(b))-(b*f(a)))/(f(b)-f(a)));
        printf("%2d\t%4.6f\t%4.6f\t%4.6f\t%4.6f\t",i++,a,b,c,f(c));
        if(f(c)==0){
                break;
        }else if(f(a)*f(c)< 0){
                b=c;
        }else a=c;
                error=fabs(c-cold);
        if(i==1){
                printf("----\n");
        }else printf("%4.6f\n",error);

}while(error>0.00005);
printf(" Root is %4.6f \n",c);
return 0;
}

Output


Input Interval: 1 3
Ite    a               b               c               f(c)            error
0      1.000000        3.000000        2.307692        -5.710514       ----
1      2.307692        3.000000        2.576441        -0.897459       0.268749
2      2.576441        3.000000        2.614847        -0.121172       0.038406
3      2.614847        3.000000        2.619964        -0.016010       0.005117
4      2.619964        3.000000        2.620639        -0.002108       0.000675
5      2.620639        3.000000        2.620728        -0.000275       0.000089
6      2.620728        3.000000        2.620739        -0.000040       0.000011
Root is 2.620739


Hi I am Pluto.