Q.This program is for f(x)=x2+4x+4
#include<
#include<
#include<
float g(float m)
{
float n;
n=-4/(m+4);
return n;
}
int main()
{
int n,i;
float x0,x1,e;
printf("Enter the value of x0,e,n");
scanf("%f%f%d",&x0,&e,&n);
x1=g(x0);
for(i=1;i<=n;i++)
{
x0=x1;
x1=g(x0);
printf(" i=%d x1=%f\n",i,x1);
if(fabs((x1-x0)/x1)<=e)
{
printf("\nConverge to root at iteration %d and x=%f\n",i,x1);
exit(1);
}
}
printf("Doesnot converge to a root\n");
return 0;
}
Nov 18, 2008
Method of Successive Approximation
Posted by
bikash pradhan
at
1:24 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)
1 comments:
What does that function "g" return?
Post a Comment