Posts

Showing posts from January 27, 2019

C Program To Calculate Values Using Fixed Point Iteration and Honors Method | C Programming

C Program To Calculate Values Using Fixed Point Iteration Method Algorithm Start Read values of x0 and e. *Here x0 is the initial approximation e is the absolute error or the desired degree of accuracy, also the stopping criteria* Calculate x1 = g(x0) If [x1 – x0] <= e, goto step 6. *Here [ ] refers to the modulus sign* Else, assign x0 = x1 and goto step 3. Display x1 as the root. Stop #include<stdio.h> #include<math.h> #include<conio.h> #define EST 0.05 #define F(x) exp(-x)-x #define G(x) exp(-x) int main() { int i=1; float error,x0,x1,temp; printf("Enter the initial guess x0:\n"); scanf("%f",&x0); printf("Iteration x0\t\t x1\t Error\n"); x1=G(x0); error=fabs((x1-x0)/x1); printf("%d\t %.4f\t%.4f\t %.4f\n",i,x0,x1,error); do { i++; temp=x1; x0=temp; x1=G(x0); error=fabs((x1-x0)/x1); printf("%d\t %.4f\t%.4f\t %.4f\n",i,x0,x1,error); }while (error>EST); } C Program To Calculate Values Using Ho