Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _USE_MATH_DEFINES
- #include<math.h>
- #include<iostream>
- #include <stdio.h>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "RUS");
- double x, b, h, a, y, i, s0, s1, e, s;
- e = 0.0001;
- b = M_PI;
- h = M_PI / 25;
- a = M_PI / 5;
- for (x = a; x <= b; x = x + h)
- {
- s = 0;
- i = 1;
- s0 = pow(-1, i) * cos(i * x) / (i * i);
- do
- {
- s1 = s0;
- s = s + s1;
- i++;
- s0 = (pow(-1, i) * cos(i * x)) / (i * i);
- } while (fabs(s0 - s1) >= e);
- y = (x * x - M_PI * M_PI / 3) * 0.25;
- cout << "sum=" << s << " " << "y=" << y << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment