Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- double f(double a){return 0.7-a+sin(a);}
- double fturev(double a){return -1+cos(a);}
- int main()
- {
- double epsilon,x1,fark,x2;
- printf("X1 : "); scanf("%lf",&x1);
- printf("epsilon : "); scanf("%lf",&epsilon);
- do{
- x2 = x1 - (f(x1) / fturev(x1)) ;
- fark = fabs(x1-x2);
- printf("x1 = %.15lf , x2 = %.15lf , fark = %.15lf \n",x1,x2,fark );
- if( fark > epsilon ) { x1 = x2;}
- } while( fark > epsilon );
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement