Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #include <conio.h>
- float func(float x);
- float sum(float x, float eps);
- void main()
- {
- float x,y,s,eps;
- printf("Vvedite eps: ");
- scanf("%f", &eps);
- if (eps<0) eps=0;
- for (x = 0.5; x <= 0.751; x=x+0.05) {
- s=sum(x,eps);
- y=func(x);
- printf("x=%4.2f => s=%f, y=%f \n", x, s, y);
- }
- getch();
- return;
- }
- //
- float func(float x)
- {
- return (1-cos(x))/x/x-sin(x)/x+0.5;}
- //
- float sum(float x, float eps)
- {
- int n;
- float t,a,b;
- t=0;
- n=1;
- a=-1;
- while (fabs(a)>eps)
- {b=-x*x/(2*n-1)/(2*n+2)/2;
- a=a*b;
- t=t+a;
- n=n+1;}
- return t;}
Add Comment
Please, Sign In to add comment