Advertisement
Infiniti_Inter

F(x) = 1 - (x/(2*7)) + ...

Dec 16th, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include<iostream>
  2. #include<math.h>
  3.  
  4. using namespace std;
  5.  
  6. int tw = 2, svn = 7;
  7. double x, current_x;
  8. int cur = 1;
  9.  
  10. double abs(double a){return a > 0 ? a : -a;}
  11.  
  12. double next(int i)
  13. {
  14. return (current_x * x)/(tw * i * svn * i);
  15. }
  16.  
  17. int main()
  18. {
  19. cout << "Enter 'X' : ";
  20. cin >> x;
  21. double eps;
  22. cout << "Enter 'eps' : ";
  23. cin >> eps;
  24. double answer = 1;
  25. current_x = -1;
  26. int i = 1;
  27. while (abs(next(i)) >= eps )
  28. {
  29. answer += next(i++);
  30. current_x *= -x;
  31. }
  32. cout << answer;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement