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