Advertisement
Risonna

Check

Nov 28th, 2019
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.23 KB | None | 0 0
  1. #include<math.h>
  2. #include<iostream>
  3.  
  4. using namespace std;
  5. int main()
  6. {
  7.     setlocale(LC_ALL, "RUS");
  8.     double x, b, h, a, y, i, s0, s1, e, p, s, z, pi, j;
  9.     pi = acos(-1.0);
  10.     e = 0.0001;
  11.     b = pi;
  12.     h = pi / 25;
  13.     a = pi / 5;
  14.     j = (-1) * cos(pi * 0.2);
  15.     cout << "j=" << j;
  16.     //z = 0;
  17. //    cout << a;
  18.     for (x = a; x <= b; x = x + h)
  19.     {
  20.         s = 0;
  21.         i = 1;
  22.         //z++;
  23.         //cout << "итерация for " << z << "\n";
  24.         s0 = (pow(-1, i) * cos(i * x)) / (i * i);
  25.         do
  26.         {
  27.             //cout << "итерация while " << i << "\n";
  28.             s1 = s0;
  29.             s = s + s1;
  30.             i++;
  31.             s0 = (pow(-1, i) * cos(i * x)) / (i * i); //cout << "s0=" << s0 << "\n";
  32.             //p = fabs(s0 - y);
  33.             //cout << "|s1-s0|=" << fabs(s1 - s0)<<"\n";
  34.             //cout << "|s0-y|=" << p << "\n";
  35.             //cout << "y=" << y << "\n";
  36.         }
  37.         while (fabs(s0-s1) >= e);
  38.        
  39.         y = ((x * x) - ((pi * pi) / 3)*0.25);
  40.        
  41.         //cout << "y=" << y << "\n";
  42.         //cout << "|s-y|=" << fabs(s - y) << "\n";
  43.  
  44.         cout << "  " << endl;
  45.         cout << "sum=" << s << " " << y;
  46.     }
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement