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 = 0.8;
- h = 0.1;
- a = 0.1;
- //z = 0;
- // cout << a;
- for (x = a; x <= b; x = x + h)
- {
- s = 0;
- i = 1;
- //z++;
- //cout << "итерация for " << z << "\n";
- s0 = (pow(x, i) * sin((pi * i) / 4));
- do
- {
- //cout << "итерация while " << i << "\n";
- s1 = s0;
- s = s + s1;
- i++;
- s0 = (pow(x, i) * sin((pi * i) / 4)); //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 * sin(pi / 4) / (1 - 2 * x * cos(pi / 4) + x * x));
- //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