Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. double x = 3.0, y1, y, sum=0;
  9. cout << "***********************************************************************" << endl;
  10. cout << "y = ";
  11. for (int n = 1; n < 21; n++){
  12. y = 2 * 1/((2*n+1)*pow(x,(2*n+1)));
  13. sum += y;
  14. if (n < 20)
  15. {
  16. cout << y << " + ";
  17. }
  18. else if (n == 20)
  19. {
  20. cout << y << " = ";
  21. }
  22. }
  23. cout << sum << endl;
  24. cout << "***********************************************************************" << endl;
  25. y1 = log((x+1)/(x-1));
  26. cout << "x = " << x << " y = " << sum << " y1 = " << y1 << endl;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement