FALSE POSITION OR REGULA FALSI PROGRAM IN C
FALSE POSITION
REGULA FALSI PROGRAM IN C
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define f(x) ((x*x*x)-(2*x)-5)
void main()
{
float x1,x2,ep,x3;
printf("Enter x1 and x2 :");
scanf("%f%f",&x1,&x2);
printf("nEnter Ep value : ");
scanf("%f",&ep);
if((f(x1)*f(x2))>0)
printf("Initial approximation os unsuitable :");
do
{
x3=((x1*f(x1))-(x2*f(x1)))/(f(x2)-f(x1));
if((f(x1)*f(x3))>0)
{
x2=x3;
// f(x2)==f(x3);
}
else
{
x1=x3;
// f(x1)==f(x3);
}
}
while((fabs(x1-x2)>ep) && f(x3)!=0);
printf("value of x3 : %f",x3);
getch();
}