Advertisement
al3taibi

Untitled

May 24th, 2022
776
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. void process(double Xn, double Xk, double dX, double eps) {
  9.     while (Xn < Xk) {
  10.         int n{};
  11.         double res = 0, prev_res = 0, sum = 0;
  12.         res = pow(Xn, 2 * n + 1) / (2 * n + 1);
  13.         while (fabs(res - prev_res) > eps) {
  14.             sum += res;
  15.             prev_res = res;
  16.             n++;
  17.             res = pow(Xn, 2 * n + 1) / (2 * n + 1);
  18.         }
  19.         cout << Xn << " " << setprecision(4) << sum << " " << (n + 1) << " " << setprecision(4)
  20.              << atanh(Xn) << endl;
  21.  
  22.         Xn += dX;
  23.     }
  24. }
  25.  
  26. int main() {
  27.     double Xn, Xk, dX, eps;
  28.     cin >> Xn >> Xk >> dX >> eps;
  29.  
  30.     process(Xn, Xk, dX, eps);
  31.  
  32.     return 0;
  33. }
Advertisement
RAW Paste Data Copied
Advertisement