Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #define _USE_MATH_DEFINES
- #include "math.h"
- #include <windows.h>
- using namespace std;
- double receq(double t, double f, double x, double e, int i) {
- double t1 = t * pow(-1, i + 1) * pow(x, 2) * log(1 + 2 * i) / (4 * log(1 + 2 * (i - 1)));
- f += t1;
- if (abs(t1) <= e) {
- return f;
- }
- else {
- return receq(t1, f, x, e, i + 1);
- }
- }
- void main()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- double e;
- cout << "Введите точность вычисления" << endl;
- cin >> e;
- double x;
- cout << "Введите x" << endl;
- cin >> x;
- double s = 0, t = 1;
- int N = 1;
- while (abs(t) > e) {
- t = pow(-1, N + 1) * pow(x, 2 * N) * log(1 + 2 * N) / (4 * pow(N, 2));
- s += t;
- N++;
- }
- cout.precision(15);
- cout << "Сумма ряда через общую формулу = " << s << endl;
- double r, k1 = pow(x, 2) * log(3) / 4;
- r = receq(k1, k1, x, e, 2);
- cout.precision(15);
- cout << "Сумма ряда через смешанный способ = " << r << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement