#include
#include
#include
float f(float m)
{
float n;
n=m*m-25;
return n;
}
int main()
{
int n,i;
float x0,x1,x2,e,f0,f1,f2;
printf("Enter the values of x0,x1,e,n\n");
scanf("%f %f %f %d",&x0,&x1,&e,&n);
f0=f(x0);
f1=f(x1);
printf("Iteration x0 x1 x2 f0 f1 f2\n");
for(i=1;i<=n;i++)
{
x2=(x0*f1-x1*f0)/(f1-f0);
f2=f(x2);
printf("%d %f %f %f %f %f %f\n",i,x0,x1,x2,f0,f1,f2);
if(fabs(f2)<=e)
{
printf("\n\nConvergent solution at %d iteration and x= %f\n",i,x2);
exit(1);
}
if((f0*f2)<0)
{
x1=x2;
f1=f2;
}
else
{
x0=x2;
f0=f2;
}
}
printf("\n\n Does not converge in %d iteration, x2= %f, f2= %f",i,x2,f2);
}
Nov 18, 2008
Regula Falsi on False Position Method
Posted by
bikash pradhan
at
1:28 AM
Subscribe to:
Post Comments (Atom)
Search
Programs
- backward difference formula c program code (1)
- Bisection Method c program code (1)
- Cramers rule (1)
- False position (1)
- Forward Difference Formula c program code (1)
- Gauss Seidal Method c program code (1)
- Guass Elimination Method c program code (1)
- Method of Successive Approximation c program code (1)
- Newton Raphson Method c program code (1)
- Newton's Backward Interpolation Formula c program code (1)
- Newton's Forward Interpolation Formula c program code (1)
- Regula Falsi on False Position Method c program code (1)
- Simpson's 1/3 Rule c program code (1)
- Simpson's Simpsons' 3/8 rule c program code (1)
- Trapezoidal Rule C program code (1)
0 comments:
Post a Comment