SHARE
TWEET

d2

a guest Nov 19th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <math.h>
  2. #include <iostream>
  3. #include <conio.h>
  4. #include<stdio.h>
  5. #include <iomanip>
  6.  
  7. using namespace std;
  8.  
  9. int n;
  10.  
  11. double f1(double x) {
  12.  
  13.     return (1 + x * x) / 2 * atan(x) - (x / 2);
  14. }
  15.  
  16. double f2(double x) {
  17.     double S = 0;
  18.     double E = -1;
  19.     for (int k = 1; k <= n; k++)
  20.     {
  21.         E *= (-1) * x * x;
  22.         S = S + E * x / (4 * k * k - 1);
  23.     }
  24.     return S;
  25.  
  26. }
  27. int main() {
  28.     system("chcp 1251>nul");
  29.     double a, b, h,E;
  30.     double S;
  31.     double x;
  32.     cout << "Введите a,b,h,n\n";
  33.     cin >> a >> b >> h >> n;
  34.     cout << setw(30) << "Y" << setw(15) << "S" << setw(15) << "|S-Y|" << endl;
  35.     for (x = a; x <= b; x += h)
  36.     {
  37.    
  38.         f1(x);
  39.         f2(x);
  40.         cout << setw(30) << f1(x) << setw(15) << f2(x) << setw(15) << fabs(f2(x)- f1(x)) << endl;
  41.     }
  42.     system("pause>nul");
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top