Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<math.h>
- #include<iostream>
- #define pi acos(-1.0)
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "RUS");
- double x, b, h, a, y, i, s0, s1, e, p, s, z;
- e = 0.0001;
- b = pi;
- h = pi / 25;
- a = pi / 5;
- i = 1;
- x = a;
- s = 0;
- z = 0;
- for (x = a; x <= b; x = x + h)
- {
- i = 1;
- z++;
- cout << "итерация for " << z << "\n";
- s0 = (pow(-1, i) * cos(i * x)) / (i * i);
- s1 = (pow(-1, (i + 1)) * cos((i + 1) * (x))) / ((i + 1) * (i + 1));
- while (fabs(s1) >= e)
- {
- cout << "итерация while " << i << "\n";
- s0 = (pow(-1, i) * cos(i * x)) / (i * i); cout << "s0=" << s0 << "\n";
- s1 = (pow(-1, (i + 1)) * cos((i + 1) * (x))) / ((i + 1) * (i + 1));
- y = ((x * x) - ((pi * pi) / 3));
- i++;
- //p = fabs(s0 - y);
- s = s + s0;
- //cout << "|s1-s0|=" << fabs(s1 - s0)<<"\n";
- //cout << "|s0-y|=" << p << "\n";
- cout << "y=" << y << "\n";
- }
- }
- cout << "Сумма равна " << s;
- return 0;
- }
Add Comment
Please, Sign In to add comment