SHARE
TWEET

Untitled

a guest Nov 13th, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. #define e 2.73
  6. #define E 0.000001
  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)\n");
  15.  
  16.   for(double x = 0; x < 5.5; x += 0.5)
  17.   {
  18.     double value = S(x);
  19.     printf("%.1lf\t|\t%.5lf\n", x, value);
  20.   }
  21.  
  22.   system("pause");
  23.   return 0;
  24. }
  25.  
  26. double F(double x)
  27. {
  28.   double x_k = 2 * x; double sum = x_k; int k = 2;
  29.  
  30.   while(fabs(x_k) > E)
  31.   {
  32.     x_k = x_k * (pow(-1, k) * pow(x, 2)) / (k * (2*k + 1));
  33.     sum += k; k++;
  34.   }
  35.  
  36.   return sum;
  37. }
  38.  
  39. double ch(double x)
  40. {
  41.   return (pow(e, x) + pow(e, -x)) / 2;
  42. }
  43.  
  44. double S(double x)
  45. {
  46.   return F(x) - sin(x) * ch(x);
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top