Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. double Calc_Eps(){
  4. double eps = 1;
  5. while ((eps/2 + 1) > 1) eps /= 2;
  6. return eps;
  7. }
  8.  
  9. double Calc_Row(double x, int i){
  10. double ch = 1;
  11. double zn = 4;
  12. double res = 0;
  13. double eps = Calc_Eps();
  14. while ((ch/zn) > eps){
  15. double tmp = ch / zn;
  16. res += tmp;
  17. ch *= x*x*x*x;
  18. zn *= 4;
  19. i++;
  20. }
  21. return res;
  22. }
  23.  
  24. int main(){
  25. int i = 0;
  26. double x = 0.5;
  27. printf("%lf\n", x);
  28. x = 1/ (4 - x*x*x*x);
  29. printf("%.20lf\n", x);
  30. x = Calc_Row(x , i);
  31. printf("%.20lf%d" , x , i);
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement