Advertisement
JewishCat

Teilor_5v

Dec 19th, 2015
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <math.h>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. double esx(double x, double epsl);
  9.  
  10. int main(int argc, char** argv) {
  11.    
  12.     double x;
  13.     double epsl;
  14.     cout << "Enter value a X:" << endl;
  15.     cin >> x;
  16.     cout << "Enter value a Epsl:" << endl;
  17.     cin >> epsl;
  18.     double x1 = (1/(1-x));
  19.     cout << "x=" << x1 << endl << "x1=" << esx(x,epsl) << endl;
  20.     system("pause");
  21.     return 0;
  22. }
  23.  
  24. double esx(double x, double epsl){
  25.     int n=0;
  26.     double s = 1;
  27.     double p = s;
  28.     double xn=x;
  29.     do{
  30.         for(int i=1;i<=n;++i){
  31.             xn=xn*x;
  32.         }
  33.         p=p+xn;
  34.         s=xn;
  35.         xn=x;
  36.         n++;
  37.     }while(fabs(s)>epsl);
  38.     return p;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement