Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cmath>
- #include <conio.h>
- main() {
- int n;
- double a, b, h, r, k, S, Y, x, YS;
- printf("Enter a, b, h, n\n");
- scanf("%lf %lf %lf %d", &a, &b, &h, &n);
- for (x = a; x <= b; x += h) {
- S = 0;
- for (k = 1; k <= n; k++) {
- S += (pow(x,k)*cos(k*M_PI/3))/k;
- }
- Y = -0.5*log(1-2*x*cos(M_PI/3)+pow(x,2));
- YS = fabs(S-Y);
- printf("\n x = %2.4lf S(x) = %2.6lf Y(x) = %2.6lf |Y(x) - S(x)| = %2.6lf\n", x, S, Y, YS);
- }
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement