Tweet
#include<stdio.h>
#include<math.h>
float f(float x)
{
return (x*x*x)-(3*x)+1;
}
main()
{
printf("\nProgram to implement Regula-Falsi method : \n");
float a,b,m;
int i,c=1;
printf("\nEnter the lower and upper approximation root : \n");
scanf("%f%f",&a,&b);
if(f(b)>f(a))
{
m=a;
a=b;
b=m;
}
if((f(a)>0 && f(b)>0)||(f(a)<0 && f(b)<0))
{
printf("\nNo root present...");
return;
}
while((fabs(a-b)>0.001)&& c!=40)
{
c++;
m=(a*f(b)-b*f(a))/(f(b)-f(a));
if(f(m)>0) b=m;
else a=m;
}
printf("\nRoot = %f\n",m);
}
How to implement Regula Falsi Method in C Programming ?
Posted by
LAHAUL SETH
~
How to implement Regula Falsi Method in C Programming ?
2012-04-08T10:57:00+05:30
LAHAUL SETH
Numerical Methods
|
Programming in C
|
Comments
How to implement Regula Falsi Method in C Programming ?
2012-04-08T10:57:00+05:30
LAHAUL SETH
Numerical Methods
|
Programming in C
|