Advertisement
PikingFish

Untitled

Sep 12th, 2020
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #define _USE_MATH_DEFINES
  3. #include <math.h>
  4.  
  5. using namespace std;
  6.  
  7. long double pow_f(long double a, long double b)
  8. {
  9.     return exp(log(a) * b);
  10. }
  11.  
  12. int n;
  13.  
  14. long double s_f(long double x)
  15. {
  16.     long double sum = 1;
  17.     long double last = sum;
  18.     n=0;
  19.     while(last>0.0000001)
  20.     {
  21.         sum += x * x * (2 * n + 3) / (2 * n + 1) / (n + 1) * last;
  22.         last *= x * x * (2 * n + 3) / (2 * n + 1) / (n + 1);
  23.         n++;
  24.     }
  25.     return sum;
  26. }
  27.  
  28. long double y_f(long double x)
  29. {
  30.     return (1 + 2 * x * x)*exp(pow_f(x, 2.0));
  31. }
  32.  
  33. int main_f()
  34. {
  35.     for(long double i = 0.0; i <= 1.1; i += 0.2)
  36.     {
  37.         cout<<i<<"      "<<y_f(i)<<"        "<<s_f(i)<<"        "<<n<<endl;
  38.     }
  39. }
  40.  
  41. int main()
  42. {
  43.     system(" chcp 1251 > nul");
  44.     cout<<"x        "<<"Y(x)        "<<"S(x)        "<<'N'<<endl;
  45.     main_f();  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement