Advertisement
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, s, e, p;
- e = 1.4e-1;
- b = pi;
- h = pi / 25;
- a = pi / 5;
- i = 1;
- x = a;
- s = (pow(-1, i) * cos(i * x)) / (i * i);
- p = (pow(-1, (i+1)) * cos((i+1) * (x+h))) / ((i+1) * (i+1));
- for (x = a; x <= b; x = x + h)
- {
- i++;
- p += (pow(-1, i) * cos(i * x)) / (i * i);
- if (fabs(p - s) > e)
- {
- s += (pow(-1, i) * cos(i * x)) / (i * i);
- continue;
- }
- else
- {
- break;
- }
- y = ((x * x) - ((pi * pi) / 3));
- }
- cout << "Сумма равна" << s;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement