Advertisement
Risonna

Check1

Nov 28th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.17 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 = 0.8;
  12.     h = 0.1;
  13.     a = 0.1;
  14.     //z = 0;
  15. //    cout << a;
  16.     for (x = a; x <= b; x = x + h)
  17.     {
  18.         s = 0;
  19.         i = 1;
  20.         //z++;
  21.         //cout << "итерация for " << z << "\n";
  22.         s0 = (pow(x, i) * sin((pi * i) / 4));
  23.         do
  24.         {
  25.             //cout << "итерация while " << i << "\n";
  26.             s1 = s0;
  27.             s = s + s1;
  28.             i++;
  29.             s0 = (pow(x, i) * sin((pi * i) / 4)); //cout << "s0=" << s0 << "\n";
  30.             //p = fabs(s0 - y);
  31.             //cout << "|s1-s0|=" << fabs(s1 - s0)<<"\n";
  32.             //cout << "|s0-y|=" << p << "\n";
  33.             //cout << "y=" << y << "\n";
  34.         }
  35.         while (fabs(s0-s1) >= e);
  36.  
  37.         y = (x * sin(pi / 4) / (1 - 2 * x * cos(pi / 4) + x * x));
  38.  
  39.         //cout << "y=" << y << "\n";
  40.         //cout << "|s-y|=" << fabs(s - y) << "\n";
  41.  
  42.         cout << "  " << endl;
  43.         cout << "sum=" << s << " " << y;
  44.     }
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement