Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. #define e 2.73
  6. #define E pow(10, -6)
  7.  
  8. double F(double x);
  9. double S(double x);
  10. double ch(double x);
  11.  
  12. int main(void)
  13. {
  14. printf(" x \t|\t S(x) \t\t|\t F(x)\n");
  15.  
  16. for(double x = 0.5; x < 5.5; x += 0.5)
  17. {
  18. double s = S(x);
  19. double f = F(x);
  20. printf("%.1lf\t|\t%.6lf\t|\t%.5lf \n", x, s, f);
  21. }
  22.  
  23. system("pause");
  24. return 0;
  25. }
  26.  
  27. double F(double x)
  28. {
  29. double x_k = x; double sum = x_k; int k = 2;
  30.  
  31. while(fabs(x_k) > E)
  32. {
  33. x_k *= (pow(-1, k) * (x*x) / (k * (2*k+1)));
  34. sum += x_k; k++;
  35. }
  36.  
  37. return sum;
  38. }
  39.  
  40. double ch(double x)
  41. {
  42. return (pow(e, x) + pow(e, -x)) / 2;
  43. }
  44.  
  45. double S(double x)
  46. {
  47. return F(x) - sin(x) * ch(x);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement