Advertisement
noler89

Untitled

Feb 27th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. int sgn (double x0) {
  2. if (x0 > 0)
  3. return 1;
  4. else
  5. if (x0 == 0)
  6. return 0;
  7. else
  8. return -1;
  9. }
  10. double slagarctg (double x0, int k0) {
  11. if (fabs (x0) < 1)
  12. return (pow (-1, k0)*pow (x0, 2 * k0 + 1)) / (2 * k0 + 1);
  13. else
  14. if (fabs (x0)>=1)
  15. return( pow (-1, k0)*pow (x0, -(2 * k0 + 1))) / (2 * k0 + 1);
  16. }
  17. double arctgM (double x0) {
  18. int k = 0;
  19. double arctag = 0;
  20. double slag = 0;
  21. do{
  22. slag = slagarctg (x0, k++);
  23. arctag += slag;
  24. std::cout << " C = " << arctag << " slag = " << slag << std::endl;
  25. } while (fabs (slag)>E1);
  26. double arctag1 = arctag;
  27. if (fabs (x0) >= 1)
  28. arctag1 = PI / 2 * sgn (x0) - arctag;
  29. return arctag1;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement