Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <cstdio>
  2. #include <cmath>
  3. #include <conio.h>
  4.  
  5. main() {
  6.     int n;
  7.     double a, b, h, r, k, S, Y, x, YS;
  8.    
  9.     printf("Enter a, b, h, n\n");
  10.     scanf("%lf %lf %lf %d", &a, &b, &h, &n);
  11.    
  12.     for (x = a; x <= b; x += h) {
  13.         S = 0;
  14.         for (k = 1; k <= n; k++) {
  15.             S += (pow(x,k)*cos(k*M_PI/3))/k;
  16.         }
  17.         Y = -0.5*log(1-2*x*cos(M_PI/3)+pow(x,2));
  18.         YS = fabs(S-Y);
  19.         printf("\n x = %2.4lf S(x) = %2.6lf Y(x) = %2.6lf |Y(x) - S(x)| = %2.6lf\n", x, S, Y, YS);
  20.     }
  21.    
  22.     getch();
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement