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 func(double x, double eps)
- {
- double sum = x;
- long n = 1;
- double fn = pow(x, 3) / 6.0;
- while (eps < fabs(fn))
- {
- sum += fn;
- n += 1;
- fn *= (2 * n - 1) * (2 * n - 1) * x * x;
- fn /= 2 * n * (2 * n + 1);
- }
- return sum;
- }
- int main()
- {
- setlocale(LC_CTYPE, "Rus");
- system("title Ряд Тейлора, практична робота №1");
- char null[] = " ";
- double x, fx, dx = 0.1, xn = 0, xk = 0, eps = 0.001;
- cout << "Введите xn: ";
- cin >> xn;
- if (xn < -1 || xn > 1 || xn < xk)
- {
- cout << "Тригонометрическая ошибка." << endl;
- return(0);
- }
- cout << "Введите xk: ";
- cin >> xk;
- if (xk < xn || xk > 1 || xk < -1)
- {
- cout << "Тригонометрическая ошибка." << endl;
- return(0);
- }
- cout << "|-----------------------------------------------|" << endl;
- cout << "|\t\t x \t| \t asin |" << endl;
- cout << "|-----------------------------------------------|" << endl;
- for (x = xn; x <= xk; x += dx)
- {
- fx = func(x, eps);
- if (x < -1){
- null[0] = '\0';
- }else{
- null[0] = ' ';
- printf("\t %s%.4f\t|\t%s%.4f\n", null, x, null, asin(fx));
- }
- }
- cout << "|-----------------------------------------------|" << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement