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)
- {
- s = 0;
- 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-s0) >= e)
- {
- //cout << "итерация while " << i << "\n";
- s0 = (pow(-1, i) * cos(i * x)) / (i * i);
- s1 = (pow(-1, (i + 1)) * cos((i + 1) * (x))) / ((i + 1) * (i + 1));
- i++;
- //p = fabs(s0 - y);
- s = s + s0;
- //cout << "|s1-s0|=" << fabs(s1 - s0)<<"\n";
- //cout << "|s0-y|=" << p << "\n";
- }
- y = (((x * x) - ((pi * pi) / 3))/4);
- cout << "y=" << y << " s=" << s << "\n";
- //cout << "s=" << s << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment