Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <math.h>
- #include <iostream>
- #include <conio.h>
- #include<stdio.h>
- #include <iomanip>
- using namespace std;
- int n;
- double f1(double x) {
- return (1 + x * x) / 2 * atan(x) - (x / 2);
- }
- double f2(double x) {
- double S = 0;
- double E = -1;
- for (int k = 1; k <= n; k++)
- {
- E *= (-1) * x * x;
- S = S + E * x / (4 * k * k - 1);
- }
- return S;
- }
- int main() {
- system("chcp 1251>nul");
- double a, b, h,E;
- double S;
- double x;
- cout << "Введите a,b,h,n\n";
- cin >> a >> b >> h >> n;
- cout << setw(30) << "Y" << setw(15) << "S" << setw(15) << "|S-Y|" << endl;
- for (x = a; x <= b; x += h)
- {
- f1(x);
- f2(x);
- cout << setw(30) << f1(x) << setw(15) << f2(x) << setw(15) << fabs(f2(x)- f1(x)) << endl;
- }
- system("pause>nul");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement