Advertisement
semenrbt

asfasfaf

Feb 12th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main() {
  5. long double EPS = 0;
  6. long double EP = 1, ep = 1;
  7. long double x = 0;
  8. printf("Enter EPS(0 < EPS < 1) = ");
  9. if(scanf("%Lf", &EPS) != 1)
  10. {
  11. printf("Error.\n");
  12. return 0;
  13. }
  14. printf("Enter x = ");
  15. if(scanf("%Lf", &x) != 1)
  16. {
  17. printf("Error.\n");
  18. return 0;
  19. }
  20. int k = 1;
  21. long double y = 1;
  22. long double powx = x*x*(-1);
  23. int factorial = 2;
  24. int f = 2;
  25. if(EPS >= 1 || EPS <= 0)
  26. {
  27. printf("Error EPS.\n");
  28. return 0;
  29. }
  30. printf("cos(x) = %f;\n", cos(x));
  31. while(k < 10)
  32. {
  33. EP = powx/factorial;
  34. y = y + EP;
  35. powx = powx*x*x*(-1);
  36. factorial = factorial*(f + 1)*(f + 2);
  37. f = f + 2;
  38. k++;
  39. printf("EP = %1.25Lf\n", EP);
  40. }
  41. printf("Teilor = %Lf\n", y);
  42.  
  43.  
  44.  
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement