Advertise

Responsive Ad

Regula Falsi Method In C++

Regula Falsi Method In C++

Regula Falsi Method , False Position Method
Regula Falsi Method


C Prrogramme of Regula Falsi Method :


#include<stdio.h>
#include<conio.h>
#include<math.h>
#define esp 0.0001
#define f(x) ((x*x*x)-18)
main()
{
float x0,x1,x2,f1,f2,f0;
int count=1;
do
{
printf("\n Enter the value of x0: ");
scanf("%f",&x0);
}
while(f(x0)>0);
do
{
printf("\n Enter the value of x1: ");
scanf("%f",&x1);
}
while(f(x1)<0);
printf("\n************************************************************ \n");
printf(" n x0\t  x1\t  x2\t  f0\t  f1\t  f2");
printf("\n************************************************************ \n");
do
{
f0=f(x0);
f1=f(x1);
x2=x0-((f0*(x1-x0))/(f1-f0));
f2=f(x2);
printf("\n %d %f %f %f %f %f %f",count,x0,x1,x2,f0,f1,f2);
if(f0*f2<0)
x1=x2;
else
x0=x2;
count++;
}
while(fabs(f2)>esp);
printf("\n************************************************************ \n");
printf("\n\n Approximate Root = %f",x2);
getch();
}

Output Value:



Post a Comment

0 Comments