METHOD OF FALSI POSITION OR REGULA -FALSI METHOD Prepared by – Mr. Ashok Kumar MCA II Sem The bisection method guarantees that the iterative process will converge. It is however slow. Thus attempts have been made to speed up bisection method retaining its guaranteed convergence. A method of doing this is called the method of false position. It is sometimes is known as method of linear interpolation. This is the oldest method for finding the real root of a numerical equation and closely resembles the bisection methods. In this method, we choose two points x0 and x1 such that f(x0) and f(x1) are of opposite signs. Since the graph of y=f(x) crosses the X-axis between these two points, a root must lie in between these points. Consequently, f(x0)f(x1)<0. Equation of the chord joining points {x0,f(x0)} and {x1,f(x1)} is----- Y- f(x0) = (f(x1)-f(x0))*(x-x0)/(x1-x0) The abscissa of the point where chord cuts y=0 is given by X2=x0 - ((x1-x0)*f(x0))/(f(x1)-f(x0)) Which is an approximation to the root. If now f(x0) and f(x2) are of opposite signs, then the root lies between x0 and x2. So replacing x1 by x2, we obtain the next approximations x3.However the root could as well lie between x1 and x2 then we find x3 accordingly. This procedure is repeated till the root is found to the desired accuracy. ALGORITHM Step 1- Start of the program. Step 2- Input the variables x0,x1,e,n for the task. Step 3- f0=f(x0) Step 4- f1=f(x1) Step 5- for i=1 and repeat if i <=n. Step 6- x2=(x0 f1-x1 f0)/(f1-f0) Step 7- f2=x2. Step 8- if|f2|<=e Step 9- Print “convergent”,x2,f2 Step 10- if sign (f2)!=sign(f0) Step 11- x1=x2 & f1=f2 Step 12- else Step 13- x0=x2 & f0=f2 Step 14- End loop Step 15- Print output Step 16- End of the program. FLOW CHART COMPUTER PROGRAME /*Program to find root of an equation by REGULA-FALSI method #include<stdio.h> #include<conio.h> float pow(float,int); void main() { int n,i,j=0,z; float f,f1,f2,x,y,m,a[10],p,p1,p2; clrscr(); printf("Enter degree of the equation ="); scanf("%d",&n); printf("\nEnter the interval of the equation ----\n"); scanf("%f%f",&x,&y); printf("Enter value of a,b,c,d........\n"); for(i=n;i>=0;i--) scanf("%f",&a[i]); printf("Enter no. of ITERATIONs = "); scanf("%d",&z); while(j<z) { f1=0; f2=0; f=0; for(i=n;i>=0;i--) { p=pow(x,i); p1=pow(y,i); f1=f1+a[i]*p; f2=f2+a[i]*p1; m=y-(y-x)*f2/(f2-f1); p2=pow(m,i); f=f+a[i]*p2; } if(f1*f<0) { y=m; m=y-(y-x)*f2/(f2-f1); } else if(f2*f<0) { x=m; m=y-(y-x)*f2/(f2-f1); } else {printf("\nSolution not possible."); goto l;} j++; } printf("\n\nThe root of equation is ==%f",m); l : getch(); } //..............................power() ..................... float pow(float a,int b) { int i,j; float p=1; for(i=b;i>0;i--) p=p*a; return p; }

METHOD OF FALSI POSITION OR REGULA -FALSI METHOD

Prepared by – Mr. Ashok Kumar MCA II Sem

The bisection method guarantees that the iterative process will converge. It is however slow. Thus attempts have been made to speed up bisection method retaining its guaranteed convergence. A method of doing this is called the

method of false position.It is sometimes is known as

method of linear interpolation.This is the oldest method for finding the real root of a numerical equation and closely resembles the bisection methods.

In this method, we choose two points x0 and x1 such that f(x0) and f(x1) are of opposite signs. Since the graph of y=f(x) crosses the X-axis between these two points, a root must lie in between these points.

Consequently, f(x0)f(x1)<0.

Equation of the chord joining points {x0,f(x0)} and {x1,f(x1)} is-----

Y- f(x0) = (f(x1)-f(x0))*(x-x0)/(x1-x0)The abscissa of the point where chord cuts y=0 is given by

X2=x0 - ((x1-x0)*f(x0))/(f(x1)-f(x0))Which is an approximation to the root.

If now f(x0) and f(x2) are of opposite signs, then the root lies between x0 and x2. So replacing x1 by x2, we obtain the next approximations x3.However the root could as well lie between x1 and x2 then we find x3 accordingly.

This procedure is repeated till the root is found to the desired accuracy.

ALGORITHMStep 1-Start of the program.Step 2-Input the variables x0,x1,e,n for the task.Step 3- f0=f(x0)Step 4- f1=f(x1)Step 5-for i=1 and repeat if i <=n.Step 6- x2=(x0 f1-x1 f0)/(f1-f0)Step 7- f2=x2.Step 8- if|f2|<=eStep 9- Print “convergent”,x2,f2Step 10- if sign (f2)!=sign(f0)Step 11- x1=x2 & f1=f2Step 12- elseStep 13- x0=x2 & f0=f2Step 14- End loopStep 15- Print outputStep 16- End of the program.FLOW CHARTCOMPUTER PROGRAME/*Program to find root of an equation byREGULA-FALSI method#include<stdio.h>

#include<conio.h>

float pow(float,int);

void main()

{

int n,i,j=0,z;

float f,f1,f2,x,y,m,a[10],p,p1,p2;

clrscr();

printf("Enter degree of the equation =");

scanf("%d",&n);

printf("\nEnter the interval of the equation ----\n");

scanf("%f%f",&x,&y);

printf("Enter value of a,b,c,d........\n");

for(i=n;i>=0;i--)

scanf("%f",&a[i]);

printf("Enter no. of ITERATIONs = ");

scanf("%d",&z);

while(j<z)

{

f1=0;

f2=0;

f=0;

for(i=n;i>=0;i--)

{

p=pow(x,i);

p1=pow(y,i);

f1=f1+a[i]*p;

f2=f2+a[i]*p1;

m=y-(y-x)*f2/(f2-f1);

p2=pow(m,i);

f=f+a[i]*p2;

}

if(f1*f<0)

{

y=m;

m=y-(y-x)*f2/(f2-f1);

}

else if(f2*f<0)

{

x=m;

m=y-(y-x)*f2/(f2-f1);

}

else

{printf("\nSolution not possible.");

goto l;}

j++;

}

printf("\n\nThe root of equation is ==%f",m);

l :

getch();

}

//..............................power() .....................

float pow(float a,int b)

{

int i,j;

float p=1;

for(i=b;i>0;i--)

p=p*a;

return p;

}