Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include"stdafx.h"
- #include<conio.h>
- #include<vector>
- #include<clocale>
- #include<iostream>
- #include<math.h>
- using namespace std;
- double f(double x, double eps)
- {
- #define pi 3,1415926
- double sum = (pi / 2);
- long n = 1;
- double fn = 1 / (3 * pow(x, 3.00));
- while (eps < fabs(fn))
- {
- sum += fn;
- n += 1;
- fn *= pow(-1, n + 1);
- fn /= (2 * n + 1) * pow(x, 2 * n + 1);
- }
- return sum;
- }
- int main()
- {
- char sign[] = " ";
- double x, fx, dx = 0.1, xn = 0, xk = 0, eps = 0.001;
- cout << "Enter xn : ";
- cin >> xn;
- printf("Enter xk : ");
- cin >> xk;
- printf("|----------------|\n");
- printf("| x | atan |\n");
- printf("|----------------|\n");
- for (x = xn; x <= xk; x += dx)
- {
- fx = f(x, eps);
- if (x < 3)
- sign[0] = '\0';
- else
- sign[0] = ' ';
- printf("|%s%.4f|%s%.4f |\n",
- sign, x, sign, atan(fx));
- }
- printf("|---------------|\n");
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement